mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge branch 'master' of github.com:Human-Connection/Human-Connection into 1703-add-vue-apollo-subsriptions
This commit is contained in:
commit
f16c8b27e7
@ -61,7 +61,7 @@
|
|||||||
"graphql-middleware": "~4.0.2",
|
"graphql-middleware": "~4.0.2",
|
||||||
"graphql-middleware-sentry": "^3.2.1",
|
"graphql-middleware-sentry": "^3.2.1",
|
||||||
"graphql-redis-subscriptions": "^2.1.2",
|
"graphql-redis-subscriptions": "^2.1.2",
|
||||||
"graphql-shield": "~7.0.10",
|
"graphql-shield": "~7.0.11",
|
||||||
"graphql-tag": "~2.10.3",
|
"graphql-tag": "~2.10.3",
|
||||||
"helmet": "~3.21.2",
|
"helmet": "~3.21.2",
|
||||||
"ioredis": "^4.14.1",
|
"ioredis": "^4.14.1",
|
||||||
@ -130,6 +130,7 @@
|
|||||||
"jest": "~25.1.0",
|
"jest": "~25.1.0",
|
||||||
"nodemon": "~2.0.2",
|
"nodemon": "~2.0.2",
|
||||||
"prettier": "~1.19.1",
|
"prettier": "~1.19.1",
|
||||||
|
"rosie": "^2.0.1",
|
||||||
"supertest": "~4.0.2"
|
"supertest": "~4.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { handler } from './webfinger'
|
import { handler } from './webfinger'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { getDriver } from '../../db/neo4j'
|
import { getDriver } from '../../db/neo4j'
|
||||||
|
|
||||||
let resource, res, json, status, contentType
|
let resource, res, json, status, contentType
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
const request = () => {
|
const request = () => {
|
||||||
@ -28,7 +27,7 @@ const request = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('webfinger', () => {
|
describe('webfinger', () => {
|
||||||
@ -90,7 +89,7 @@ describe('webfinger', () => {
|
|||||||
|
|
||||||
describe('given a user for acct', () => {
|
describe('given a user for acct', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', { slug: 'some-user' })
|
await Factory.build('user', { slug: 'some-user' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns user object', async () => {
|
it('returns user object', async () => {
|
||||||
|
|||||||
@ -4,6 +4,9 @@ if (require.resolve) {
|
|||||||
dotenv.config({ path: require.resolve('../../.env') })
|
dotenv.config({ path: require.resolve('../../.env') })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const env = typeof Cypress !== 'undefined' ? Cypress.env() : process.env
|
||||||
|
|
||||||
const {
|
const {
|
||||||
MAPBOX_TOKEN,
|
MAPBOX_TOKEN,
|
||||||
JWT_SECRET,
|
JWT_SECRET,
|
||||||
@ -23,7 +26,7 @@ const {
|
|||||||
REDIS_DOMAIN,
|
REDIS_DOMAIN,
|
||||||
REDIS_PORT,
|
REDIS_PORT,
|
||||||
REDIS_PASSWORD,
|
REDIS_PASSWORD,
|
||||||
} = process.env
|
} = env
|
||||||
|
|
||||||
export const requiredConfigs = {
|
export const requiredConfigs = {
|
||||||
MAPBOX_TOKEN,
|
MAPBOX_TOKEN,
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { cleanDatabase } from '../factories'
|
import { cleanDatabase } from '../db/factories'
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'production') {
|
if (process.env.NODE_ENV === 'production') {
|
||||||
throw new Error(`You cannot clean the database in production environment!`)
|
throw new Error(`You cannot clean the database in production environment!`)
|
||||||
|
|||||||
226
backend/src/db/factories.js
Normal file
226
backend/src/db/factories.js
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
import uuid from 'uuid/v4'
|
||||||
|
import faker from 'faker'
|
||||||
|
import slugify from 'slug'
|
||||||
|
import { hashSync } from 'bcryptjs'
|
||||||
|
import { Factory } from 'rosie'
|
||||||
|
import { getDriver, getNeode } from './neo4j'
|
||||||
|
|
||||||
|
const neode = getNeode()
|
||||||
|
|
||||||
|
export const cleanDatabase = async (options = {}) => {
|
||||||
|
const { driver = getDriver() } = options
|
||||||
|
const session = driver.session()
|
||||||
|
try {
|
||||||
|
await session.writeTransaction(transaction => {
|
||||||
|
return transaction.run(
|
||||||
|
`
|
||||||
|
MATCH (everything)
|
||||||
|
DETACH DELETE everything
|
||||||
|
`,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
session.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Factory.define('category')
|
||||||
|
.attr('id', uuid)
|
||||||
|
.attr('icon', 'globe')
|
||||||
|
.attr('name', 'global-peace-nonviolence')
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('Category', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('badge')
|
||||||
|
.attr('type', 'crowdfunding')
|
||||||
|
.attr('status', 'permanent')
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('Badge', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('userWithoutEmailAddress')
|
||||||
|
.option('password', '1234')
|
||||||
|
.attrs({
|
||||||
|
id: uuid,
|
||||||
|
name: faker.name.findName,
|
||||||
|
password: '1234',
|
||||||
|
role: 'user',
|
||||||
|
avatar: faker.internet.avatar,
|
||||||
|
about: faker.lorem.paragraph,
|
||||||
|
termsAndConditionsAgreedVersion: '0.0.1',
|
||||||
|
termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z',
|
||||||
|
allowEmbedIframes: false,
|
||||||
|
showShoutsPublicly: false,
|
||||||
|
locale: 'en',
|
||||||
|
})
|
||||||
|
.attr('slug', ['slug', 'name'], (slug, name) => {
|
||||||
|
return slug || slugify(name, { lower: true })
|
||||||
|
})
|
||||||
|
.attr('encryptedPassword', ['password'], password => {
|
||||||
|
return hashSync(password, 10)
|
||||||
|
})
|
||||||
|
.after(async (buildObject, options) => {
|
||||||
|
return neode.create('User', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('user')
|
||||||
|
.extend('userWithoutEmailAddress')
|
||||||
|
.option('email', faker.internet.exampleEmail)
|
||||||
|
.after(async (buildObject, options) => {
|
||||||
|
const [user, email] = await Promise.all([
|
||||||
|
buildObject,
|
||||||
|
neode.create('EmailAddress', { email: options.email }),
|
||||||
|
])
|
||||||
|
await Promise.all([user.relateTo(email, 'primaryEmail'), email.relateTo(user, 'belongsTo')])
|
||||||
|
return user
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('post')
|
||||||
|
.option('categoryIds', [])
|
||||||
|
.option('categories', ['categoryIds'], categoryIds => {
|
||||||
|
if (categoryIds.length) return Promise.all(categoryIds.map(id => neode.find('Category', id)))
|
||||||
|
// there must be at least one category
|
||||||
|
return Promise.all([Factory.build('category')])
|
||||||
|
})
|
||||||
|
.option('tagIds', [])
|
||||||
|
.option('tags', ['tagIds'], tagIds => {
|
||||||
|
return Promise.all(tagIds.map(id => neode.find('Tag', id)))
|
||||||
|
})
|
||||||
|
.option('authorId', null)
|
||||||
|
.option('author', ['authorId'], authorId => {
|
||||||
|
if (authorId) return neode.find('User', authorId)
|
||||||
|
return Factory.build('user')
|
||||||
|
})
|
||||||
|
.option('pinnedBy', null)
|
||||||
|
.attrs({
|
||||||
|
id: uuid,
|
||||||
|
title: faker.lorem.sentence,
|
||||||
|
content: faker.lorem.paragraphs,
|
||||||
|
image: faker.image.unsplash.imageUrl,
|
||||||
|
visibility: 'public',
|
||||||
|
deleted: false,
|
||||||
|
imageBlurred: false,
|
||||||
|
imageAspectRatio: 1.333,
|
||||||
|
})
|
||||||
|
.attr('pinned', ['pinned'], pinned => {
|
||||||
|
// Convert false to null
|
||||||
|
return pinned || null
|
||||||
|
})
|
||||||
|
.attr('contentExcerpt', ['contentExcerpt', 'content'], (contentExcerpt, content) => {
|
||||||
|
return contentExcerpt || content
|
||||||
|
})
|
||||||
|
.attr('slug', ['slug', 'title'], (slug, title) => {
|
||||||
|
return slug || slugify(title, { lower: true })
|
||||||
|
})
|
||||||
|
.after(async (buildObject, options) => {
|
||||||
|
const [post, author, categories, tags] = await Promise.all([
|
||||||
|
neode.create('Post', buildObject),
|
||||||
|
options.author,
|
||||||
|
options.categories,
|
||||||
|
options.tags,
|
||||||
|
])
|
||||||
|
await Promise.all([
|
||||||
|
post.relateTo(author, 'author'),
|
||||||
|
Promise.all(categories.map(c => c.relateTo(post, 'post'))),
|
||||||
|
Promise.all(tags.map(t => t.relateTo(post, 'post'))),
|
||||||
|
])
|
||||||
|
if (buildObject.pinned) {
|
||||||
|
const pinnedBy = await (options.pinnedBy || Factory.build('user', { role: 'admin' }))
|
||||||
|
await pinnedBy.relateTo(post, 'pinned')
|
||||||
|
}
|
||||||
|
return post
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('comment')
|
||||||
|
.option('postId', null)
|
||||||
|
.option('post', ['postId'], postId => {
|
||||||
|
if (postId) return neode.find('Post', postId)
|
||||||
|
return Factory.build('post')
|
||||||
|
})
|
||||||
|
.option('authorId', null)
|
||||||
|
.option('author', ['authorId'], authorId => {
|
||||||
|
if (authorId) return neode.find('User', authorId)
|
||||||
|
return Factory.build('user')
|
||||||
|
})
|
||||||
|
.attrs({
|
||||||
|
id: uuid,
|
||||||
|
content: faker.lorem.sentence,
|
||||||
|
})
|
||||||
|
.attr('contentExcerpt', ['contentExcerpt', 'content'], (contentExcerpt, content) => {
|
||||||
|
return contentExcerpt || content
|
||||||
|
})
|
||||||
|
.after(async (buildObject, options) => {
|
||||||
|
const [comment, author, post] = await Promise.all([
|
||||||
|
neode.create('Comment', buildObject),
|
||||||
|
options.author,
|
||||||
|
options.post,
|
||||||
|
])
|
||||||
|
await Promise.all([comment.relateTo(author, 'author'), comment.relateTo(post, 'post')])
|
||||||
|
return comment
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('donations')
|
||||||
|
.attr('id', uuid)
|
||||||
|
.attr('goal', 15000)
|
||||||
|
.attr('progress', 0)
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('Donations', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
const emailDefaults = {
|
||||||
|
email: faker.internet.email,
|
||||||
|
verifiedAt: () => new Date().toISOString(),
|
||||||
|
}
|
||||||
|
|
||||||
|
Factory.define('emailAddress')
|
||||||
|
.attr(emailDefaults)
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('EmailAddress', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('unverifiedEmailAddress')
|
||||||
|
.attr(emailDefaults)
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('UnverifiedEmailAddress', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('location')
|
||||||
|
.attrs({
|
||||||
|
name: 'Germany',
|
||||||
|
namePT: 'Alemanha',
|
||||||
|
nameDE: 'Deutschland',
|
||||||
|
nameES: 'Alemania',
|
||||||
|
nameNL: 'Duitsland',
|
||||||
|
namePL: 'Niemcy',
|
||||||
|
nameFR: 'Allemagne',
|
||||||
|
nameIT: 'Germania',
|
||||||
|
nameEN: 'Germany',
|
||||||
|
id: 'country.10743216036480410',
|
||||||
|
type: 'country',
|
||||||
|
})
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('Location', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('report').after((buildObject, options) => {
|
||||||
|
return neode.create('Report', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('tag')
|
||||||
|
.attrs({
|
||||||
|
name: '#human-connection',
|
||||||
|
})
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('Tag', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
Factory.define('socialMedia')
|
||||||
|
.attrs({
|
||||||
|
url: 'https://mastodon.social/@Gargron',
|
||||||
|
})
|
||||||
|
.after((buildObject, options) => {
|
||||||
|
return neode.create('SocialMedia', buildObject)
|
||||||
|
})
|
||||||
|
|
||||||
|
export default Factory
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,15 +0,0 @@
|
|||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
type: 'crowdfunding',
|
|
||||||
status: 'permanent',
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('Badge', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
import uuid from 'uuid/v4'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
id: uuid(),
|
|
||||||
icon: 'img/badges/fundraisingbox_de_airship.svg',
|
|
||||||
name: 'Some category name',
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('Category', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +0,0 @@
|
|||||||
import faker from 'faker'
|
|
||||||
import uuid from 'uuid/v4'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance, factoryInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
id: uuid(),
|
|
||||||
content: [faker.lorem.sentence(), faker.lorem.sentence()].join('. '),
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
args.contentExcerpt = args.contentExcerpt || args.content
|
|
||||||
|
|
||||||
let { post, postId } = args
|
|
||||||
delete args.post
|
|
||||||
delete args.postId
|
|
||||||
if (post && postId) throw new Error('You provided both post and postId')
|
|
||||||
if (postId) post = await neodeInstance.find('Post', postId)
|
|
||||||
post = post || (await factoryInstance.create('Post'))
|
|
||||||
|
|
||||||
let { author, authorId } = args
|
|
||||||
delete args.author
|
|
||||||
delete args.authorId
|
|
||||||
if (author && authorId) throw new Error('You provided both author and authorId')
|
|
||||||
if (authorId) author = await neodeInstance.find('User', authorId)
|
|
||||||
author = author || (await factoryInstance.create('User'))
|
|
||||||
|
|
||||||
delete args.author
|
|
||||||
const comment = await neodeInstance.create('Comment', args)
|
|
||||||
await comment.relateTo(post, 'post')
|
|
||||||
await comment.relateTo(author, 'author')
|
|
||||||
return comment
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
import uuid from 'uuid/v4'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
id: uuid(),
|
|
||||||
goal: 15000,
|
|
||||||
progress: 0,
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('Donations', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
import faker from 'faker'
|
|
||||||
|
|
||||||
export function defaults({ args }) {
|
|
||||||
const defaults = {
|
|
||||||
email: faker.internet.email(),
|
|
||||||
verifiedAt: new Date().toISOString(),
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return args
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
args = defaults({ args })
|
|
||||||
return neodeInstance.create('EmailAddress', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,63 +0,0 @@
|
|||||||
import { getDriver, getNeode } from '../db/neo4j'
|
|
||||||
|
|
||||||
const factories = {
|
|
||||||
Badge: require('./badges.js').default,
|
|
||||||
User: require('./users.js').default,
|
|
||||||
Post: require('./posts.js').default,
|
|
||||||
Comment: require('./comments.js').default,
|
|
||||||
Category: require('./categories.js').default,
|
|
||||||
Tag: require('./tags.js').default,
|
|
||||||
SocialMedia: require('./socialMedia.js').default,
|
|
||||||
Location: require('./locations.js').default,
|
|
||||||
EmailAddress: require('./emailAddresses.js').default,
|
|
||||||
UnverifiedEmailAddress: require('./unverifiedEmailAddresses.js').default,
|
|
||||||
Donations: require('./donations.js').default,
|
|
||||||
Report: require('./reports.js').default,
|
|
||||||
}
|
|
||||||
|
|
||||||
export const cleanDatabase = async (options = {}) => {
|
|
||||||
const { driver = getDriver() } = options
|
|
||||||
const session = driver.session()
|
|
||||||
try {
|
|
||||||
await session.writeTransaction(transaction => {
|
|
||||||
return transaction.run(
|
|
||||||
`
|
|
||||||
MATCH (everything)
|
|
||||||
DETACH DELETE everything
|
|
||||||
`,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
session.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Factory(options = {}) {
|
|
||||||
const { neo4jDriver = getDriver(), neodeInstance = getNeode() } = options
|
|
||||||
|
|
||||||
const result = {
|
|
||||||
neo4jDriver,
|
|
||||||
factories,
|
|
||||||
lastResponse: null,
|
|
||||||
neodeInstance,
|
|
||||||
async create(node, args = {}) {
|
|
||||||
const { factory } = this.factories[node](args)
|
|
||||||
this.lastResponse = await factory({
|
|
||||||
args,
|
|
||||||
neodeInstance,
|
|
||||||
factoryInstance: this,
|
|
||||||
})
|
|
||||||
return this.lastResponse
|
|
||||||
},
|
|
||||||
|
|
||||||
async cleanDatabase() {
|
|
||||||
this.lastResponse = await cleanDatabase({
|
|
||||||
driver: this.neo4jDriver,
|
|
||||||
})
|
|
||||||
return this
|
|
||||||
},
|
|
||||||
}
|
|
||||||
result.create.bind(result)
|
|
||||||
result.cleanDatabase.bind(result)
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
name: 'Germany',
|
|
||||||
namePT: 'Alemanha',
|
|
||||||
nameDE: 'Deutschland',
|
|
||||||
nameES: 'Alemania',
|
|
||||||
nameNL: 'Duitsland',
|
|
||||||
namePL: 'Niemcy',
|
|
||||||
nameFR: 'Allemagne',
|
|
||||||
nameIT: 'Germania',
|
|
||||||
nameEN: 'Germany',
|
|
||||||
id: 'country.10743216036480410',
|
|
||||||
type: 'country',
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('Location', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,89 +0,0 @@
|
|||||||
import faker from 'faker'
|
|
||||||
import slugify from 'slug'
|
|
||||||
import uuid from 'uuid/v4'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance, factoryInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
id: uuid(),
|
|
||||||
title: faker.lorem.sentence(),
|
|
||||||
content: [
|
|
||||||
faker.lorem.sentence(),
|
|
||||||
faker.lorem.sentence(),
|
|
||||||
faker.lorem.sentence(),
|
|
||||||
faker.lorem.sentence(),
|
|
||||||
faker.lorem.sentence(),
|
|
||||||
].join('. '),
|
|
||||||
image: faker.image.unsplash.imageUrl(),
|
|
||||||
visibility: 'public',
|
|
||||||
deleted: false,
|
|
||||||
categoryIds: [],
|
|
||||||
imageBlurred: false,
|
|
||||||
imageAspectRatio: 1.333,
|
|
||||||
pinned: null,
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
// Convert false to null
|
|
||||||
args.pinned = args.pinned || null
|
|
||||||
|
|
||||||
args.slug = args.slug || slugify(args.title, { lower: true })
|
|
||||||
args.contentExcerpt = args.contentExcerpt || args.content
|
|
||||||
|
|
||||||
let { categories, categoryIds } = args
|
|
||||||
delete args.categories
|
|
||||||
delete args.categoryIds
|
|
||||||
if (categories && categoryIds) throw new Error('You provided both categories and categoryIds')
|
|
||||||
if (categoryIds)
|
|
||||||
categories = await Promise.all(categoryIds.map(id => neodeInstance.find('Category', id)))
|
|
||||||
categories = categories || (await Promise.all([factoryInstance.create('Category')]))
|
|
||||||
const { tagIds = [] } = args
|
|
||||||
delete args.tags
|
|
||||||
const tags = await Promise.all(
|
|
||||||
tagIds.map(t => {
|
|
||||||
return neodeInstance.find('Tag', t)
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
|
|
||||||
let { author, authorId } = args
|
|
||||||
delete args.author
|
|
||||||
delete args.authorId
|
|
||||||
if (author && authorId) throw new Error('You provided both author and authorId')
|
|
||||||
if (authorId) author = await neodeInstance.find('User', authorId)
|
|
||||||
author = author || (await factoryInstance.create('User'))
|
|
||||||
const post = await neodeInstance.create('Post', args)
|
|
||||||
|
|
||||||
const { commentContent } = args
|
|
||||||
let comment
|
|
||||||
delete args.commentContent
|
|
||||||
if (commentContent)
|
|
||||||
comment = await factoryInstance.create('Comment', {
|
|
||||||
contentExcerpt: commentContent,
|
|
||||||
post,
|
|
||||||
author,
|
|
||||||
})
|
|
||||||
|
|
||||||
await post.relateTo(author, 'author')
|
|
||||||
if (comment) await post.relateTo(comment, 'comments')
|
|
||||||
|
|
||||||
if (args.pinned) {
|
|
||||||
args.pinnedAt = args.pinnedAt || new Date().toISOString()
|
|
||||||
if (!args.pinnedBy) {
|
|
||||||
const admin = await factoryInstance.create('User', {
|
|
||||||
role: 'admin',
|
|
||||||
updatedAt: new Date().toISOString(),
|
|
||||||
})
|
|
||||||
await admin.relateTo(post, 'pinned')
|
|
||||||
args.pinnedBy = admin
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await Promise.all(categories.map(c => c.relateTo(post, 'post')))
|
|
||||||
await Promise.all(tags.map(t => t.relateTo(post, 'post')))
|
|
||||||
return post
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
return neodeInstance.create('Report', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
url: 'https://mastodon.social/@Gargron',
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('SocialMedia', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
const defaults = { name: '#human-connection' }
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
return neodeInstance.create('Tag', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import { defaults } from './emailAddresses.js'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance }) => {
|
|
||||||
args = defaults({ args })
|
|
||||||
return neodeInstance.create('UnverifiedEmailAddress', args)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
import faker from 'faker'
|
|
||||||
import uuid from 'uuid/v4'
|
|
||||||
import encryptPassword from '../helpers/encryptPassword'
|
|
||||||
import slugify from 'slug'
|
|
||||||
|
|
||||||
export default function create() {
|
|
||||||
return {
|
|
||||||
factory: async ({ args, neodeInstance, factoryInstance }) => {
|
|
||||||
const defaults = {
|
|
||||||
id: uuid(),
|
|
||||||
name: faker.name.findName(),
|
|
||||||
email: faker.internet.email(),
|
|
||||||
password: '1234',
|
|
||||||
role: 'user',
|
|
||||||
avatar: faker.internet.avatar(),
|
|
||||||
about: faker.lorem.paragraph(),
|
|
||||||
termsAndConditionsAgreedVersion: '0.0.1',
|
|
||||||
termsAndConditionsAgreedAt: '2019-08-01T10:47:19.212Z',
|
|
||||||
allowEmbedIframes: false,
|
|
||||||
showShoutsPublicly: false,
|
|
||||||
locale: 'en',
|
|
||||||
}
|
|
||||||
defaults.slug = slugify(defaults.name, { lower: true })
|
|
||||||
args = {
|
|
||||||
...defaults,
|
|
||||||
...args,
|
|
||||||
}
|
|
||||||
args = await encryptPassword(args)
|
|
||||||
const user = await neodeInstance.create('User', args)
|
|
||||||
|
|
||||||
let email
|
|
||||||
if (typeof args.email === 'object') {
|
|
||||||
// probably a neode node
|
|
||||||
email = args.email
|
|
||||||
} else {
|
|
||||||
email = await factoryInstance.create('EmailAddress', { email: args.email })
|
|
||||||
}
|
|
||||||
|
|
||||||
await user.relateTo(email, 'primaryEmail')
|
|
||||||
await email.relateTo(user, 'belongsTo')
|
|
||||||
return user
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,7 @@
|
|||||||
import Factory from '../factories/index'
|
import Factory, { cleanDatabase } from '../db/factories'
|
||||||
import { getDriver, getNeode } from '../db/neo4j'
|
import { getDriver, getNeode } from '../db/neo4j'
|
||||||
import decode from './decode'
|
import decode from './decode'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ export const validAuthorizationHeader =
|
|||||||
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoidXNlciIsImxvY2F0aW9uTmFtZSI6bnVsbCwibmFtZSI6Ikplbm55IFJvc3RvY2siLCJhYm91dCI6bnVsbCwiYXZhdGFyIjoiaHR0cHM6Ly9zMy5hbWF6b25hd3MuY29tL3VpZmFjZXMvZmFjZXMvdHdpdHRlci9zYXNoYV9zaGVzdGFrb3YvMTI4LmpwZyIsImlkIjoidTMiLCJlbWFpbCI6InVzZXJAZXhhbXBsZS5vcmciLCJzbHVnIjoiamVubnktcm9zdG9jayIsImlhdCI6MTU1MDg0NjY4MCwiZXhwIjoxNjM3MjQ2NjgwLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQwMDAiLCJzdWIiOiJ1MyJ9.eZ_mVKas4Wzoc_JrQTEWXyRn7eY64cdIg4vqQ-F_7Jc'
|
'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoidXNlciIsImxvY2F0aW9uTmFtZSI6bnVsbCwibmFtZSI6Ikplbm55IFJvc3RvY2siLCJhYm91dCI6bnVsbCwiYXZhdGFyIjoiaHR0cHM6Ly9zMy5hbWF6b25hd3MuY29tL3VpZmFjZXMvZmFjZXMvdHdpdHRlci9zYXNoYV9zaGVzdGFrb3YvMTI4LmpwZyIsImlkIjoidTMiLCJlbWFpbCI6InVzZXJAZXhhbXBsZS5vcmciLCJzbHVnIjoiamVubnktcm9zdG9jayIsImlhdCI6MTU1MDg0NjY4MCwiZXhwIjoxNjM3MjQ2NjgwLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjMwMDAiLCJpc3MiOiJodHRwOi8vbG9jYWxob3N0OjQwMDAiLCJzdWIiOiJ1MyJ9.eZ_mVKas4Wzoc_JrQTEWXyRn7eY64cdIg4vqQ-F_7Jc'
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('decode', () => {
|
describe('decode', () => {
|
||||||
@ -65,14 +64,19 @@ describe('decode', () => {
|
|||||||
describe('and corresponding user in the database', () => {
|
describe('and corresponding user in the database', () => {
|
||||||
let user
|
let user
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await factory.create('User', {
|
user = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
name: 'Jenny Rostock',
|
name: 'Jenny Rostock',
|
||||||
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/sasha_shestakov/128.jpg',
|
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/sasha_shestakov/128.jpg',
|
||||||
id: 'u3',
|
id: 'u3',
|
||||||
email: 'user@example.org',
|
|
||||||
slug: 'jenny-rostock',
|
slug: 'jenny-rostock',
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
email: 'user@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns user object except email', async () => {
|
it('returns user object except email', async () => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../factories'
|
import { cleanDatabase } from '../../db/factories'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
@ -9,7 +9,6 @@ let query
|
|||||||
let mutate
|
let mutate
|
||||||
let hashtagingUser
|
let hashtagingUser
|
||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
@ -48,13 +47,18 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
hashtagingUser = await neode.create('User', {
|
hashtagingUser = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'you',
|
id: 'you',
|
||||||
name: 'Al Capone',
|
name: 'Al Capone',
|
||||||
slug: 'al-capone',
|
slug: 'al-capone',
|
||||||
email: 'test@example.org',
|
},
|
||||||
|
{
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
email: 'test@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
await neode.create('Category', {
|
await neode.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
@ -63,7 +67,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('hashtags', () => {
|
describe('hashtags', () => {
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../factories'
|
import { cleanDatabase } from '../../db/factories'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let server, query, mutate, notifiedUser, authenticatedUser
|
let server, query, mutate, notifiedUser, authenticatedUser
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
@ -36,7 +35,7 @@ const createCommentMutation = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const createServerResult = createServer({
|
const createServerResult = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
@ -53,13 +52,18 @@ beforeAll(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
notifiedUser = await neode.create('User', {
|
notifiedUser = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'you',
|
id: 'you',
|
||||||
name: 'Al Capone',
|
name: 'Al Capone',
|
||||||
slug: 'al-capone',
|
slug: 'al-capone',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await neode.create('Category', {
|
await neode.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
@ -68,7 +72,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('notifications', () => {
|
describe('notifications', () => {
|
||||||
@ -143,13 +147,18 @@ describe('notifications', () => {
|
|||||||
describe('commenter is not me', () => {
|
describe('commenter is not me', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
commentContent = 'Commenters comment.'
|
commentContent = 'Commenters comment.'
|
||||||
commentAuthor = await neode.create('User', {
|
commentAuthor = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'commentauthor@example.org',
|
email: 'commentauthor@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sends me a notification', async () => {
|
it('sends me a notification', async () => {
|
||||||
@ -224,13 +233,18 @@ describe('notifications', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
postAuthor = await neode.create('User', {
|
postAuthor = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'postAuthor',
|
id: 'postAuthor',
|
||||||
name: 'Mrs Post',
|
name: 'Mrs Post',
|
||||||
slug: 'mrs-post',
|
slug: 'mrs-post',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'post-author@example.org',
|
email: 'post-author@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mentions me in a post', () => {
|
describe('mentions me in a post', () => {
|
||||||
@ -428,23 +442,33 @@ describe('notifications', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
commentContent =
|
commentContent =
|
||||||
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
||||||
commentAuthor = await neode.create('User', {
|
commentAuthor = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'comment-author@example.org',
|
email: 'comment-author@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sends only one notification with reason mentioned_in_comment', async () => {
|
it('sends only one notification with reason mentioned_in_comment', async () => {
|
||||||
postAuthor = await neode.create('User', {
|
postAuthor = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'MrPostAuthor',
|
id: 'MrPostAuthor',
|
||||||
name: 'Mr Author',
|
name: 'Mr Author',
|
||||||
slug: 'mr-author',
|
slug: 'mr-author',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'post-author@example.org',
|
email: 'post-author@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
await createCommentOnPostAction()
|
await createCommentOnPostAction()
|
||||||
const expected = expect.objectContaining({
|
const expected = expect.objectContaining({
|
||||||
@ -514,13 +538,18 @@ describe('notifications', () => {
|
|||||||
await postAuthor.relateTo(notifiedUser, 'blocked')
|
await postAuthor.relateTo(notifiedUser, 'blocked')
|
||||||
commentContent =
|
commentContent =
|
||||||
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
'One mention about me with <a data-mention-id="you" class="mention" href="/profile/you" target="_blank">@al-capone</a>.'
|
||||||
commentAuthor = await neode.create('User', {
|
commentAuthor = await neode.create(
|
||||||
|
'User',
|
||||||
|
{
|
||||||
id: 'commentAuthor',
|
id: 'commentAuthor',
|
||||||
name: 'Mrs Comment',
|
name: 'Mrs Comment',
|
||||||
slug: 'mrs-comment',
|
slug: 'mrs-comment',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'comment-author@example.org',
|
email: 'comment-author@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sends no notification', async () => {
|
it('sends no notification', async () => {
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import Factory from '../factories'
|
import { cleanDatabase } from '../db/factories'
|
||||||
import { getNeode, getDriver } from '../db/neo4j'
|
import { getNeode, getDriver } from '../db/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -27,7 +26,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Query', () => {
|
describe('Query', () => {
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
import Factory from '../factories'
|
import Factory, { cleanDatabase } from '../db/factories'
|
||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import { getDriver, getNeode } from '../db/neo4j'
|
import { getDriver, getNeode } from '../db/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ const userQuery = gql`
|
|||||||
|
|
||||||
describe('authorization', () => {
|
describe('authorization', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => ({
|
context: () => ({
|
||||||
driver,
|
driver,
|
||||||
@ -34,34 +33,54 @@ describe('authorization', () => {
|
|||||||
describe('given two existing users', () => {
|
describe('given two existing users', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
;[owner, anotherRegularUser, administrator, moderator] = await Promise.all([
|
;[owner, anotherRegularUser, administrator, moderator] = await Promise.all([
|
||||||
factory.create('User', {
|
Factory.build(
|
||||||
email: 'owner@example.org',
|
'user',
|
||||||
|
{
|
||||||
name: 'Owner',
|
name: 'Owner',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'owner@example.org',
|
||||||
password: 'iamtheowner',
|
password: 'iamtheowner',
|
||||||
}),
|
},
|
||||||
factory.create('User', {
|
),
|
||||||
email: 'another.regular.user@example.org',
|
Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
name: 'Another Regular User',
|
name: 'Another Regular User',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'another.regular.user@example.org',
|
||||||
password: 'else',
|
password: 'else',
|
||||||
}),
|
},
|
||||||
factory.create('User', {
|
),
|
||||||
email: 'admin@example.org',
|
Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
name: 'Admin',
|
name: 'Admin',
|
||||||
password: 'admin',
|
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
}),
|
},
|
||||||
factory.create('User', {
|
{
|
||||||
email: 'moderator@example.org',
|
email: 'admin@example.org',
|
||||||
|
password: 'admin',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
name: 'Moderator',
|
name: 'Moderator',
|
||||||
password: 'moderator',
|
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
email: 'moderator@example.org',
|
||||||
|
password: 'moderator',
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
variables = {}
|
variables = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('access email address', () => {
|
describe('access email address', () => {
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
import Factory from '../factories'
|
import Factory, { cleanDatabase } from '../db/factories'
|
||||||
import { gql } from '../helpers/jest'
|
import { gql } from '../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../db/neo4j'
|
import { getNeode, getDriver } from '../db/neo4j'
|
||||||
import createServer from '../server'
|
import createServer from '../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
|
|
||||||
let mutate
|
let mutate
|
||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
let variables
|
let variables
|
||||||
@ -28,14 +26,18 @@ beforeAll(() => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = {}
|
variables = {}
|
||||||
const admin = await factory.create('User', {
|
const admin = await Factory.build('user', {
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
})
|
})
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
|
'user',
|
||||||
|
{},
|
||||||
|
{
|
||||||
email: 'someone@example.org',
|
email: 'someone@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
await factory.create('Category', {
|
)
|
||||||
|
await Factory.build('category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
icon: 'university',
|
icon: 'university',
|
||||||
@ -44,7 +46,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('slugifyMiddleware', () => {
|
describe('slugifyMiddleware', () => {
|
||||||
@ -84,12 +86,17 @@ describe('slugifyMiddleware', () => {
|
|||||||
|
|
||||||
describe('if slug exists', () => {
|
describe('if slug exists', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
title: 'Pre-existing post',
|
title: 'Pre-existing post',
|
||||||
slug: 'pre-existing-post',
|
slug: 'pre-existing-post',
|
||||||
content: 'as Someone else content',
|
content: 'as Someone else content',
|
||||||
|
},
|
||||||
|
{
|
||||||
categoryIds,
|
categoryIds,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('chooses another slug', async () => {
|
it('chooses another slug', async () => {
|
||||||
@ -190,7 +197,7 @@ describe('slugifyMiddleware', () => {
|
|||||||
|
|
||||||
describe('given a user has signed up with their email address', () => {
|
describe('given a user has signed up with their email address', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('EmailAddress', {
|
await Factory.build('emailAddress', {
|
||||||
email: '123@example.org',
|
email: '123@example.org',
|
||||||
nonce: '123456',
|
nonce: '123456',
|
||||||
verifiedAt: null,
|
verifiedAt: null,
|
||||||
@ -214,7 +221,7 @@ describe('slugifyMiddleware', () => {
|
|||||||
|
|
||||||
describe('if slug exists', () => {
|
describe('if slug exists', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', {
|
await Factory.build('user', {
|
||||||
name: 'I am a user',
|
name: 'I am a user',
|
||||||
slug: 'i-am-a-user',
|
slug: 'i-am-a-user',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -18,13 +17,18 @@ const action = () => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// For performance reasons we do this only once
|
// For performance reasons we do this only once
|
||||||
const users = await Promise.all([
|
const users = await Promise.all([
|
||||||
factory.create('User', { id: 'u1', role: 'user' }),
|
Factory.build('user', { id: 'u1', role: 'user' }),
|
||||||
factory.create('User', {
|
Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'm1',
|
id: 'm1',
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
|
},
|
||||||
|
{
|
||||||
password: '1234',
|
password: '1234',
|
||||||
}),
|
},
|
||||||
factory.create('User', {
|
),
|
||||||
|
Factory.build('user', {
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
name: 'Offensive Name',
|
name: 'Offensive Name',
|
||||||
@ -45,48 +49,73 @@ beforeAll(async () => {
|
|||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
user.relateTo(troll, 'following'),
|
user.relateTo(troll, 'following'),
|
||||||
factory.create('Post', {
|
Factory.build(
|
||||||
author: user,
|
'post',
|
||||||
|
{
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
title: 'Deleted post',
|
title: 'Deleted post',
|
||||||
slug: 'deleted-post',
|
slug: 'deleted-post',
|
||||||
deleted: true,
|
deleted: true,
|
||||||
categoryIds,
|
},
|
||||||
}),
|
{
|
||||||
factory.create('Post', {
|
|
||||||
author: user,
|
author: user,
|
||||||
|
categoryIds,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'p3',
|
id: 'p3',
|
||||||
title: 'Publicly visible post',
|
title: 'Publicly visible post',
|
||||||
slug: 'publicly-visible-post',
|
slug: 'publicly-visible-post',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
author: user,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
|
|
||||||
const resources = await Promise.all([
|
const resources = await Promise.all([
|
||||||
factory.create('Comment', {
|
Factory.build(
|
||||||
author: user,
|
'comment',
|
||||||
|
{
|
||||||
id: 'c2',
|
id: 'c2',
|
||||||
postId: 'p3',
|
|
||||||
content: 'Enabled comment on public post',
|
content: 'Enabled comment on public post',
|
||||||
}),
|
},
|
||||||
factory.create('Post', {
|
{
|
||||||
|
author: user,
|
||||||
|
postId: 'p3',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
author: troll,
|
|
||||||
title: 'Disabled post',
|
title: 'Disabled post',
|
||||||
content: 'This is an offensive post content',
|
content: 'This is an offensive post content',
|
||||||
contentExcerpt: 'This is an offensive post content',
|
contentExcerpt: 'This is an offensive post content',
|
||||||
image: '/some/offensive/image.jpg',
|
image: '/some/offensive/image.jpg',
|
||||||
deleted: false,
|
deleted: false,
|
||||||
categoryIds,
|
},
|
||||||
}),
|
{
|
||||||
factory.create('Comment', {
|
|
||||||
id: 'c1',
|
|
||||||
author: troll,
|
author: troll,
|
||||||
postId: 'p3',
|
categoryIds,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
|
id: 'c1',
|
||||||
content: 'Disabled comment',
|
content: 'Disabled comment',
|
||||||
contentExcerpt: 'Disabled comment',
|
contentExcerpt: 'Disabled comment',
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
author: troll,
|
||||||
|
postId: 'p3',
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
|
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
@ -105,9 +134,9 @@ beforeAll(async () => {
|
|||||||
const trollingComment = resources[2]
|
const trollingComment = resources[2]
|
||||||
|
|
||||||
const reports = await Promise.all([
|
const reports = await Promise.all([
|
||||||
factory.create('Report'),
|
Factory.build('report'),
|
||||||
factory.create('Report'),
|
Factory.build('report'),
|
||||||
factory.create('Report'),
|
Factory.build('report'),
|
||||||
])
|
])
|
||||||
const reportAgainstTroll = reports[0]
|
const reportAgainstTroll = reports[0]
|
||||||
const reportAgainstTrollingPost = reports[1]
|
const reportAgainstTrollingPost = reports[1]
|
||||||
@ -154,7 +183,7 @@ beforeAll(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('softDeleteMiddleware', () => {
|
describe('softDeleteMiddleware', () => {
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
let authenticatedUser,
|
let authenticatedUser,
|
||||||
@ -94,14 +93,14 @@ beforeAll(() => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
users = await Promise.all([
|
users = await Promise.all([
|
||||||
factory.create('User', {
|
Factory.build('user', {
|
||||||
id: 'reporting-user',
|
id: 'reporting-user',
|
||||||
}),
|
}),
|
||||||
factory.create('User', {
|
Factory.build('user', {
|
||||||
id: 'moderating-user',
|
id: 'moderating-user',
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
}),
|
}),
|
||||||
factory.create('User', {
|
Factory.build('user', {
|
||||||
id: 'commenting-user',
|
id: 'commenting-user',
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@ -119,20 +118,30 @@ beforeEach(async () => {
|
|||||||
moderatingUser = users[1]
|
moderatingUser = users[1]
|
||||||
commentingUser = users[2]
|
commentingUser = users[2]
|
||||||
const posts = await Promise.all([
|
const posts = await Promise.all([
|
||||||
factory.create('Post', {
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'offensive-post',
|
id: 'offensive-post',
|
||||||
|
},
|
||||||
|
{
|
||||||
authorId: 'moderating-user',
|
authorId: 'moderating-user',
|
||||||
}),
|
},
|
||||||
factory.create('Post', {
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'post-4-commenting',
|
id: 'post-4-commenting',
|
||||||
|
},
|
||||||
|
{
|
||||||
authorId: 'commenting-user',
|
authorId: 'commenting-user',
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
offensivePost = posts[0]
|
offensivePost = posts[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('validateCreateComment', () => {
|
describe('validateCreateComment', () => {
|
||||||
@ -182,10 +191,15 @@ describe('validateCreateComment', () => {
|
|||||||
describe('validateUpdateComment', () => {
|
describe('validateUpdateComment', () => {
|
||||||
let updateCommentVariables
|
let updateCommentVariables
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Comment', {
|
await Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'comment-id',
|
id: 'comment-id',
|
||||||
|
},
|
||||||
|
{
|
||||||
authorId: 'commenting-user',
|
authorId: 'commenting-user',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
updateCommentVariables = {
|
updateCommentVariables = {
|
||||||
id: 'whatever',
|
id: 'whatever',
|
||||||
content: '',
|
content: '',
|
||||||
@ -328,7 +342,7 @@ describe('validateReport', () => {
|
|||||||
|
|
||||||
describe('validateReview', () => {
|
describe('validateReview', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const reportAgainstModerator = await factory.create('Report')
|
const reportAgainstModerator = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstModerator.relateTo(reportingUser, 'filed', {
|
reportAgainstModerator.relateTo(reportingUser, 'filed', {
|
||||||
...reportVariables,
|
...reportVariables,
|
||||||
@ -370,7 +384,7 @@ describe('validateReview', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws an error if a moderator tries to review their own resource(Post|Comment)', async () => {
|
it('throws an error if a moderator tries to review their own resource(Post|Comment)', async () => {
|
||||||
const reportAgainstOffensivePost = await factory.create('Report')
|
const reportAgainstOffensivePost = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstOffensivePost.relateTo(reportingUser, 'filed', {
|
reportAgainstOffensivePost.relateTo(reportingUser, 'filed', {
|
||||||
...reportVariables,
|
...reportVariables,
|
||||||
@ -389,7 +403,7 @@ describe('validateReview', () => {
|
|||||||
|
|
||||||
describe('moderate a resource that is not a (Comment|Post|User) ', () => {
|
describe('moderate a resource that is not a (Comment|Post|User) ', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await Promise.all([factory.create('Tag', { id: 'tag-id' })])
|
await Promise.all([Factory.build('tag', { id: 'tag-id' })])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns null', async () => {
|
it('returns null', async () => {
|
||||||
@ -419,7 +433,7 @@ describe('validateReview', () => {
|
|||||||
id: 'updating-user',
|
id: 'updating-user',
|
||||||
name: 'John Doughnut',
|
name: 'John Doughnut',
|
||||||
}
|
}
|
||||||
updatingUser = await factory.create('User', userParams)
|
updatingUser = await Factory.build('user', userParams)
|
||||||
authenticatedUser = await updatingUser.toJson()
|
authenticatedUser = await updatingUser.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -52,5 +52,4 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
pinned: { type: 'boolean', default: null, valid: [null, true] },
|
pinned: { type: 'boolean', default: null, valid: [null, true] },
|
||||||
pinnedAt: { type: 'string', isoDate: true },
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import Factory from '../factories'
|
import { cleanDatabase } from '../db/factories'
|
||||||
import { getNeode } from '../db/neo4j'
|
import { getNeode } from '../db/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('role', () => {
|
describe('role', () => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
@ -6,12 +6,11 @@ import { getNeode, getDriver } from '../../db/neo4j'
|
|||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const factory = Factory()
|
|
||||||
|
|
||||||
let variables, mutate, authenticatedUser, commentAuthor, newlyCreatedComment
|
let variables, mutate, authenticatedUser, commentAuthor, newlyCreatedComment
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
@ -33,7 +32,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
const createCommentMutation = gql`
|
const createCommentMutation = gql`
|
||||||
@ -48,18 +47,28 @@ const createCommentMutation = gql`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
const setupPostAndComment = async () => {
|
const setupPostAndComment = async () => {
|
||||||
commentAuthor = await factory.create('User')
|
commentAuthor = await Factory.build('user')
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
content: 'Post to be commented',
|
content: 'Post to be commented',
|
||||||
|
},
|
||||||
|
{
|
||||||
categoryIds: ['cat9'],
|
categoryIds: ['cat9'],
|
||||||
})
|
},
|
||||||
newlyCreatedComment = await factory.create('Comment', {
|
)
|
||||||
|
newlyCreatedComment = await Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'c456',
|
id: 'c456',
|
||||||
|
content: 'Comment to be deleted',
|
||||||
|
},
|
||||||
|
{
|
||||||
postId: 'p1',
|
postId: 'p1',
|
||||||
author: commentAuthor,
|
author: commentAuthor,
|
||||||
content: 'Comment to be deleted',
|
},
|
||||||
})
|
)
|
||||||
variables = {
|
variables = {
|
||||||
...variables,
|
...variables,
|
||||||
id: 'c456',
|
id: 'c456',
|
||||||
@ -88,7 +97,7 @@ describe('CreateComment', () => {
|
|||||||
|
|
||||||
describe('given a post', () => {
|
describe('given a post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', { categoryIds: ['cat9'], id: 'p1' })
|
await Factory.build('post', { id: 'p1' }, { categoryIds: ['cat9'] })
|
||||||
variables = {
|
variables = {
|
||||||
...variables,
|
...variables,
|
||||||
postId: 'p1',
|
postId: 'p1',
|
||||||
@ -141,7 +150,7 @@ describe('UpdateComment', () => {
|
|||||||
|
|
||||||
describe('authenticated but not the author', () => {
|
describe('authenticated but not the author', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const randomGuy = await factory.create('User')
|
const randomGuy = await Factory.build('user')
|
||||||
authenticatedUser = await randomGuy.toJson()
|
authenticatedUser = await randomGuy.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -233,7 +242,7 @@ describe('DeleteComment', () => {
|
|||||||
|
|
||||||
describe('authenticated but not the author', () => {
|
describe('authenticated but not the author', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const randomGuy = await factory.create('User')
|
const randomGuy = await Factory.build('user')
|
||||||
authenticatedUser = await randomGuy.toJson()
|
authenticatedUser = await randomGuy.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let mutate, query, authenticatedUser, variables
|
let mutate, query, authenticatedUser, variables
|
||||||
const factory = Factory()
|
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ const donationsQuery = gql`
|
|||||||
describe('donations', () => {
|
describe('donations', () => {
|
||||||
let currentUser, newlyCreatedDonations
|
let currentUser, newlyCreatedDonations
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
authenticatedUser = undefined
|
authenticatedUser = undefined
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
@ -50,11 +49,11 @@ describe('donations', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = {}
|
variables = {}
|
||||||
newlyCreatedDonations = await factory.create('Donations')
|
newlyCreatedDonations = await Factory.build('donations')
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('query for donations', () => {
|
describe('query for donations', () => {
|
||||||
@ -68,7 +67,7 @@ describe('donations', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build('user', {
|
||||||
id: 'normal-user',
|
id: 'normal-user',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
})
|
})
|
||||||
@ -102,7 +101,7 @@ describe('donations', () => {
|
|||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
describe('as a normal user', () => {
|
describe('as a normal user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build('user', {
|
||||||
id: 'normal-user',
|
id: 'normal-user',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
})
|
})
|
||||||
@ -121,7 +120,7 @@ describe('donations', () => {
|
|||||||
|
|
||||||
describe('as a moderator', () => {
|
describe('as a moderator', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build('user', {
|
||||||
id: 'moderator',
|
id: 'moderator',
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
})
|
})
|
||||||
@ -140,7 +139,7 @@ describe('donations', () => {
|
|||||||
|
|
||||||
describe('as an admin', () => {
|
describe('as an admin', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build('user', {
|
||||||
id: 'admin',
|
id: 'admin',
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, getNeode } from '../../db/neo4j'
|
import { getDriver, getNeode } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
let mutate
|
let mutate
|
||||||
@ -31,7 +30,7 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('AddEmailAddress', () => {
|
describe('AddEmailAddress', () => {
|
||||||
@ -63,7 +62,7 @@ describe('AddEmailAddress', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await factory.create('User', { id: '567', email: 'user@example.org' })
|
user = await Factory.build('user', { id: '567' }, { email: 'user@example.org' })
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -110,7 +109,7 @@ describe('AddEmailAddress', () => {
|
|||||||
|
|
||||||
describe('if another `UnverifiedEmailAddress` node already exists with that email', () => {
|
describe('if another `UnverifiedEmailAddress` node already exists with that email', () => {
|
||||||
it('throws no unique constraint violation error', async () => {
|
it('throws no unique constraint violation error', async () => {
|
||||||
await factory.create('UnverifiedEmailAddress', {
|
await Factory.build('unverifiedEmailAddress', {
|
||||||
createdAt: '2019-09-24T14:00:01.565Z',
|
createdAt: '2019-09-24T14:00:01.565Z',
|
||||||
email: 'new-email@example.org',
|
email: 'new-email@example.org',
|
||||||
})
|
})
|
||||||
@ -128,7 +127,7 @@ describe('AddEmailAddress', () => {
|
|||||||
|
|
||||||
describe('but if another user owns an `EmailAddress` already with that email', () => {
|
describe('but if another user owns an `EmailAddress` already with that email', () => {
|
||||||
it('throws UserInputError because of unique constraints', async () => {
|
it('throws UserInputError because of unique constraints', async () => {
|
||||||
await factory.create('User', { email: 'new-email@example.org' })
|
await Factory.build('user', {}, { email: 'new-email@example.org' })
|
||||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||||
data: { AddEmailAddress: null },
|
data: { AddEmailAddress: null },
|
||||||
errors: [{ message: 'A user account with this email already exists.' }],
|
errors: [{ message: 'A user account with this email already exists.' }],
|
||||||
@ -169,7 +168,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await factory.create('User', { id: '567', email: 'user@example.org' })
|
user = await Factory.build('user', { id: '567' }, { email: 'user@example.org' })
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -185,7 +184,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
describe('given a `UnverifiedEmailAddress`', () => {
|
describe('given a `UnverifiedEmailAddress`', () => {
|
||||||
let emailAddress
|
let emailAddress
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
emailAddress = await factory.create('UnverifiedEmailAddress', {
|
emailAddress = await Factory.build('unverifiedEmailAddress', {
|
||||||
nonce: 'abcdef',
|
nonce: 'abcdef',
|
||||||
verifiedAt: null,
|
verifiedAt: null,
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
@ -281,7 +280,7 @@ describe('VerifyEmailAddress', () => {
|
|||||||
|
|
||||||
describe('Edge case: In the meantime someone created an `EmailAddress` node with the given email', () => {
|
describe('Edge case: In the meantime someone created an `EmailAddress` node with the given email', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('EmailAddress', { email: 'to-be-verified@example.org' })
|
await Factory.build('emailAddress', { email: 'to-be-verified@example.org' })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws UserInputError because of unique constraints', async () => {
|
it('throws UserInputError because of unique constraints', async () => {
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { getDriver, getNeode } from '../../db/neo4j'
|
import { getDriver, getNeode } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ const userQuery = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => ({
|
context: () => ({
|
||||||
driver,
|
driver,
|
||||||
@ -72,29 +71,35 @@ beforeAll(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user1 = await factory
|
user1 = await Factory.build(
|
||||||
.create('User', {
|
'user',
|
||||||
|
{
|
||||||
id: 'u1',
|
id: 'u1',
|
||||||
name: 'user1',
|
name: 'user1',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
.then(user => user.toJson())
|
).then(user => user.toJson())
|
||||||
user2 = await factory
|
user2 = await Factory.build(
|
||||||
.create('User', {
|
'user',
|
||||||
|
{
|
||||||
id: 'u2',
|
id: 'u2',
|
||||||
name: 'user2',
|
name: 'user2',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'test2@example.org',
|
email: 'test2@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
.then(user => user.toJson())
|
).then(user => user.toJson())
|
||||||
|
|
||||||
authenticatedUser = user1
|
authenticatedUser = user1
|
||||||
variables = { id: user2.id }
|
variables = { id: user2.id }
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('follow', () => {
|
describe('follow', () => {
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
|
|
||||||
let mutate, authenticatedUser
|
let mutate, authenticatedUser
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
@ -25,7 +23,7 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('resolvers', () => {
|
describe('resolvers', () => {
|
||||||
@ -49,7 +47,7 @@ describe('resolvers', () => {
|
|||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doughnut',
|
name: 'John Doughnut',
|
||||||
}
|
}
|
||||||
const Paris = await factory.create('Location', {
|
const Paris = await Factory.build('location', {
|
||||||
id: 'region.9397217726497330',
|
id: 'region.9397217726497330',
|
||||||
name: 'Paris',
|
name: 'Paris',
|
||||||
type: 'region',
|
type: 'region',
|
||||||
@ -58,7 +56,7 @@ describe('resolvers', () => {
|
|||||||
nameEN: 'Paris',
|
nameEN: 'Paris',
|
||||||
})
|
})
|
||||||
|
|
||||||
const user = await factory.create('User', {
|
const user = await Factory.build('user', {
|
||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ const reviewMutation = gql`
|
|||||||
|
|
||||||
describe('moderate resources', () => {
|
describe('moderate resources', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
authenticatedUser = undefined
|
authenticatedUser = undefined
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
@ -80,23 +79,33 @@ describe('moderate resources', () => {
|
|||||||
closed: false,
|
closed: false,
|
||||||
}
|
}
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
moderator = await factory.create('User', {
|
moderator = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'moderator-id',
|
id: 'moderator-id',
|
||||||
name: 'Moderator',
|
name: 'Moderator',
|
||||||
|
role: 'moderator',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'moderator@example.org',
|
email: 'moderator@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
role: 'moderator',
|
},
|
||||||
})
|
)
|
||||||
nonModerator = await factory.create('User', {
|
nonModerator = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'non-moderator',
|
id: 'non-moderator',
|
||||||
name: 'Non Moderator',
|
name: 'Non Moderator',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'non.moderator@example.org',
|
email: 'non.moderator@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('review to close report, leaving resource enabled', () => {
|
describe('review to close report, leaving resource enabled', () => {
|
||||||
@ -127,10 +136,10 @@ describe('moderate resources', () => {
|
|||||||
describe('moderator', () => {
|
describe('moderator', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await moderator.toJson()
|
authenticatedUser = await moderator.toJson()
|
||||||
const questionablePost = await factory.create('Post', {
|
const questionablePost = await Factory.build('post', {
|
||||||
id: 'should-i-be-disabled',
|
id: 'should-i-be-disabled',
|
||||||
})
|
})
|
||||||
const reportAgainstQuestionablePost = await factory.create('Report')
|
const reportAgainstQuestionablePost = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstQuestionablePost.relateTo(nonModerator, 'filed', {
|
reportAgainstQuestionablePost.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'should-i-be-disabled',
|
resourceId: 'should-i-be-disabled',
|
||||||
@ -229,10 +238,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a comment', () => {
|
describe('moderate a comment', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const trollingComment = await factory.create('Comment', {
|
const trollingComment = await Factory.build('comment', {
|
||||||
id: 'comment-id',
|
id: 'comment-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTrollingComment = await factory.create('Report')
|
const reportAgainstTrollingComment = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTrollingComment.relateTo(nonModerator, 'filed', {
|
reportAgainstTrollingComment.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'comment-id',
|
resourceId: 'comment-id',
|
||||||
@ -307,10 +316,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a post', () => {
|
describe('moderate a post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const trollingPost = await factory.create('Post', {
|
const trollingPost = await Factory.build('post', {
|
||||||
id: 'post-id',
|
id: 'post-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTrollingPost = await factory.create('Report')
|
const reportAgainstTrollingPost = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTrollingPost.relateTo(nonModerator, 'filed', {
|
reportAgainstTrollingPost.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'post-id',
|
resourceId: 'post-id',
|
||||||
@ -387,10 +396,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a user', () => {
|
describe('moderate a user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const troll = await factory.create('User', {
|
const troll = await Factory.build('user', {
|
||||||
id: 'user-id',
|
id: 'user-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTroll = await factory.create('Report')
|
const reportAgainstTroll = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTroll.relateTo(nonModerator, 'filed', {
|
reportAgainstTroll.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'user-id',
|
resourceId: 'user-id',
|
||||||
@ -504,10 +513,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a comment', () => {
|
describe('moderate a comment', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const trollingComment = await factory.create('Comment', {
|
const trollingComment = await Factory.build('comment', {
|
||||||
id: 'comment-id',
|
id: 'comment-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTrollingComment = await factory.create('Report')
|
const reportAgainstTrollingComment = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTrollingComment.relateTo(nonModerator, 'filed', {
|
reportAgainstTrollingComment.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'comment-id',
|
resourceId: 'comment-id',
|
||||||
@ -568,10 +577,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a post', () => {
|
describe('moderate a post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const trollingPost = await factory.create('Post', {
|
const trollingPost = await Factory.build('post', {
|
||||||
id: 'post-id',
|
id: 'post-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTrollingPost = await factory.create('Report')
|
const reportAgainstTrollingPost = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTrollingPost.relateTo(nonModerator, 'filed', {
|
reportAgainstTrollingPost.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'post-id',
|
resourceId: 'post-id',
|
||||||
@ -633,10 +642,10 @@ describe('moderate resources', () => {
|
|||||||
|
|
||||||
describe('moderate a user', () => {
|
describe('moderate a user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const troll = await factory.create('User', {
|
const troll = await Factory.build('user', {
|
||||||
id: 'user-id',
|
id: 'user-id',
|
||||||
})
|
})
|
||||||
const reportAgainstTroll = await factory.create('Report')
|
const reportAgainstTroll = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstTroll.relateTo(nonModerator, 'filed', {
|
reportAgainstTroll.relateTo(nonModerator, 'filed', {
|
||||||
resourceId: 'user-id',
|
resourceId: 'user-id',
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver } from '../../db/neo4j'
|
import { getDriver } from '../../db/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../.././server'
|
import createServer from '../.././server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
let user
|
let user
|
||||||
@ -32,52 +31,77 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('given some notifications', () => {
|
describe('given some notifications', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const categoryIds = ['cat1']
|
const categoryIds = ['cat1']
|
||||||
author = await factory.create('User', { id: 'author' })
|
author = await Factory.build('user', { id: 'author' })
|
||||||
user = await factory.create('User', { id: 'you' })
|
user = await Factory.build('user', { id: 'you' })
|
||||||
const [neighbor] = await Promise.all([
|
const [neighbor] = await Promise.all([
|
||||||
factory.create('User', { id: 'neighbor' }),
|
Factory.build('user', { id: 'neighbor' }),
|
||||||
factory.create('Category', { id: 'cat1' }),
|
Factory.build('category', { id: 'cat1' }),
|
||||||
])
|
])
|
||||||
const [post1, post2, post3] = await Promise.all([
|
const [post1, post2, post3] = await Promise.all([
|
||||||
factory.create('Post', { author, id: 'p1', categoryIds, content: 'Not for you' }),
|
Factory.build('post', { id: 'p1', content: 'Not for you' }, { author, categoryIds }),
|
||||||
factory.create('Post', {
|
Factory.build(
|
||||||
author,
|
'post',
|
||||||
|
{
|
||||||
id: 'p2',
|
id: 'p2',
|
||||||
categoryIds,
|
|
||||||
content: 'Already seen post mention',
|
content: 'Already seen post mention',
|
||||||
}),
|
},
|
||||||
factory.create('Post', {
|
{
|
||||||
author,
|
author,
|
||||||
id: 'p3',
|
|
||||||
categoryIds,
|
categoryIds,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
|
id: 'p3',
|
||||||
content: 'You have been mentioned in a post',
|
content: 'You have been mentioned in a post',
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
author,
|
||||||
|
categoryIds,
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
const [comment1, comment2, comment3] = await Promise.all([
|
const [comment1, comment2, comment3] = await Promise.all([
|
||||||
factory.create('Comment', {
|
Factory.build(
|
||||||
author,
|
'comment',
|
||||||
postId: 'p3',
|
{
|
||||||
id: 'c1',
|
id: 'c1',
|
||||||
content: 'You have seen this comment mentioning already',
|
content: 'You have seen this comment mentioning already',
|
||||||
}),
|
},
|
||||||
factory.create('Comment', {
|
{
|
||||||
author,
|
author,
|
||||||
postId: 'p3',
|
postId: 'p3',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'c2',
|
id: 'c2',
|
||||||
content: 'You have been mentioned in a comment',
|
content: 'You have been mentioned in a comment',
|
||||||
}),
|
},
|
||||||
factory.create('Comment', {
|
{
|
||||||
author,
|
author,
|
||||||
postId: 'p3',
|
postId: 'p3',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'c3',
|
id: 'c3',
|
||||||
content: 'Somebody else was mentioned in a comment',
|
content: 'Somebody else was mentioned in a comment',
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
author,
|
||||||
|
postId: 'p3',
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
post1.relateTo(neighbor, 'notified', {
|
post1.relateTo(neighbor, 'notified', {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createPasswordReset from './helpers/createPasswordReset'
|
import createPasswordReset from './helpers/createPasswordReset'
|
||||||
@ -7,7 +7,6 @@ import { createTestClient } from 'apollo-server-testing'
|
|||||||
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
|
||||||
|
|
||||||
let mutate
|
let mutate
|
||||||
let authenticatedUser
|
let authenticatedUser
|
||||||
@ -39,15 +38,19 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('passwordReset', () => {
|
describe('passwordReset', () => {
|
||||||
describe('given a user', () => {
|
describe('given a user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
|
'user',
|
||||||
|
{},
|
||||||
|
{
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('requestPasswordReset', () => {
|
describe('requestPasswordReset', () => {
|
||||||
@ -123,11 +126,16 @@ describe('resetPassword', () => {
|
|||||||
|
|
||||||
describe('given a user', () => {
|
describe('given a user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
email: 'user@example.org',
|
'user',
|
||||||
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('invalid email', () => {
|
describe('invalid email', () => {
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
let query
|
let query
|
||||||
@ -40,7 +39,7 @@ const createPostMutation = gql`
|
|||||||
`
|
`
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
@ -56,12 +55,17 @@ beforeAll(async () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = {}
|
variables = {}
|
||||||
user = await factory.create('User', {
|
user = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'current-user',
|
id: 'current-user',
|
||||||
name: 'TestUser',
|
name: 'TestUser',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
neode.create('Category', {
|
neode.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
@ -88,7 +92,7 @@ beforeEach(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Post', () => {
|
describe('Post', () => {
|
||||||
@ -96,21 +100,31 @@ describe('Post', () => {
|
|||||||
let followedUser, happyPost, cryPost
|
let followedUser, happyPost, cryPost
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
;[followedUser] = await Promise.all([
|
;[followedUser] = await Promise.all([
|
||||||
factory.create('User', {
|
Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'followed-by-me',
|
id: 'followed-by-me',
|
||||||
email: 'followed@example.org',
|
|
||||||
name: 'Followed User',
|
name: 'Followed User',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'followed@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
;[happyPost, cryPost] = await Promise.all([
|
;[happyPost, cryPost] = await Promise.all([
|
||||||
factory.create('Post', { id: 'happy-post', categoryIds: ['cat4'] }),
|
Factory.build('post', { id: 'happy-post' }, { categoryIds: ['cat4'] }),
|
||||||
factory.create('Post', { id: 'cry-post', categoryIds: ['cat15'] }),
|
Factory.build('post', { id: 'cry-post' }, { categoryIds: ['cat15'] }),
|
||||||
factory.create('Post', {
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'post-by-followed-user',
|
id: 'post-by-followed-user',
|
||||||
|
},
|
||||||
|
{
|
||||||
categoryIds: ['cat9'],
|
categoryIds: ['cat9'],
|
||||||
author: followedUser,
|
author: followedUser,
|
||||||
}),
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -340,14 +354,19 @@ describe('UpdatePost', () => {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
author = await factory.create('User', { slug: 'the-author' })
|
author = await Factory.build('user', { slug: 'the-author' })
|
||||||
newlyCreatedPost = await factory.create('Post', {
|
newlyCreatedPost = await Factory.build(
|
||||||
author,
|
'post',
|
||||||
|
{
|
||||||
id: 'p9876',
|
id: 'p9876',
|
||||||
title: 'Old title',
|
title: 'Old title',
|
||||||
content: 'Old content',
|
content: 'Old content',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
author,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
id: 'p9876',
|
id: 'p9876',
|
||||||
@ -529,10 +548,15 @@ describe('UpdatePost', () => {
|
|||||||
|
|
||||||
describe('are allowed to pin posts', () => {
|
describe('are allowed to pin posts', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'created-and-pinned-by-same-admin',
|
id: 'created-and-pinned-by-same-admin',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: admin,
|
author: admin,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
variables = { ...variables, id: 'created-and-pinned-by-same-admin' }
|
variables = { ...variables, id: 'created-and-pinned-by-same-admin' }
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -589,15 +613,20 @@ describe('UpdatePost', () => {
|
|||||||
describe('post created by another admin', () => {
|
describe('post created by another admin', () => {
|
||||||
let otherAdmin
|
let otherAdmin
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
otherAdmin = await factory.create('User', {
|
otherAdmin = await Factory.build('user', {
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
name: 'otherAdmin',
|
name: 'otherAdmin',
|
||||||
})
|
})
|
||||||
authenticatedUser = await otherAdmin.toJson()
|
authenticatedUser = await otherAdmin.toJson()
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'created-by-one-admin-pinned-by-different-one',
|
id: 'created-by-one-admin-pinned-by-different-one',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: otherAdmin,
|
author: otherAdmin,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('responds with the updated Post', async () => {
|
it('responds with the updated Post', async () => {
|
||||||
@ -654,10 +683,15 @@ describe('UpdatePost', () => {
|
|||||||
describe('pinned post already exists', () => {
|
describe('pinned post already exists', () => {
|
||||||
let pinnedPost
|
let pinnedPost
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'only-pinned-post',
|
id: 'only-pinned-post',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: admin,
|
author: admin,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await mutate({ mutation: pinPostMutation, variables })
|
await mutate({ mutation: pinPostMutation, variables })
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -683,12 +717,12 @@ describe('UpdatePost', () => {
|
|||||||
|
|
||||||
describe('PostOrdering', () => {
|
describe('PostOrdering', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', {
|
await Factory.build('post', {
|
||||||
id: 'im-a-pinned-post',
|
id: 'im-a-pinned-post',
|
||||||
createdAt: '2019-11-22T17:26:29.070Z',
|
createdAt: '2019-11-22T17:26:29.070Z',
|
||||||
pinned: true,
|
pinned: true,
|
||||||
})
|
})
|
||||||
await factory.create('Post', {
|
await Factory.build('post', {
|
||||||
id: 'i-was-created-before-pinned-post',
|
id: 'i-was-created-before-pinned-post',
|
||||||
// fairly old, so this should be 3rd
|
// fairly old, so this should be 3rd
|
||||||
createdAt: '2019-10-22T17:26:29.070Z',
|
createdAt: '2019-10-22T17:26:29.070Z',
|
||||||
@ -807,7 +841,7 @@ describe('UpdatePost', () => {
|
|||||||
describe('admin can unpin posts', () => {
|
describe('admin can unpin posts', () => {
|
||||||
let admin, pinnedPost
|
let admin, pinnedPost
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
pinnedPost = await factory.create('Post', { id: 'post-to-be-unpinned' })
|
pinnedPost = await Factory.build('post', { id: 'post-to-be-unpinned' })
|
||||||
admin = await user.update({
|
admin = await user.update({
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
name: 'Admin',
|
name: 'Admin',
|
||||||
@ -874,15 +908,20 @@ describe('DeletePost', () => {
|
|||||||
`
|
`
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
author = await factory.create('User')
|
author = await Factory.build('user')
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'p4711',
|
id: 'p4711',
|
||||||
author,
|
|
||||||
title: 'I will be deleted',
|
title: 'I will be deleted',
|
||||||
content: 'To be deleted',
|
content: 'To be deleted',
|
||||||
image: 'path/to/some/image',
|
image: 'path/to/some/image',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
author,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
variables = { ...variables, id: 'p4711' }
|
variables = { ...variables, id: 'p4711' }
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -929,11 +968,16 @@ describe('DeletePost', () => {
|
|||||||
|
|
||||||
describe('if there are comments on the post', () => {
|
describe('if there are comments on the post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Comment', {
|
await Factory.build(
|
||||||
postId: 'p4711',
|
'comment',
|
||||||
|
{
|
||||||
content: 'to be deleted comment content',
|
content: 'to be deleted comment content',
|
||||||
contentExcerpt: 'to be deleted comment content',
|
contentExcerpt: 'to be deleted comment content',
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
postId: 'p4711',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('marks the comments as deleted', async () => {
|
it('marks the comments as deleted', async () => {
|
||||||
@ -988,11 +1032,16 @@ describe('emotions', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
author = await neode.create('User', { id: 'u257' })
|
author = await neode.create('User', { id: 'u257' })
|
||||||
postToEmote = await factory.create('Post', {
|
postToEmote = await Factory.build(
|
||||||
author,
|
'post',
|
||||||
|
{
|
||||||
id: 'p1376',
|
id: 'p1376',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
author,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
...variables,
|
...variables,
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, getNeode } from '../../db/neo4j'
|
import { getDriver, getNeode } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
let mutate
|
let mutate
|
||||||
@ -30,7 +29,7 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Signup', () => {
|
describe('Signup', () => {
|
||||||
@ -58,11 +57,16 @@ describe('Signup', () => {
|
|||||||
|
|
||||||
describe('as admin', () => {
|
describe('as admin', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const admin = await factory.create('User', {
|
const admin = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
authenticatedUser = await admin.toJson()
|
authenticatedUser = await admin.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -90,9 +94,9 @@ describe('Signup', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('if the email already exists', () => {
|
describe('if the email already exists', () => {
|
||||||
let email
|
let emailAddress
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
email = await factory.create('EmailAddress', {
|
emailAddress = await Factory.build('emailAddress', {
|
||||||
email: 'someuser@example.org',
|
email: 'someuser@example.org',
|
||||||
verifiedAt: null,
|
verifiedAt: null,
|
||||||
})
|
})
|
||||||
@ -100,7 +104,8 @@ describe('Signup', () => {
|
|||||||
|
|
||||||
describe('and the user has registered already', () => {
|
describe('and the user has registered already', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', { email })
|
const user = await Factory.build('userWithoutEmailAddress')
|
||||||
|
await emailAddress.relateTo(user, 'belongsTo')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws UserInputError error because of unique constraint violation', async () => {
|
it('throws UserInputError error because of unique constraint violation', async () => {
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../.././server'
|
import createServer from '../.././server'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getDriver, getNeode } from '../../db/neo4j'
|
import { getDriver, getNeode } from '../../db/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ describe('file a report on a resource', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
const { server } = createServer({
|
const { server } = createServer({
|
||||||
context: () => {
|
context: () => {
|
||||||
return {
|
return {
|
||||||
@ -68,7 +67,7 @@ describe('file a report on a resource', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('report a resource', () => {
|
describe('report a resource', () => {
|
||||||
@ -84,24 +83,39 @@ describe('file a report on a resource', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'current-user-id',
|
id: 'current-user-id',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'test@example.org',
|
email: 'test@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
otherReportingUser = await factory.create('User', {
|
)
|
||||||
|
otherReportingUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'other-reporting-user-id',
|
id: 'other-reporting-user-id',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'reporting@example.org',
|
email: 'reporting@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
await factory.create('User', {
|
)
|
||||||
|
await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'abusive-user-id',
|
id: 'abusive-user-id',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
name: 'abusive-user',
|
name: 'abusive-user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'abusive-user@example.org',
|
email: 'abusive-user@example.org',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await instance.create('Category', {
|
await instance.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
@ -341,12 +355,17 @@ describe('file a report on a resource', () => {
|
|||||||
|
|
||||||
describe('reported resource is a post', () => {
|
describe('reported resource is a post', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
author: currentUser,
|
'post',
|
||||||
|
{
|
||||||
id: 'post-to-report-id',
|
id: 'post-to-report-id',
|
||||||
title: 'This is a post that is going to be reported',
|
title: 'This is a post that is going to be reported',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
author: currentUser,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns type "Post"', async () => {
|
it('returns type "Post"', async () => {
|
||||||
@ -394,21 +413,30 @@ describe('file a report on a resource', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('reported resource is a comment', () => {
|
describe('reported resource is a comment', () => {
|
||||||
let createPostVariables
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
createPostVariables = {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'p1',
|
id: 'p1',
|
||||||
title: 'post to comment on',
|
title: 'post to comment on',
|
||||||
content: 'please comment on me',
|
content: 'please comment on me',
|
||||||
|
},
|
||||||
|
{
|
||||||
categoryIds,
|
categoryIds,
|
||||||
}
|
|
||||||
await factory.create('Post', { ...createPostVariables, author: currentUser })
|
|
||||||
await factory.create('Comment', {
|
|
||||||
author: currentUser,
|
author: currentUser,
|
||||||
postId: 'p1',
|
},
|
||||||
|
)
|
||||||
|
await Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'comment-to-report-id',
|
id: 'comment-to-report-id',
|
||||||
content: 'Post comment to be reported.',
|
content: 'Post comment to be reported.',
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
author: currentUser,
|
||||||
|
postId: 'p1',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns type "Comment"', async () => {
|
it('returns type "Comment"', async () => {
|
||||||
@ -457,7 +485,7 @@ describe('file a report on a resource', () => {
|
|||||||
|
|
||||||
describe('reported resource is a tag', () => {
|
describe('reported resource is a tag', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Tag', {
|
await Factory.build('tag', {
|
||||||
id: 'tag-to-report-id',
|
id: 'tag-to-report-id',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -515,24 +543,39 @@ describe('file a report on a resource', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = null
|
authenticatedUser = null
|
||||||
moderator = await factory.create('User', {
|
moderator = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'moderator-1',
|
id: 'moderator-1',
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'moderator@example.org',
|
email: 'moderator@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
currentUser = await factory.create('User', {
|
)
|
||||||
|
currentUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'current-user-id',
|
id: 'current-user-id',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'current.user@example.org',
|
email: 'current.user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
abusiveUser = await factory.create('User', {
|
)
|
||||||
|
abusiveUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'abusive-user-1',
|
id: 'abusive-user-1',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
name: 'abusive-user',
|
name: 'abusive-user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'abusive-user@example.org',
|
email: 'abusive-user@example.org',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await instance.create('Category', {
|
await instance.create('Category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
@ -540,31 +583,51 @@ describe('file a report on a resource', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('Post', {
|
Factory.build(
|
||||||
author: abusiveUser,
|
'post',
|
||||||
|
{
|
||||||
id: 'abusive-post-1',
|
id: 'abusive-post-1',
|
||||||
categoryIds,
|
|
||||||
content: 'Interesting Knowledge',
|
content: 'Interesting Knowledge',
|
||||||
}),
|
},
|
||||||
factory.create('Post', {
|
{
|
||||||
author: moderator,
|
categoryIds,
|
||||||
|
author: abusiveUser,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
id: 'post-2',
|
id: 'post-2',
|
||||||
categoryIds,
|
|
||||||
content: 'More things to do …',
|
content: 'More things to do …',
|
||||||
}),
|
},
|
||||||
factory.create('Post', {
|
{
|
||||||
author: currentUser,
|
author: moderator,
|
||||||
id: 'post-3',
|
|
||||||
categoryIds,
|
categoryIds,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
|
id: 'post-3',
|
||||||
content: 'I am at school …',
|
content: 'I am at school …',
|
||||||
}),
|
},
|
||||||
|
{
|
||||||
|
categoryIds,
|
||||||
|
author: currentUser,
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('Comment', {
|
Factory.build(
|
||||||
author: currentUser,
|
'comment',
|
||||||
|
{
|
||||||
id: 'abusive-comment-1',
|
id: 'abusive-comment-1',
|
||||||
postId: 'post-1',
|
},
|
||||||
}),
|
{
|
||||||
|
postId: 'post-2',
|
||||||
|
author: currentUser,
|
||||||
|
},
|
||||||
|
),
|
||||||
])
|
])
|
||||||
authenticatedUser = await currentUser.toJson()
|
authenticatedUser = await currentUser.toJson()
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
|
|
||||||
@ -31,23 +30,38 @@ describe('rewards', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
regularUser = await factory.create('User', {
|
regularUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'regular-user-id',
|
id: 'regular-user-id',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'user@example.org',
|
email: 'user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
moderator = await factory.create('User', {
|
)
|
||||||
|
moderator = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'moderator-id',
|
id: 'moderator-id',
|
||||||
role: 'moderator',
|
role: 'moderator',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'moderator@example.org',
|
email: 'moderator@example.org',
|
||||||
})
|
},
|
||||||
administrator = await factory.create('User', {
|
)
|
||||||
|
administrator = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'admin-id',
|
id: 'admin-id',
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
})
|
},
|
||||||
badge = await factory.create('Badge', {
|
)
|
||||||
|
badge = await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_rhino',
|
id: 'indiegogo_en_rhino',
|
||||||
type: 'crowdfunding',
|
type: 'crowdfunding',
|
||||||
status: 'permanent',
|
status: 'permanent',
|
||||||
@ -56,7 +70,7 @@ describe('rewards', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('reward', () => {
|
describe('reward', () => {
|
||||||
@ -130,7 +144,7 @@ describe('rewards', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('rewards a second different badge to same user', async () => {
|
it('rewards a second different badge to same user', async () => {
|
||||||
await factory.create('Badge', {
|
await Factory.build('badge', {
|
||||||
id: 'indiegogo_en_racoon',
|
id: 'indiegogo_en_racoon',
|
||||||
icon: '/img/badges/indiegogo_en_racoon.svg',
|
icon: '/img/badges/indiegogo_en_racoon.svg',
|
||||||
})
|
})
|
||||||
@ -172,10 +186,15 @@ describe('rewards', () => {
|
|||||||
},
|
},
|
||||||
errors: undefined,
|
errors: undefined,
|
||||||
}
|
}
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'regular-user-2-id',
|
id: 'regular-user-2-id',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'regular2@email.com',
|
email: 'regular2@email.com',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: rewardMutation,
|
mutation: rewardMutation,
|
||||||
variables,
|
variables,
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let mutate, query, authenticatedUser, variables
|
let mutate, query, authenticatedUser, variables
|
||||||
const factory = Factory()
|
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -47,22 +46,32 @@ describe('shout and unshout posts', () => {
|
|||||||
query = createTestClient(server).query
|
query = createTestClient(server).query
|
||||||
})
|
})
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
currentUser = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'current-user-id',
|
id: 'current-user-id',
|
||||||
name: 'Current User',
|
name: 'Current User',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'current.user@example.org',
|
email: 'current.user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
|
|
||||||
postAuthor = await factory.create('User', {
|
postAuthor = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'id-of-another-user',
|
id: 'id-of-another-user',
|
||||||
name: 'Another User',
|
name: 'Another User',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'another.user@example.org',
|
email: 'another.user@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('shout', () => {
|
describe('shout', () => {
|
||||||
@ -78,16 +87,26 @@ describe('shout and unshout posts', () => {
|
|||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await currentUser.toJson()
|
authenticatedUser = await currentUser.toJson()
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
name: 'Other user post',
|
name: 'Other user post',
|
||||||
id: 'another-user-post-id',
|
id: 'another-user-post-id',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: postAuthor,
|
author: postAuthor,
|
||||||
})
|
},
|
||||||
await factory.create('Post', {
|
)
|
||||||
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
name: 'current user post',
|
name: 'current user post',
|
||||||
id: 'current-user-post-id',
|
id: 'current-user-post-id',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: currentUser,
|
author: currentUser,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
variables = {}
|
variables = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -144,11 +163,16 @@ describe('shout and unshout posts', () => {
|
|||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
authenticatedUser = await currentUser.toJson()
|
authenticatedUser = await currentUser.toJson()
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
|
'post',
|
||||||
|
{
|
||||||
name: 'Posted By Another User',
|
name: 'Posted By Another User',
|
||||||
id: 'posted-by-another-user',
|
id: 'posted-by-another-user',
|
||||||
|
},
|
||||||
|
{
|
||||||
author: postAuthor,
|
author: postAuthor,
|
||||||
})
|
},
|
||||||
|
)
|
||||||
await mutate({
|
await mutate({
|
||||||
mutation: mutationShoutPost,
|
mutation: mutationShoutPost,
|
||||||
variables: { id: 'posted-by-another-user' },
|
variables: { id: 'posted-by-another-user' },
|
||||||
|
|||||||
@ -1,41 +1,46 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getDriver } from '../../db/neo4j'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
|
||||||
|
|
||||||
describe('SocialMedia', () => {
|
describe('SocialMedia', () => {
|
||||||
let socialMediaAction, someUser, ownerNode, owner
|
let socialMediaAction, someUser, ownerNode, owner
|
||||||
|
|
||||||
const ownerParams = {
|
|
||||||
email: 'pippi@example.com',
|
|
||||||
password: '1234',
|
|
||||||
name: 'Pippi Langstrumpf',
|
|
||||||
}
|
|
||||||
|
|
||||||
const userParams = {
|
|
||||||
email: 'kalle@example.com',
|
|
||||||
password: 'abcd',
|
|
||||||
name: 'Kalle Blomqvist',
|
|
||||||
}
|
|
||||||
|
|
||||||
const url = 'https://twitter.com/pippi-langstrumpf'
|
const url = 'https://twitter.com/pippi-langstrumpf'
|
||||||
const newUrl = 'https://twitter.com/bullerby'
|
const newUrl = 'https://twitter.com/bullerby'
|
||||||
|
|
||||||
const setUpSocialMedia = async () => {
|
const setUpSocialMedia = async () => {
|
||||||
const socialMediaNode = await neode.create('SocialMedia', { url })
|
const socialMediaNode = await Factory.build('socialMedia', { url })
|
||||||
await socialMediaNode.relateTo(ownerNode, 'ownedBy')
|
await socialMediaNode.relateTo(ownerNode, 'ownedBy')
|
||||||
return socialMediaNode.toJson()
|
return socialMediaNode.toJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const someUserNode = await neode.create('User', userParams)
|
const someUserNode = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
|
name: 'Kalle Blomqvist',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'kalle@example.com',
|
||||||
|
password: 'abcd',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
someUser = await someUserNode.toJson()
|
someUser = await someUserNode.toJson()
|
||||||
ownerNode = await neode.create('User', ownerParams)
|
ownerNode = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
|
name: 'Pippi Langstrumpf',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'pippi@example.com',
|
||||||
|
password: '1234',
|
||||||
|
},
|
||||||
|
)
|
||||||
owner = await ownerNode.toJson()
|
owner = await ownerNode.toJson()
|
||||||
|
|
||||||
socialMediaAction = async (user, mutation, variables) => {
|
socialMediaAction = async (user, mutation, variables) => {
|
||||||
@ -57,7 +62,7 @@ describe('SocialMedia', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('create social media', () => {
|
describe('create social media', () => {
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
|
|
||||||
let query, authenticatedUser
|
let query, authenticatedUser
|
||||||
const factory = Factory()
|
|
||||||
const instance = getNeode()
|
const instance = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('statistics', () => {
|
describe('statistics', () => {
|
||||||
@ -45,7 +44,7 @@ describe('statistics', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[...Array(6).keys()].map(() => {
|
[...Array(6).keys()].map(() => {
|
||||||
return factory.create('User')
|
return Factory.build('user')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -62,7 +61,7 @@ describe('statistics', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[...Array(3).keys()].map(() => {
|
[...Array(3).keys()].map(() => {
|
||||||
return factory.create('Post')
|
return Factory.build('post')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -79,7 +78,7 @@ describe('statistics', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
[...Array(2).keys()].map(() => {
|
[...Array(2).keys()].map(() => {
|
||||||
return factory.create('Comment')
|
return Factory.build('comment')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@ -97,7 +96,7 @@ describe('statistics', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
users = await Promise.all(
|
users = await Promise.all(
|
||||||
[...Array(2).keys()].map(() => {
|
[...Array(2).keys()].map(() => {
|
||||||
return factory.create('User')
|
return Factory.build('user')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
await users[0].relateTo(users[1], 'following')
|
await users[0].relateTo(users[1], 'following')
|
||||||
@ -116,12 +115,12 @@ describe('statistics', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
users = await Promise.all(
|
users = await Promise.all(
|
||||||
[...Array(2).keys()].map(() => {
|
[...Array(2).keys()].map(() => {
|
||||||
return factory.create('User')
|
return Factory.build('user')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
posts = await Promise.all(
|
posts = await Promise.all(
|
||||||
[...Array(3).keys()].map(() => {
|
[...Array(3).keys()].map(() => {
|
||||||
return factory.create('Post')
|
return Factory.build('post')
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
import CONFIG from './../../config'
|
import CONFIG from './../../config'
|
||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer, { context } from '../../server'
|
import createServer, { context } from '../../server'
|
||||||
import encode from '../../jwt/encode'
|
import encode from '../../jwt/encode'
|
||||||
import { getNeode } from '../../db/neo4j'
|
import { getNeode } from '../../db/neo4j'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
let query, mutate, variables, req, user
|
let query, mutate, variables, req, user
|
||||||
|
|
||||||
const disable = async id => {
|
const disable = async id => {
|
||||||
const moderator = await factory.create('User', { id: 'u2', role: 'moderator' })
|
const moderator = await Factory.build('user', { id: 'u2', role: 'moderator' })
|
||||||
const user = await neode.find('User', id)
|
const user = await neode.find('User', id)
|
||||||
const reportAgainstUser = await factory.create('Report')
|
const reportAgainstUser = await Factory.build('report')
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
reportAgainstUser.relateTo(moderator, 'filed', {
|
reportAgainstUser.relateTo(moderator, 'filed', {
|
||||||
resourceId: id,
|
resourceId: id,
|
||||||
@ -48,7 +47,7 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('isLoggedIn', () => {
|
describe('isLoggedIn', () => {
|
||||||
@ -69,7 +68,7 @@ describe('isLoggedIn', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await factory.create('User', { id: 'u3' })
|
user = await Factory.build('user', { id: 'u3' })
|
||||||
const userBearerToken = encode({ id: 'u3' })
|
const userBearerToken = encode({ id: 'u3' })
|
||||||
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
||||||
})
|
})
|
||||||
@ -127,15 +126,20 @@ describe('currentUser', () => {
|
|||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
describe('and corresponding user in the database', () => {
|
describe('and corresponding user in the database', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
id: 'u3',
|
id: 'u3',
|
||||||
// the `id` is the only thing that has to match the decoded JWT bearer token
|
// the `id` is the only thing that has to match the decoded JWT bearer token
|
||||||
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/jimmuirhead/128.jpg',
|
avatar: 'https://s3.amazonaws.com/uifaces/faces/twitter/jimmuirhead/128.jpg',
|
||||||
email: 'test@example.org',
|
|
||||||
name: 'Matilde Hermiston',
|
name: 'Matilde Hermiston',
|
||||||
slug: 'matilde-hermiston',
|
slug: 'matilde-hermiston',
|
||||||
role: 'user',
|
role: 'user',
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
email: 'test@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
const userBearerToken = encode({ id: 'u3' })
|
const userBearerToken = encode({ id: 'u3' })
|
||||||
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
||||||
})
|
})
|
||||||
@ -172,10 +176,13 @@ describe('login', () => {
|
|||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { email: 'test@example.org', password: '1234' }
|
variables = { email: 'test@example.org', password: '1234' }
|
||||||
user = await factory.create('User', {
|
user = await Factory.build(
|
||||||
...variables,
|
'user',
|
||||||
|
{
|
||||||
id: 'acb2d923-f3af-479e-9f00-61b12e864666',
|
id: 'acb2d923-f3af-479e-9f00-61b12e864666',
|
||||||
})
|
},
|
||||||
|
variables,
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('ask for a `token`', () => {
|
describe('ask for a `token`', () => {
|
||||||
@ -295,7 +302,7 @@ describe('change password', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', { id: 'u3' })
|
await Factory.build('user', { id: 'u3' })
|
||||||
const userBearerToken = encode({ id: 'u3' })
|
const userBearerToken = encode({ id: 'u3' })
|
||||||
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
req = { headers: { authorization: `Bearer ${userBearerToken}` } }
|
||||||
})
|
})
|
||||||
|
|||||||
@ -252,9 +252,11 @@ export default {
|
|||||||
followedByCurrentUser:
|
followedByCurrentUser:
|
||||||
'MATCH (this)<-[:FOLLOWS]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
'MATCH (this)<-[:FOLLOWS]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||||
blocked:
|
blocked:
|
||||||
'MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
'MATCH (this)-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||||
isMuted:
|
isMuted:
|
||||||
'MATCH (this)<-[:MUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
'MATCH (this)<-[:MUTED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||||
|
isBlocked:
|
||||||
|
'MATCH (this)<-[:BLOCKED]-(u:User {id: $cypherParams.currentUserId}) RETURN COUNT(u) >= 1',
|
||||||
},
|
},
|
||||||
count: {
|
count: {
|
||||||
contributionsCount:
|
contributionsCount:
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import Factory from '../../factories'
|
import Factory, { cleanDatabase } from '../../db/factories'
|
||||||
import { gql } from '../../helpers/jest'
|
import { gql } from '../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../db/neo4j'
|
import { getNeode, getDriver } from '../../db/neo4j'
|
||||||
import createServer from '../../server'
|
import createServer from '../../server'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const categoryIds = ['cat9']
|
const categoryIds = ['cat9']
|
||||||
let user
|
let user
|
||||||
|
|
||||||
@ -31,13 +30,13 @@ beforeAll(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('User', () => {
|
describe('User', () => {
|
||||||
describe('query by email address', () => {
|
describe('query by email address', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('User', { name: 'Johnny', email: 'any-email-address@example.org' })
|
await Factory.build('user', { name: 'Johnny' }, { email: 'any-email-address@example.org' })
|
||||||
})
|
})
|
||||||
|
|
||||||
const userQuery = gql`
|
const userQuery = gql`
|
||||||
@ -57,11 +56,16 @@ describe('User', () => {
|
|||||||
|
|
||||||
describe('as admin', () => {
|
describe('as admin', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const admin = await factory.create('User', {
|
const admin = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
role: 'admin',
|
role: 'admin',
|
||||||
|
},
|
||||||
|
{
|
||||||
email: 'admin@example.org',
|
email: 'admin@example.org',
|
||||||
password: '1234',
|
password: '1234',
|
||||||
})
|
},
|
||||||
|
)
|
||||||
authenticatedUser = await admin.toJson()
|
authenticatedUser = await admin.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -91,19 +95,9 @@ describe('User', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('UpdateUser', () => {
|
describe('UpdateUser', () => {
|
||||||
let userParams, variables
|
let variables
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
userParams = {
|
|
||||||
email: 'user@example.org',
|
|
||||||
password: '1234',
|
|
||||||
id: 'u47',
|
|
||||||
name: 'John Doe',
|
|
||||||
termsAndConditionsAgreedVersion: null,
|
|
||||||
termsAndConditionsAgreedAt: null,
|
|
||||||
allowEmbedIframes: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
id: 'u47',
|
id: 'u47',
|
||||||
name: 'John Doughnut',
|
name: 'John Doughnut',
|
||||||
@ -133,18 +127,33 @@ describe('UpdateUser', () => {
|
|||||||
`
|
`
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
user = await factory.create('User', userParams)
|
user = await Factory.build(
|
||||||
|
'user',
|
||||||
|
{
|
||||||
|
id: 'u47',
|
||||||
|
name: 'John Doe',
|
||||||
|
termsAndConditionsAgreedVersion: null,
|
||||||
|
termsAndConditionsAgreedAt: null,
|
||||||
|
allowEmbedIframes: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
email: 'user@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('as another user', () => {
|
describe('as another user', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const someoneElseParams = {
|
const someoneElse = await Factory.build(
|
||||||
email: 'someone-else@example.org',
|
'user',
|
||||||
password: '1234',
|
{
|
||||||
name: 'James Doe',
|
name: 'James Doe',
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
email: 'someone-else@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
const someoneElse = await factory.create('User', someoneElseParams)
|
|
||||||
authenticatedUser = await someoneElse.toJson()
|
authenticatedUser = await someoneElse.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -267,16 +276,20 @@ describe('DeleteUser', () => {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
variables = { id: ' u343', resource: [] }
|
variables = { id: ' u343', resource: [] }
|
||||||
|
|
||||||
user = await factory.create('User', {
|
user = await Factory.build('user', {
|
||||||
name: 'My name should be deleted',
|
name: 'My name should be deleted',
|
||||||
about: 'along with my about',
|
about: 'along with my about',
|
||||||
id: 'u343',
|
id: 'u343',
|
||||||
})
|
})
|
||||||
await factory.create('User', {
|
await Factory.build(
|
||||||
email: 'friends-account@example.org',
|
'user',
|
||||||
password: '1234',
|
{
|
||||||
id: 'not-my-account',
|
id: 'not-my-account',
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
email: 'friends-account@example.org',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('unauthenticated', () => {
|
describe('unauthenticated', () => {
|
||||||
@ -309,27 +322,42 @@ describe('DeleteUser', () => {
|
|||||||
|
|
||||||
describe('given posts and comments', () => {
|
describe('given posts and comments', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.create('Category', {
|
await Factory.build('category', {
|
||||||
id: 'cat9',
|
id: 'cat9',
|
||||||
name: 'Democracy & Politics',
|
name: 'Democracy & Politics',
|
||||||
icon: 'university',
|
icon: 'university',
|
||||||
})
|
})
|
||||||
await factory.create('Post', {
|
await Factory.build(
|
||||||
author: user,
|
'post',
|
||||||
|
{
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
content: 'Post by user u343',
|
content: 'Post by user u343',
|
||||||
categoryIds,
|
},
|
||||||
})
|
{
|
||||||
await factory.create('Comment', {
|
|
||||||
author: user,
|
author: user,
|
||||||
|
categoryIds,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
await Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
content: 'Comment by user u343',
|
content: 'Comment by user u343',
|
||||||
})
|
},
|
||||||
await factory.create('Comment', {
|
{
|
||||||
postId: 'p139',
|
author: user,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
await Factory.build(
|
||||||
|
'comment',
|
||||||
|
{
|
||||||
id: 'c156',
|
id: 'c156',
|
||||||
content: "A comment by someone else on user u343's post",
|
content: "A comment by someone else on user u343's post",
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
postId: 'p139',
|
||||||
|
},
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("deletes my account, but doesn't delete posts or comments by default", async () => {
|
it("deletes my account, but doesn't delete posts or comments by default", async () => {
|
||||||
@ -527,7 +555,7 @@ describe('DeleteUser', () => {
|
|||||||
|
|
||||||
describe('connected `SocialMedia` nodes', () => {
|
describe('connected `SocialMedia` nodes', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
const socialMedia = await factory.create('SocialMedia')
|
const socialMedia = await Factory.build('socialMedia')
|
||||||
await socialMedia.relateTo(user, 'ownedBy')
|
await socialMedia.relateTo(user, 'ownedBy')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import { gql } from '../../../helpers/jest'
|
import { gql } from '../../../helpers/jest'
|
||||||
import Factory from '../../../factories'
|
import Factory, { cleanDatabase } from '../../../db/factories'
|
||||||
import { getNeode, getDriver } from '../../../db/neo4j'
|
import { getNeode, getDriver } from '../../../db/neo4j'
|
||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../../server'
|
import createServer from '../../../server'
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
let authenticatedUser, mutate, variables
|
let authenticatedUser, mutate, variables
|
||||||
@ -107,7 +106,7 @@ beforeEach(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
factory.cleanDatabase()
|
cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('userMiddleware', () => {
|
describe('userMiddleware', () => {
|
||||||
@ -146,7 +145,7 @@ describe('userMiddleware', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('UpdateUser', () => {
|
describe('UpdateUser', () => {
|
||||||
let user, userParams
|
let user
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
newlyCreatedNodesWithLocales = [
|
newlyCreatedNodesWithLocales = [
|
||||||
{
|
{
|
||||||
@ -182,10 +181,9 @@ describe('userMiddleware', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
userParams = {
|
user = await Factory.build('user', {
|
||||||
id: 'updating-user',
|
id: 'updating-user',
|
||||||
}
|
})
|
||||||
user = await factory.create('User', userParams)
|
|
||||||
authenticatedUser = await user.toJson()
|
authenticatedUser = await user.toJson()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { createTestClient } from 'apollo-server-testing'
|
import { createTestClient } from 'apollo-server-testing'
|
||||||
import createServer from '../../../server'
|
import createServer from '../../../server'
|
||||||
import Factory from '../../../factories'
|
import { cleanDatabase } from '../../../db/factories'
|
||||||
import { gql } from '../../../helpers/jest'
|
import { gql } from '../../../helpers/jest'
|
||||||
import { getNeode, getDriver } from '../../../db/neo4j'
|
import { getNeode, getDriver } from '../../../db/neo4j'
|
||||||
|
|
||||||
const driver = getDriver()
|
const driver = getDriver()
|
||||||
const factory = Factory()
|
|
||||||
const neode = getNeode()
|
const neode = getNeode()
|
||||||
|
|
||||||
let currentUser
|
let currentUser
|
||||||
@ -30,7 +29,7 @@ beforeEach(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mutedUsers', () => {
|
describe('mutedUsers', () => {
|
||||||
|
|||||||
@ -68,7 +68,12 @@ type User {
|
|||||||
RETURN COUNT(u) >= 1
|
RETURN COUNT(u) >= 1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
isBlocked: Boolean! @cypher(
|
||||||
|
statement: """
|
||||||
|
MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
|
||||||
|
RETURN COUNT(user) >= 1
|
||||||
|
"""
|
||||||
|
)
|
||||||
blocked: Boolean! @cypher(
|
blocked: Boolean! @cypher(
|
||||||
statement: """
|
statement: """
|
||||||
MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
|
MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId})
|
||||||
|
|||||||
@ -3,18 +3,18 @@ import { Given, When, Then, AfterAll } from 'cucumber'
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
// import { client } from '../../../src/activitypub/apollo-client'
|
// import { client } from '../../../src/activitypub/apollo-client'
|
||||||
import { GraphQLClient } from 'graphql-request'
|
import { GraphQLClient } from 'graphql-request'
|
||||||
import Factory from '../../../src/factories'
|
import Factory from '../../../src/db/factories'
|
||||||
const debug = require('debug')('ea:test:steps')
|
const debug = require('debug')('ea:test:steps')
|
||||||
|
|
||||||
const factory = Factory()
|
|
||||||
const client = new GraphQLClient(host)
|
const client = new GraphQLClient(host)
|
||||||
|
|
||||||
function createUser (slug) {
|
function createUser (slug) {
|
||||||
debug(`creating user ${slug}`)
|
debug(`creating user ${slug}`)
|
||||||
return factory.create('User', {
|
return Factory.build('user', {
|
||||||
name: slug,
|
name: slug,
|
||||||
email: 'example@test.org',
|
}, {
|
||||||
password: '1234'
|
password: '1234'
|
||||||
|
email: 'example@test.org',
|
||||||
})
|
})
|
||||||
// await login({ email: 'example@test.org', password: '1234' })
|
// await login({ email: 'example@test.org', password: '1234' })
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4495,10 +4495,10 @@ graphql-redis-subscriptions@^2.1.2:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
ioredis "^4.6.3"
|
ioredis "^4.6.3"
|
||||||
|
|
||||||
graphql-shield@~7.0.10:
|
graphql-shield@~7.0.11:
|
||||||
version "7.0.10"
|
version "7.0.11"
|
||||||
resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-7.0.10.tgz#c25517a07e97bfd74089fde66ea2d2044addf743"
|
resolved "https://registry.yarnpkg.com/graphql-shield/-/graphql-shield-7.0.11.tgz#78d49f346326be71090d35d8f5843da9ee8136e2"
|
||||||
integrity sha512-m1HPQ3DpzuW8b7derWcsjjYtiBk+Hjgb1eL/0YK/Y2A0EV7vDQzJwRzlIwn9My7Xv+F4DJwm25yydnnUNpZt8g==
|
integrity sha512-iWn/aiom2c8NuOj60euWTmsKKUjX1DB4ynBcDitQOLXG3WrWgss2Iolzr553qooJvkR5czeAFgPlZgI+nUgwsQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@types/yup" "0.26.30"
|
"@types/yup" "0.26.30"
|
||||||
object-hash "^2.0.0"
|
object-hash "^2.0.0"
|
||||||
@ -7815,6 +7815,11 @@ rimraf@^3.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
glob "^7.1.3"
|
glob "^7.1.3"
|
||||||
|
|
||||||
|
rosie@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/rosie/-/rosie-2.0.1.tgz#c250c4787ce450b72aa9eff26509f68589814fa2"
|
||||||
|
integrity sha1-wlDEeHzkULcqqe/yZQn2hYmBT6I=
|
||||||
|
|
||||||
router-ips@^1.0.0:
|
router-ips@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/router-ips/-/router-ips-1.0.0.tgz#44e00858ebebc0133d58e40b2cd8a1fbb04203f5"
|
resolved "https://registry.yarnpkg.com/router-ips/-/router-ips-1.0.0.tgz#44e00858ebebc0133d58e40b2cd8a1fbb04203f5"
|
||||||
|
|||||||
@ -30,11 +30,12 @@ Given("I see David Irving's post on the post page", page => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Given('I am logged in with a {string} role', role => {
|
Given('I am logged in with a {string} role', role => {
|
||||||
cy.factory().create('User', {
|
cy.factory().build('user', {
|
||||||
email: `${role}@example.org`,
|
|
||||||
password: '1234',
|
|
||||||
termsAndConditionsAgreedVersion: VERSION,
|
termsAndConditionsAgreedVersion: VERSION,
|
||||||
role
|
role
|
||||||
|
}, {
|
||||||
|
email: `${role}@example.org`,
|
||||||
|
password: '1234',
|
||||||
})
|
})
|
||||||
cy.login({
|
cy.login({
|
||||||
email: `${role}@example.org`,
|
email: `${role}@example.org`,
|
||||||
@ -127,7 +128,7 @@ Given('somebody reported the following posts:', table => {
|
|||||||
password: '1234'
|
password: '1234'
|
||||||
}
|
}
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.create('User', submitter)
|
.build('user', {}, submitter)
|
||||||
.authenticateAs(submitter)
|
.authenticateAs(submitter)
|
||||||
.mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
.mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
|
||||||
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
|
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
|
||||||
@ -166,8 +167,9 @@ Then('I can visit the post page', () => {
|
|||||||
|
|
||||||
When("they have a post someone has reported", () => {
|
When("they have a post someone has reported", () => {
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.create("Post", {
|
.build("post", {
|
||||||
authorId: 'annnoying-user',
|
|
||||||
title,
|
title,
|
||||||
|
}, {
|
||||||
|
authorId: 'annnoying-user',
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@ -25,7 +25,6 @@ const narratorParams = {
|
|||||||
name: "Peter Pan",
|
name: "Peter Pan",
|
||||||
slug: "peter-pan",
|
slug: "peter-pan",
|
||||||
avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg",
|
avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg",
|
||||||
...loginCredentials,
|
|
||||||
...termsAndConditionsAgreedVersion,
|
...termsAndConditionsAgreedVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -33,7 +32,6 @@ const annoyingParams = {
|
|||||||
email: "spammy-spammer@example.org",
|
email: "spammy-spammer@example.org",
|
||||||
slug: 'spammy-spammer',
|
slug: 'spammy-spammer',
|
||||||
password: "1234",
|
password: "1234",
|
||||||
...termsAndConditionsAgreedVersion
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Given("I am logged in", () => {
|
Given("I am logged in", () => {
|
||||||
@ -49,49 +47,35 @@ Given("the {string} user searches for {string}", (_, postTitle) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Given("we have a selection of categories", () => {
|
Given("we have a selection of categories", () => {
|
||||||
cy.createCategories("cat0", "just-for-fun");
|
cy.factory().build('category', { id: "cat0", slug: "just-for-fun" });
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("we have a selection of tags and categories as well as posts", () => {
|
Given("we have a selection of tags and categories as well as posts", () => {
|
||||||
cy.createCategories("cat12")
|
|
||||||
.factory()
|
|
||||||
.create("Tag", {
|
|
||||||
id: "Ecology"
|
|
||||||
})
|
|
||||||
.create("Tag", {
|
|
||||||
id: "Nature"
|
|
||||||
})
|
|
||||||
.create("Tag", {
|
|
||||||
id: "Democracy"
|
|
||||||
});
|
|
||||||
|
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.create("User", {
|
.build('category', { id: 'cat12', name: "Just For Fun", icon: "smile", })
|
||||||
id: 'a1'
|
.build('category', { id: 'cat121', name: "Happiness & Values", icon: "heart-o"})
|
||||||
})
|
.build('category', { id: 'cat122', name: "Health & Wellbeing", icon: "medkit"})
|
||||||
.create("Post", {
|
.build("tag", { id: "Ecology" })
|
||||||
|
.build("tag", { id: "Nature" })
|
||||||
|
.build("tag", { id: "Democracy" })
|
||||||
|
.build("user", { id: 'a1' })
|
||||||
|
.build("post", {}, {
|
||||||
authorId: 'a1',
|
authorId: 'a1',
|
||||||
tagIds: ["Ecology", "Nature", "Democracy"],
|
tagIds: ["Ecology", "Nature", "Democracy"],
|
||||||
categoryIds: ["cat12"]
|
categoryIds: ["cat12"]
|
||||||
})
|
})
|
||||||
.create("Post", {
|
.build("post", {}, {
|
||||||
authorId: 'a1',
|
authorId: 'a1',
|
||||||
tagIds: ["Nature", "Democracy"],
|
tagIds: ["Nature", "Democracy"],
|
||||||
categoryIds: ["cat121"]
|
categoryIds: ["cat121"]
|
||||||
});
|
|
||||||
|
|
||||||
cy.factory()
|
|
||||||
.create("User", {
|
|
||||||
id: 'a2'
|
|
||||||
})
|
})
|
||||||
.create("Post", {
|
.build("user", { id: 'a2' })
|
||||||
|
.build("post", {}, {
|
||||||
authorId: 'a2',
|
authorId: 'a2',
|
||||||
tagIds: ['Nature', 'Democracy'],
|
tagIds: ['Nature', 'Democracy'],
|
||||||
categoryIds: ["cat12"]
|
categoryIds: ["cat12"]
|
||||||
});
|
})
|
||||||
cy.factory()
|
.build("post", {}, {
|
||||||
.create("Post", {
|
|
||||||
authorId: narratorParams.id,
|
|
||||||
tagIds: ['Democracy'],
|
tagIds: ['Democracy'],
|
||||||
categoryIds: ["cat122"]
|
categoryIds: ["cat122"]
|
||||||
})
|
})
|
||||||
@ -99,23 +83,22 @@ Given("we have a selection of tags and categories as well as posts", () => {
|
|||||||
|
|
||||||
Given("we have the following user accounts:", table => {
|
Given("we have the following user accounts:", table => {
|
||||||
table.hashes().forEach(params => {
|
table.hashes().forEach(params => {
|
||||||
cy.factory().create("User", {
|
cy.factory().build("user", {
|
||||||
...params,
|
...params,
|
||||||
...termsAndConditionsAgreedVersion
|
...termsAndConditionsAgreedVersion
|
||||||
});
|
}, params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("I have a user account", () => {
|
Given("I have a user account", () => {
|
||||||
cy.factory().create("User", narratorParams);
|
cy.factory().build("user", narratorParams, loginCredentials);
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("my user account has the role {string}", role => {
|
Given("my user account has the role {string}", role => {
|
||||||
cy.factory().create("User", {
|
cy.factory().build("user", {
|
||||||
role,
|
role,
|
||||||
...loginCredentials,
|
|
||||||
...termsAndConditionsAgreedVersion,
|
...termsAndConditionsAgreedVersion,
|
||||||
});
|
}, loginCredentials);
|
||||||
});
|
});
|
||||||
|
|
||||||
When("I log out", cy.logout);
|
When("I log out", cy.logout);
|
||||||
@ -203,30 +186,34 @@ When("I press {string}", label => {
|
|||||||
cy.contains(label).click();
|
cy.contains(label).click();
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("we have this user in our database:", table => {
|
Given("we have the following comments in our database:", table => {
|
||||||
const [firstRow] = table.hashes()
|
table.hashes().forEach((attributesOrOptions, i) => {
|
||||||
cy.factory().create('User', firstRow)
|
cy.factory().build("comment", {
|
||||||
|
...attributesOrOptions,
|
||||||
|
}, {
|
||||||
|
...attributesOrOptions,
|
||||||
|
});
|
||||||
})
|
})
|
||||||
|
});
|
||||||
|
|
||||||
Given("we have the following posts in our database:", table => {
|
Given("we have the following posts in our database:", table => {
|
||||||
cy.factory().create('Category', {
|
cy.factory().build('category', {
|
||||||
id: `cat-456`,
|
id: `cat-456`,
|
||||||
name: "Just For Fun",
|
name: "Just For Fun",
|
||||||
slug: `just-for-fun`,
|
slug: `just-for-fun`,
|
||||||
icon: "smile"
|
icon: "smile"
|
||||||
})
|
})
|
||||||
|
|
||||||
table.hashes().forEach(({
|
table.hashes().forEach((attributesOrOptions, i) => {
|
||||||
...postAttributes
|
cy.factory().build("post", {
|
||||||
}, i) => {
|
...attributesOrOptions,
|
||||||
postAttributes = {
|
deleted: Boolean(attributesOrOptions.deleted),
|
||||||
...postAttributes,
|
disabled: Boolean(attributesOrOptions.disabled),
|
||||||
deleted: Boolean(postAttributes.deleted),
|
pinned: Boolean(attributesOrOptions.pinned),
|
||||||
disabled: Boolean(postAttributes.disabled),
|
}, {
|
||||||
pinned: Boolean(postAttributes.pinned),
|
...attributesOrOptions,
|
||||||
categoryIds: ['cat-456']
|
categoryIds: ['cat-456']
|
||||||
}
|
});
|
||||||
cy.factory().create("Post", postAttributes);
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -246,11 +233,15 @@ When(
|
|||||||
);
|
);
|
||||||
|
|
||||||
Given("I previously created a post", () => {
|
Given("I previously created a post", () => {
|
||||||
lastPost.authorId = narratorParams.id
|
lastPost = {
|
||||||
lastPost.title = "previously created post";
|
lastPost,
|
||||||
lastPost.content = "with some content";
|
title: "previously created post",
|
||||||
|
content: "with some content",
|
||||||
|
};
|
||||||
cy.factory()
|
cy.factory()
|
||||||
.create("Post", lastPost);
|
.build("post", lastPost, {
|
||||||
|
authorId: narratorParams.id
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
When("I choose {string} as the title of the post", title => {
|
When("I choose {string} as the title of the post", title => {
|
||||||
@ -318,10 +309,9 @@ Then(
|
|||||||
Given("my user account has the following login credentials:", table => {
|
Given("my user account has the following login credentials:", table => {
|
||||||
loginCredentials = table.hashes()[0];
|
loginCredentials = table.hashes()[0];
|
||||||
cy.debug();
|
cy.debug();
|
||||||
cy.factory().create("User", {
|
cy.factory().build("user", {
|
||||||
...termsAndConditionsAgreedVersion,
|
...termsAndConditionsAgreedVersion,
|
||||||
...loginCredentials
|
}, loginCredentials);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
When("I fill the password form with:", table => {
|
When("I fill the password form with:", table => {
|
||||||
@ -428,12 +418,11 @@ Then("there are no notifications in the top menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Given("there is an annoying user called {string}", name => {
|
Given("there is an annoying user called {string}", name => {
|
||||||
cy.factory().create("User", {
|
cy.factory().build("user", {
|
||||||
...annoyingParams,
|
|
||||||
id: "annoying-user",
|
id: "annoying-user",
|
||||||
name,
|
name,
|
||||||
...termsAndConditionsAgreedVersion,
|
...termsAndConditionsAgreedVersion,
|
||||||
});
|
}, annoyingParams);
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("there is an annoying user who has muted me", () => {
|
Given("there is an annoying user who has muted me", () => {
|
||||||
@ -498,12 +487,11 @@ Given("I follow the user {string}", name => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Given('{string} wrote a post {string}', (_, title) => {
|
Given('{string} wrote a post {string}', (_, title) => {
|
||||||
cy.createCategories("cat21")
|
cy.factory()
|
||||||
.factory()
|
.build("post", {
|
||||||
.create("Post", {
|
|
||||||
authorId: 'annoying-user',
|
|
||||||
title,
|
title,
|
||||||
categoryIds: ["cat21"]
|
}, {
|
||||||
|
authorId: 'annoying-user',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -521,12 +509,11 @@ Then("I get removed from his follower collection", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Given("I wrote a post {string}", title => {
|
Given("I wrote a post {string}", title => {
|
||||||
cy.createCategories(`cat213`, title)
|
cy.factory()
|
||||||
.factory()
|
.build("post", {
|
||||||
.create("Post", {
|
|
||||||
authorId: narratorParams.id,
|
|
||||||
title,
|
title,
|
||||||
categoryIds: ["cat213"]
|
}, {
|
||||||
|
authorId: narratorParams.id,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -550,10 +537,24 @@ When("I block the user {string}", name => {
|
|||||||
name
|
name
|
||||||
})
|
})
|
||||||
.then(blockedUser => {
|
.then(blockedUser => {
|
||||||
|
cy.neode()
|
||||||
|
.first("User", {
|
||||||
|
id: narratorParams.id
|
||||||
|
})
|
||||||
|
.relateTo(blockedUser, "blocked");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
When("a user has blocked me", () => {
|
||||||
cy.neode()
|
cy.neode()
|
||||||
.first("User", {
|
.first("User", {
|
||||||
name: narratorParams.name
|
name: narratorParams.name
|
||||||
})
|
})
|
||||||
|
.then(blockedUser => {
|
||||||
|
cy.neode()
|
||||||
|
.first("User", {
|
||||||
|
name: 'Harassing User'
|
||||||
|
})
|
||||||
.relateTo(blockedUser, "blocked");
|
.relateTo(blockedUser, "blocked");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -577,10 +578,31 @@ Then("I see only one post with the title {string}", title => {
|
|||||||
cy.get(".main-container").contains(".post-link", title);
|
cy.get(".main-container").contains(".post-link", title);
|
||||||
});
|
});
|
||||||
|
|
||||||
Then("they should not see the comment from", () => {
|
Then("they should not see the comment form", () => {
|
||||||
cy.get(".ds-card-footer").children().should('not.have.class', 'comment-form')
|
cy.get(".ds-card-footer").children().should('not.have.class', 'comment-form')
|
||||||
})
|
})
|
||||||
|
|
||||||
Then("they should see a text explaining commenting is not possible", () => {
|
Then("they should see a text explaining why commenting is not possible", () => {
|
||||||
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
|
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Then("I should see no users in my blocked users list", () => {
|
||||||
|
cy.get('.ds-placeholder')
|
||||||
|
.should('contain', "So far, you have not blocked anybody.")
|
||||||
|
})
|
||||||
|
|
||||||
|
Then("I {string} see {string} from the content menu in the user info box", (condition, link) => {
|
||||||
|
cy.get(".user-content-menu .base-button").click()
|
||||||
|
cy.get(".popover .ds-menu-item-link")
|
||||||
|
.should(condition === 'should' ? 'contain' : 'not.contain', link)
|
||||||
|
})
|
||||||
|
|
||||||
|
Then('I should not see {string} button', button => {
|
||||||
|
cy.get('.ds-card-content .action-buttons')
|
||||||
|
.should('have.length', 1)
|
||||||
|
})
|
||||||
|
|
||||||
|
Then('I should see the {string} button', button => {
|
||||||
|
cy.get('.ds-card-content .action-buttons .base-button')
|
||||||
|
.should('contain', button)
|
||||||
|
})
|
||||||
|
|||||||
@ -6,8 +6,11 @@ Feature: Post Comment
|
|||||||
Background:
|
Background:
|
||||||
Given I have a user account
|
Given I have a user account
|
||||||
And we have the following posts in our database:
|
And we have the following posts in our database:
|
||||||
| id | title | slug | authorId | commentContent |
|
| id | title | slug | authorId |
|
||||||
| bWBjpkTKZp | 101 Essays that will change the way you think | 101-essays | id-of-peter-pan | @peter-pan reply to me |
|
| bWBjpkTKZp | 101 Essays that will change the way you think | 101-essays | id-of-peter-pan |
|
||||||
|
And we have the following comments in our database:
|
||||||
|
| postId | content | authorId |
|
||||||
|
| bWBjpkTKZp | @peter-pan reply to me | id-of-peter-pan |
|
||||||
And I am logged in
|
And I am logged in
|
||||||
|
|
||||||
Scenario: Comment creation
|
Scenario: Comment creation
|
||||||
|
|||||||
@ -11,6 +11,7 @@ Feature: Block a User
|
|||||||
Scenario: Block a user
|
Scenario: Block a user
|
||||||
Given I am on the profile page of the annoying user
|
Given I am on the profile page of the annoying user
|
||||||
When I click on "Block user" from the content menu in the user info box
|
When I click on "Block user" from the content menu in the user info box
|
||||||
|
And I "should" see "Unblock user" from the content menu in the user info box
|
||||||
And I navigate to my "Blocked users" settings page
|
And I navigate to my "Blocked users" settings page
|
||||||
Then I can see the following table:
|
Then I can see the following table:
|
||||||
| Avatar | Name |
|
| Avatar | Name |
|
||||||
@ -20,14 +21,15 @@ Feature: Block a User
|
|||||||
Given I block the user "Harassing User"
|
Given I block the user "Harassing User"
|
||||||
And I previously created a post
|
And I previously created a post
|
||||||
And a blocked user visits the post page of one of my authored posts
|
And a blocked user visits the post page of one of my authored posts
|
||||||
Then they should not see the comment from
|
Then they should see a text explaining why commenting is not possible
|
||||||
And they should see a text explaining commenting is not possible
|
And they should not see the comment form
|
||||||
|
|
||||||
Scenario: Block a previously followed user
|
Scenario: Block a previously followed user
|
||||||
Given I follow the user "Harassing User"
|
Given I follow the user "Harassing User"
|
||||||
When I visit the profile page of the annoying user
|
When I visit the profile page of the annoying user
|
||||||
And I click on "Block user" from the content menu in the user info box
|
And I click on "Block user" from the content menu in the user info box
|
||||||
And I get removed from his follower collection
|
And I get removed from his follower collection
|
||||||
|
And I "should" see "Unblock user" from the content menu in the user info box
|
||||||
|
|
||||||
Scenario: Posts of blocked users are not filtered from search results
|
Scenario: Posts of blocked users are not filtered from search results
|
||||||
Given "Harassing User" wrote a post "You can still see my posts"
|
Given "Harassing User" wrote a post "You can still see my posts"
|
||||||
@ -44,3 +46,15 @@ Feature: Block a User
|
|||||||
Then I should see the following posts in the select dropdown:
|
Then I should see the following posts in the select dropdown:
|
||||||
| title |
|
| title |
|
||||||
| previously created post |
|
| previously created post |
|
||||||
|
|
||||||
|
Scenario: Blocked users cannot see they are blocked in their list
|
||||||
|
Given a user has blocked me
|
||||||
|
And I navigate to my "Blocked users" settings page
|
||||||
|
Then I should see no users in my blocked users list
|
||||||
|
|
||||||
|
Scenario: Blocked users should not see link or button to unblock, only blocking users
|
||||||
|
Given a user has blocked me
|
||||||
|
When I visit the profile page of the annoying user
|
||||||
|
And I "should not" see "Unblock user" from the content menu in the user info box
|
||||||
|
And I should see the "Follow" button
|
||||||
|
And I should not see "Unblock user" button
|
||||||
@ -74,27 +74,6 @@ Cypress.Commands.add("openPage", page => {
|
|||||||
cy.visit(`/${page}`);
|
cy.visit(`/${page}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
Cypress.Commands.add("createCategories", (id, slug) => {
|
|
||||||
cy.neode()
|
|
||||||
.create("Category", {
|
|
||||||
id: `${id}`,
|
|
||||||
name: "Just For Fun",
|
|
||||||
slug: `${slug}`,
|
|
||||||
icon: "smile"
|
|
||||||
})
|
|
||||||
.create("Category", {
|
|
||||||
id: `${id}1`,
|
|
||||||
name: "Happiness & Values",
|
|
||||||
icon: "heart-o"
|
|
||||||
})
|
|
||||||
.create("Category", {
|
|
||||||
id: `${id}2`,
|
|
||||||
name: "Health & Wellbeing",
|
|
||||||
icon: "medkit"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
'authenticateAs',
|
'authenticateAs',
|
||||||
async ({email, password}) => {
|
async ({email, password}) => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import Factory from '../../backend/src/factories'
|
import Factory, { cleanDatabase } from '../../backend/src/db/factories'
|
||||||
import { getDriver, getNeode } from '../../backend/src/db/neo4j'
|
import { getDriver, getNeode } from '../../backend/src/db/neo4j'
|
||||||
|
|
||||||
const neo4jConfigs = {
|
const neo4jConfigs = {
|
||||||
@ -6,18 +6,16 @@ const neo4jConfigs = {
|
|||||||
username: Cypress.env('NEO4J_USERNAME'),
|
username: Cypress.env('NEO4J_USERNAME'),
|
||||||
password: Cypress.env('NEO4J_PASSWORD')
|
password: Cypress.env('NEO4J_PASSWORD')
|
||||||
}
|
}
|
||||||
const neo4jDriver = getDriver(neo4jConfigs)
|
|
||||||
const neodeInstance = getNeode(neo4jConfigs)
|
const neodeInstance = getNeode(neo4jConfigs)
|
||||||
const factoryOptions = { neo4jDriver, neodeInstance }
|
|
||||||
const factory = Factory(factoryOptions)
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('neode', () => {
|
Cypress.Commands.add('neode', () => {
|
||||||
return neodeInstance
|
return neodeInstance
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
'first',
|
'first',
|
||||||
{ prevSubject: true },
|
{ prevSubject: true },
|
||||||
@ -33,24 +31,14 @@ Cypress.Commands.add(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Cypress.Commands.add('factory', () => {
|
Cypress.Commands.add('factory', () => Factory)
|
||||||
return Factory(factoryOptions)
|
|
||||||
})
|
|
||||||
|
|
||||||
Cypress.Commands.add(
|
Cypress.Commands.add(
|
||||||
'create',
|
'build',
|
||||||
{ prevSubject: true },
|
{ prevSubject: true },
|
||||||
async (factory, node, properties) => {
|
async (factory, name, atrributes, options) => {
|
||||||
await factory.create(node, properties)
|
await factory.build(name, atrributes, options)
|
||||||
return factory
|
return factory
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
Cypress.Commands.add(
|
|
||||||
'relate',
|
|
||||||
{ prevSubject: true },
|
|
||||||
async (factory, node, relationship, properties) => {
|
|
||||||
await factory.relate(node, relationship, properties)
|
|
||||||
return factory
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|||||||
@ -1,15 +1,13 @@
|
|||||||
// features/support/steps.js
|
// features/support/steps.js
|
||||||
import { Given, When, Then, After, AfterAll } from 'cucumber'
|
import { Given, When, Then, After, AfterAll } from 'cucumber'
|
||||||
import Factory from '../../backend/src/factories'
|
import Factory, { cleanDatabase } from '../../backend/src/db/factories'
|
||||||
import dotenv from 'dotenv'
|
import dotenv from 'dotenv'
|
||||||
import expect from 'expect'
|
import expect from 'expect'
|
||||||
|
|
||||||
const debug = require('debug')('ea:test:steps')
|
const debug = require('debug')('ea:test:steps')
|
||||||
const factory = Factory()
|
|
||||||
|
|
||||||
|
|
||||||
After(async () => {
|
After(async () => {
|
||||||
await factory.cleanDatabase()
|
await cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
Given('our CLIENT_URI is {string}', function (string) {
|
Given('our CLIENT_URI is {string}', function (string) {
|
||||||
@ -21,7 +19,7 @@ Given('our CLIENT_URI is {string}', function (string) {
|
|||||||
|
|
||||||
Given('we have the following users in our database:', function (dataTable) {
|
Given('we have the following users in our database:', function (dataTable) {
|
||||||
return Promise.all(dataTable.hashes().map(({ slug, name }) => {
|
return Promise.all(dataTable.hashes().map(({ slug, name }) => {
|
||||||
return factory.create('User', {
|
return Factory.build('user', {
|
||||||
name,
|
name,
|
||||||
slug,
|
slug,
|
||||||
})
|
})
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"@babel/register": "^7.8.3",
|
"@babel/register": "^7.8.3",
|
||||||
"auto-changelog": "^1.16.2",
|
"auto-changelog": "^1.16.2",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"codecov": "^3.6.4",
|
"codecov": "^3.6.5",
|
||||||
"cross-env": "^6.0.3",
|
"cross-env": "^6.0.3",
|
||||||
"cucumber": "^6.0.5",
|
"cucumber": "^6.0.5",
|
||||||
"cypress": "^3.8.3",
|
"cypress": "^3.8.3",
|
||||||
@ -46,6 +46,7 @@
|
|||||||
"neo4j-driver": "^4.0.1",
|
"neo4j-driver": "^4.0.1",
|
||||||
"neode": "^0.3.7",
|
"neode": "^0.3.7",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
|
"rosie": "^2.0.1",
|
||||||
"slug": "^2.1.1",
|
"slug": "^2.1.1",
|
||||||
"standard-version": "^7.1.0"
|
"standard-version": "^7.1.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -172,7 +172,7 @@ export default {
|
|||||||
icon: 'microphone-slash',
|
icon: 'microphone-slash',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (this.resource.blocked) {
|
if (this.resource.isBlocked) {
|
||||||
routes.push({
|
routes.push({
|
||||||
label: this.$t(`settings.blocked-users.unblock`),
|
label: this.$t(`settings.blocked-users.unblock`),
|
||||||
callback: () => {
|
callback: () => {
|
||||||
|
|||||||
@ -24,6 +24,7 @@ export default i18n => {
|
|||||||
createdAt
|
createdAt
|
||||||
followedByCurrentUser
|
followedByCurrentUser
|
||||||
isMuted
|
isMuted
|
||||||
|
isBlocked
|
||||||
blocked
|
blocked
|
||||||
following(first: 7) {
|
following(first: 7) {
|
||||||
...user
|
...user
|
||||||
|
|||||||
@ -103,7 +103,7 @@
|
|||||||
"@storybook/addon-actions": "^5.3.12",
|
"@storybook/addon-actions": "^5.3.12",
|
||||||
"@storybook/addon-notes": "^5.3.12",
|
"@storybook/addon-notes": "^5.3.12",
|
||||||
"@storybook/vue": "~5.3.12",
|
"@storybook/vue": "~5.3.12",
|
||||||
"@vue/cli-shared-utils": "~4.1.2",
|
"@vue/cli-shared-utils": "~4.2.2",
|
||||||
"@vue/eslint-config-prettier": "~6.0.0",
|
"@vue/eslint-config-prettier": "~6.0.0",
|
||||||
"@vue/server-test-utils": "~1.0.0-beta.31",
|
"@vue/server-test-utils": "~1.0.0-beta.31",
|
||||||
"@vue/test-utils": "~1.0.0-beta.31",
|
"@vue/test-utils": "~1.0.0-beta.31",
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
:post="post"
|
:post="post"
|
||||||
@createComment="createComment"
|
@createComment="createComment"
|
||||||
/>
|
/>
|
||||||
<ds-placeholder v-else>
|
<ds-placeholder v-if="post.author.blocked">
|
||||||
{{ $t('settings.blocked-users.explanation.commenting-disabled') }}
|
{{ $t('settings.blocked-users.explanation.commenting-disabled') }}
|
||||||
<br />
|
<br />
|
||||||
{{ $t('settings.blocked-users.explanation.commenting-explanation') }}
|
{{ $t('settings.blocked-users.explanation.commenting-explanation') }}
|
||||||
|
|||||||
@ -67,14 +67,14 @@
|
|||||||
</ds-flex-item>
|
</ds-flex-item>
|
||||||
</ds-flex>
|
</ds-flex>
|
||||||
<div v-if="!myProfile" class="action-buttons">
|
<div v-if="!myProfile" class="action-buttons">
|
||||||
<base-button v-if="user.blocked" @click="unblockUser(user)">
|
<base-button v-if="user.isBlocked" @click="unblockUser(user)">
|
||||||
{{ $t('settings.blocked-users.unblock') }}
|
{{ $t('settings.blocked-users.unblock') }}
|
||||||
</base-button>
|
</base-button>
|
||||||
<base-button v-if="user.isMuted" @click="unmuteUser(user)">
|
<base-button v-if="user.isMuted" @click="unmuteUser(user)">
|
||||||
{{ $t('settings.muted-users.unmute') }}
|
{{ $t('settings.muted-users.unmute') }}
|
||||||
</base-button>
|
</base-button>
|
||||||
<hc-follow-button
|
<hc-follow-button
|
||||||
v-if="!(user.blocked || user.isMuted)"
|
v-if="!user.isMuted && !user.isBlocked"
|
||||||
:follow-id="user.id"
|
:follow-id="user.id"
|
||||||
:is-followed="user.followedByCurrentUser"
|
:is-followed="user.followedByCurrentUser"
|
||||||
@optimistic="optimisticFollow"
|
@optimistic="optimisticFollow"
|
||||||
|
|||||||
@ -2821,6 +2821,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.6.tgz#9cbfcb62c50947217f4d88d4d274cc40c22625a9"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.6.tgz#9cbfcb62c50947217f4d88d4d274cc40c22625a9"
|
||||||
integrity sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg==
|
integrity sha512-Fvm24+u85lGmV4hT5G++aht2C5I4Z4dYlWZIh62FAfFO/TfzXtPpoLI6I7AuBWkIFqZCnhFOoTT7RjjaIL5Fjg==
|
||||||
|
|
||||||
|
"@types/normalize-package-data@^2.4.0":
|
||||||
|
version "2.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
|
||||||
|
integrity sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA==
|
||||||
|
|
||||||
"@types/npmlog@^4.1.2":
|
"@types/npmlog@^4.1.2":
|
||||||
version "4.1.2"
|
version "4.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/@types/npmlog/-/npmlog-4.1.2.tgz#d070fe6a6b78755d1092a3dc492d34c3d8f871c4"
|
resolved "https://registry.yarnpkg.com/@types/npmlog/-/npmlog-4.1.2.tgz#d070fe6a6b78755d1092a3dc492d34c3d8f871c4"
|
||||||
@ -3025,10 +3030,10 @@
|
|||||||
"@vue/babel-plugin-transform-vue-jsx" "^1.1.2"
|
"@vue/babel-plugin-transform-vue-jsx" "^1.1.2"
|
||||||
camelcase "^5.0.0"
|
camelcase "^5.0.0"
|
||||||
|
|
||||||
"@vue/cli-shared-utils@~4.1.2":
|
"@vue/cli-shared-utils@~4.2.2":
|
||||||
version "4.1.2"
|
version "4.2.2"
|
||||||
resolved "https://registry.yarnpkg.com/@vue/cli-shared-utils/-/cli-shared-utils-4.1.2.tgz#d33984c8790ad869ef77f5229abd3e8e584fe58b"
|
resolved "https://registry.yarnpkg.com/@vue/cli-shared-utils/-/cli-shared-utils-4.2.2.tgz#953fec34115cb12d0820012a9d7400f8c27d6660"
|
||||||
integrity sha512-uQAVqxCWdL5ipZ0TPu6SVsdokQp4yHt8SzzpUGhq8TkW4vwalGddJAAJrqZHMl91ZTIJ4p4ixofmCaaJo5rSRA==
|
integrity sha512-EK5wcxgjadqUpSzfh6Bnxd46Zx+SAaHusygqV11UZKHr4EObc/SjCpq7c7drmFkBjRqmVvrHs4jRnJJo5VgCgQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@hapi/joi" "^15.0.1"
|
"@hapi/joi" "^15.0.1"
|
||||||
chalk "^2.4.2"
|
chalk "^2.4.2"
|
||||||
@ -3038,6 +3043,7 @@
|
|||||||
node-ipc "^9.1.1"
|
node-ipc "^9.1.1"
|
||||||
open "^6.3.0"
|
open "^6.3.0"
|
||||||
ora "^3.4.0"
|
ora "^3.4.0"
|
||||||
|
read-pkg "^5.1.1"
|
||||||
request "^2.87.0"
|
request "^2.87.0"
|
||||||
request-promise-native "^1.0.8"
|
request-promise-native "^1.0.8"
|
||||||
semver "^6.1.0"
|
semver "^6.1.0"
|
||||||
@ -11582,7 +11588,7 @@ nopt@~1.0.10:
|
|||||||
dependencies:
|
dependencies:
|
||||||
abbrev "1"
|
abbrev "1"
|
||||||
|
|
||||||
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
|
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0:
|
||||||
version "2.5.0"
|
version "2.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
|
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8"
|
||||||
integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==
|
integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==
|
||||||
@ -13811,6 +13817,16 @@ read-pkg@^2.0.0:
|
|||||||
normalize-package-data "^2.3.2"
|
normalize-package-data "^2.3.2"
|
||||||
path-type "^2.0.0"
|
path-type "^2.0.0"
|
||||||
|
|
||||||
|
read-pkg@^5.1.1:
|
||||||
|
version "5.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc"
|
||||||
|
integrity sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==
|
||||||
|
dependencies:
|
||||||
|
"@types/normalize-package-data" "^2.4.0"
|
||||||
|
normalize-package-data "^2.5.0"
|
||||||
|
parse-json "^5.0.0"
|
||||||
|
type-fest "^0.6.0"
|
||||||
|
|
||||||
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6:
|
"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6:
|
||||||
version "2.3.6"
|
version "2.3.6"
|
||||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
|
||||||
@ -15952,6 +15968,11 @@ type-fest@^0.5.2:
|
|||||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2"
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.5.2.tgz#d6ef42a0356c6cd45f49485c3b6281fc148e48a2"
|
||||||
integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==
|
integrity sha512-DWkS49EQKVX//Tbupb9TFa19c7+MK1XmzkrZUR8TAktmE/DizXoaoJV6TZ/tSIPXipqNiRI6CyAe7x69Jb6RSw==
|
||||||
|
|
||||||
|
type-fest@^0.6.0:
|
||||||
|
version "0.6.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b"
|
||||||
|
integrity sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==
|
||||||
|
|
||||||
type-fest@^0.8.0:
|
type-fest@^0.8.0:
|
||||||
version "0.8.0"
|
version "0.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.0.tgz#ee92ee2ec95479869dec66d17d9698666b90f29d"
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.0.tgz#ee92ee2ec95479869dec66d17d9698666b90f29d"
|
||||||
|
|||||||
20
yarn.lock
20
yarn.lock
@ -2020,17 +2020,16 @@ code-point-at@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
||||||
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
|
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
|
||||||
|
|
||||||
codecov@^3.6.4:
|
codecov@^3.6.5:
|
||||||
version "3.6.4"
|
version "3.6.5"
|
||||||
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.6.4.tgz#c993a58704ad5f15dcdd6aa3c3af22070c69eb18"
|
resolved "https://registry.yarnpkg.com/codecov/-/codecov-3.6.5.tgz#d73ce62e8a021f5249f54b073e6f2d6a513f172a"
|
||||||
integrity sha512-R9zEcTR5/IDLepdGUHAkRMZOIKhBE1NRGS1N2H96zhBOskhdW9Q22GtYYyecbZL1aheU00D2F21nNBGRISui0A==
|
integrity sha512-v48WuDMUug6JXwmmfsMzhCHRnhUf8O3duqXvltaYJKrO1OekZWpB/eH6iIoaxMl8Qli0+u3OxptdsBOYiD7VAQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
argv "0.0.2"
|
argv "0.0.2"
|
||||||
ignore-walk "3.0.3"
|
ignore-walk "3.0.3"
|
||||||
js-yaml "3.13.1"
|
js-yaml "3.13.1"
|
||||||
teeny-request "6.0.1"
|
teeny-request "6.0.1"
|
||||||
urlgrey "0.4.4"
|
urlgrey "0.4.4"
|
||||||
validator "12.2.0"
|
|
||||||
|
|
||||||
coffeeify@3.0.1:
|
coffeeify@3.0.1:
|
||||||
version "3.0.1"
|
version "3.0.1"
|
||||||
@ -3212,7 +3211,6 @@ extsprintf@^1.2.0:
|
|||||||
|
|
||||||
faker@Marak/faker.js#master:
|
faker@Marak/faker.js#master:
|
||||||
version "4.1.0"
|
version "4.1.0"
|
||||||
uid "3b2fa4aebccee52ae1bafc15d575061fb30c3cf1"
|
|
||||||
resolved "https://codeload.github.com/Marak/faker.js/tar.gz/3b2fa4aebccee52ae1bafc15d575061fb30c3cf1"
|
resolved "https://codeload.github.com/Marak/faker.js/tar.gz/3b2fa4aebccee52ae1bafc15d575061fb30c3cf1"
|
||||||
|
|
||||||
fast-deep-equal@^2.0.1:
|
fast-deep-equal@^2.0.1:
|
||||||
@ -5886,6 +5884,11 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
|
|||||||
hash-base "^3.0.0"
|
hash-base "^3.0.0"
|
||||||
inherits "^2.0.1"
|
inherits "^2.0.1"
|
||||||
|
|
||||||
|
rosie@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/rosie/-/rosie-2.0.1.tgz#c250c4787ce450b72aa9eff26509f68589814fa2"
|
||||||
|
integrity sha1-wlDEeHzkULcqqe/yZQn2hYmBT6I=
|
||||||
|
|
||||||
rsvp@^4.8.4:
|
rsvp@^4.8.4:
|
||||||
version "4.8.5"
|
version "4.8.5"
|
||||||
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
|
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
|
||||||
@ -6868,11 +6871,6 @@ validate-npm-package-license@^3.0.1:
|
|||||||
spdx-correct "^3.0.0"
|
spdx-correct "^3.0.0"
|
||||||
spdx-expression-parse "^3.0.0"
|
spdx-expression-parse "^3.0.0"
|
||||||
|
|
||||||
validator@12.2.0:
|
|
||||||
version "12.2.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/validator/-/validator-12.2.0.tgz#660d47e96267033fd070096c3b1a6f2db4380a0a"
|
|
||||||
integrity sha512-jJfE/DW6tIK1Ek8nCfNFqt8Wb3nzMoAbocBF6/Icgg1ZFSBpObdnwVY2jQj6qUqzhx5jc71fpvBWyLGO7Xl+nQ==
|
|
||||||
|
|
||||||
verror@1.10.0, verror@^1.9.0:
|
verror@1.10.0, verror@^1.9.0:
|
||||||
version "1.10.0"
|
version "1.10.0"
|
||||||
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
|
resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user