mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix failing tests, refactor
- due to changes made to comments factories, which caused failures - to use new custom CreateComment resolver syntax to relate a comment to post by passing in the postId
This commit is contained in:
parent
f4744fa513
commit
0149f30f5f
@ -23,21 +23,19 @@ beforeAll(async () => {
|
|||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('Comment', { id: 'c2', content: 'Enabled comment on public post' })
|
factory.create('Comment', { id: 'c2', postId: 'p3', content: 'Enabled comment on public post' })
|
||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.relate('Comment', 'Author', { from: 'u1', to: 'c2' }),
|
factory.relate('Comment', 'Author', { from: 'u1', to: 'c2' })
|
||||||
factory.relate('Comment', 'Post', { from: 'c2', to: 'p3' })
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const asTroll = Factory()
|
const asTroll = Factory()
|
||||||
await asTroll.authenticateAs({ email: 'troll@example.org', password: '1234' })
|
await asTroll.authenticateAs({ email: 'troll@example.org', password: '1234' })
|
||||||
await asTroll.create('Post', { id: 'p2', title: 'Disabled post', content: 'This is an offensive post content', image: '/some/offensive/image.jpg', deleted: false })
|
await asTroll.create('Post', { id: 'p2', title: 'Disabled post', content: 'This is an offensive post content', image: '/some/offensive/image.jpg', deleted: false })
|
||||||
await asTroll.create('Comment', { id: 'c1', content: 'Disabled comment' })
|
await asTroll.create('Comment', { id: 'c1', postId: 'p3', content: 'Disabled comment' })
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
asTroll.relate('Comment', 'Author', { from: 'u2', to: 'c1' }),
|
asTroll.relate('Comment', 'Author', { from: 'u2', to: 'c1' })
|
||||||
asTroll.relate('Comment', 'Post', { from: 'c1', to: 'p3' })
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const asModerator = Factory()
|
const asModerator = Factory()
|
||||||
|
|||||||
@ -109,11 +109,11 @@ describe('disable', () => {
|
|||||||
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.create('Post', { id: 'p3' }),
|
factory.create('Post', { id: 'p3' }),
|
||||||
factory.create('Comment', { id: 'c47' })
|
factory.create('Comment', { id: 'c47', postId: 'p3', content: 'this comment was created for this post' })
|
||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.relate('Comment', 'Author', { from: 'u45', to: 'c47' }),
|
factory.relate('Comment', 'Author', { from: 'u45', to: 'c47' })
|
||||||
factory.relate('Comment', 'Post', { from: 'c47', to: 'p3' })
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -286,8 +286,7 @@ describe('enable', () => {
|
|||||||
factory.create('Comment', { id: 'c456' })
|
factory.create('Comment', { id: 'c456' })
|
||||||
])
|
])
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' }),
|
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' })
|
||||||
factory.relate('Comment', 'Post', { from: 'c456', to: 'p9' })
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const disableMutation = `
|
const disableMutation = `
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
import faker from 'faker'
|
import faker from 'faker'
|
||||||
|
import uuid from 'uuid/v4'
|
||||||
|
|
||||||
export default function (params) {
|
export default function (params) {
|
||||||
const {
|
const {
|
||||||
|
id = uuid(),
|
||||||
postId = 'p6',
|
postId = 'p6',
|
||||||
content = [
|
content = [
|
||||||
faker.lorem.sentence(),
|
faker.lorem.sentence(),
|
||||||
@ -12,6 +14,7 @@ export default function (params) {
|
|||||||
return `
|
return `
|
||||||
mutation {
|
mutation {
|
||||||
CreateComment(
|
CreateComment(
|
||||||
|
id: "${id}"
|
||||||
postId: "${postId}",
|
postId: "${postId}",
|
||||||
content: "${content}"
|
content: "${content}"
|
||||||
) { id, content }
|
) { id, content }
|
||||||
|
|||||||
@ -185,45 +185,33 @@ import Factory from './factories'
|
|||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
f.create('Comment', { id: 'c1' }),
|
f.create('Comment', { id: 'c1', postId: 'p1' }),
|
||||||
f.create('Comment', { id: 'c2' }),
|
f.create('Comment', { id: 'c2', postId: 'p1' }),
|
||||||
f.create('Comment', { id: 'c3' }),
|
f.create('Comment', { id: 'c3', postId: 'p3' }),
|
||||||
f.create('Comment', { id: 'c4' }),
|
f.create('Comment', { id: 'c4', postId: 'p2' }),
|
||||||
f.create('Comment', { id: 'c5' }),
|
f.create('Comment', { id: 'c5', postId: 'p3' }),
|
||||||
f.create('Comment', { id: 'c6' }),
|
f.create('Comment', { id: 'c6', postId: 'p4' }),
|
||||||
f.create('Comment', { id: 'c7' }),
|
f.create('Comment', { id: 'c7', postId: 'p2' }),
|
||||||
f.create('Comment', { id: 'c8' }),
|
f.create('Comment', { id: 'c8', postId: 'p15' }),
|
||||||
f.create('Comment', { id: 'c9' }),
|
f.create('Comment', { id: 'c9', postId: 'p15' }),
|
||||||
f.create('Comment', { id: 'c10' }),
|
f.create('Comment', { id: 'c10', postId: 'p15' }),
|
||||||
f.create('Comment', { id: 'c11' }),
|
f.create('Comment', { id: 'c11', postId: 'p15' }),
|
||||||
f.create('Comment', { id: 'c12' })
|
f.create('Comment', { id: 'c12', postId: 'p15' })
|
||||||
])
|
])
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
f.relate('Comment', 'Author', { from: 'u3', to: 'c1' }),
|
f.relate('Comment', 'Author', { from: 'u3', to: 'c1' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c1', to: 'p1' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u1', to: 'c2' }),
|
f.relate('Comment', 'Author', { from: 'u1', to: 'c2' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c2', to: 'p1' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u1', to: 'c3' }),
|
f.relate('Comment', 'Author', { from: 'u1', to: 'c3' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c3', to: 'p3' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u4', to: 'c4' }),
|
f.relate('Comment', 'Author', { from: 'u4', to: 'c4' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c4', to: 'p2' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u4', to: 'c5' }),
|
f.relate('Comment', 'Author', { from: 'u4', to: 'c5' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c5', to: 'p3' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u3', to: 'c6' }),
|
f.relate('Comment', 'Author', { from: 'u3', to: 'c6' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c6', to: 'p4' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u2', to: 'c7' }),
|
f.relate('Comment', 'Author', { from: 'u2', to: 'c7' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c7', to: 'p2' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u5', to: 'c8' }),
|
f.relate('Comment', 'Author', { from: 'u5', to: 'c8' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c8', to: 'p15' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u6', to: 'c9' }),
|
f.relate('Comment', 'Author', { from: 'u6', to: 'c9' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c9', to: 'p15' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u7', to: 'c10' }),
|
f.relate('Comment', 'Author', { from: 'u7', to: 'c10' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c10', to: 'p15' }),
|
|
||||||
f.relate('Comment', 'Author', { from: 'u5', to: 'c11' }),
|
f.relate('Comment', 'Author', { from: 'u5', to: 'c11' }),
|
||||||
f.relate('Comment', 'Post', { from: 'c11', to: 'p15' }),
|
f.relate('Comment', 'Author', { from: 'u6', to: 'c12' })
|
||||||
f.relate('Comment', 'Author', { from: 'u6', to: 'c12' }),
|
|
||||||
f.relate('Comment', 'Post', { from: 'c12', to: 'p15' })
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const disableMutation = 'mutation($id: ID!) { disable(id: $id) }'
|
const disableMutation = 'mutation($id: ID!) { disable(id: $id) }'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user