mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Update tests after backend validations
- Now a comment cannot be created without a post to associate it with
This commit is contained in:
parent
ad46c2d059
commit
4c09268f49
@ -16,6 +16,9 @@ const setupAuthenticateClient = (params) => {
|
|||||||
|
|
||||||
let createResource
|
let createResource
|
||||||
let authenticateClient
|
let authenticateClient
|
||||||
|
let createPostVariables
|
||||||
|
let createCommentVariables
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
createResource = () => {}
|
createResource = () => {}
|
||||||
authenticateClient = () => {
|
authenticateClient = () => {
|
||||||
@ -103,18 +106,21 @@ describe('disable', () => {
|
|||||||
variables = {
|
variables = {
|
||||||
id: 'c47'
|
id: 'c47'
|
||||||
}
|
}
|
||||||
|
createPostVariables = {
|
||||||
|
id: 'p3',
|
||||||
|
title: 'post to comment on',
|
||||||
|
content: 'please comment on me'
|
||||||
|
}
|
||||||
|
createCommentVariables = {
|
||||||
|
id: 'c47',
|
||||||
|
postId: 'p3',
|
||||||
|
content: 'this comment was created for this post'
|
||||||
|
}
|
||||||
createResource = async () => {
|
createResource = async () => {
|
||||||
await factory.create('User', { id: 'u45', email: 'commenter@example.org', password: '1234' })
|
await factory.create('User', { id: 'u45', email: 'commenter@example.org', password: '1234' })
|
||||||
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
const asAuthenticatedUser = await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
||||||
await Promise.all([
|
await asAuthenticatedUser.create('Post', createPostVariables)
|
||||||
factory.create('Post', { id: 'p3' }),
|
await asAuthenticatedUser.create('Comment', createCommentVariables)
|
||||||
factory.create('Comment', { id: 'c47', postId: 'p3', content: 'this comment was created for this post' })
|
|
||||||
])
|
|
||||||
|
|
||||||
await Promise.all([
|
|
||||||
factory.relate('Comment', 'Author', { from: 'u45', to: 'c47' })
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -277,17 +283,21 @@ describe('enable', () => {
|
|||||||
variables = {
|
variables = {
|
||||||
id: 'c456'
|
id: 'c456'
|
||||||
}
|
}
|
||||||
|
createPostVariables = {
|
||||||
|
id: 'p9',
|
||||||
|
title: 'post to comment on',
|
||||||
|
content: 'please comment on me'
|
||||||
|
}
|
||||||
|
createCommentVariables = {
|
||||||
|
id: 'c456',
|
||||||
|
postId: 'p9',
|
||||||
|
content: 'this comment was created for this post'
|
||||||
|
}
|
||||||
createResource = async () => {
|
createResource = async () => {
|
||||||
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
|
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
|
||||||
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
const asAuthenticatedUser = await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||||
await Promise.all([
|
await asAuthenticatedUser.create('Post', createPostVariables)
|
||||||
factory.create('Post', { id: 'p9' }),
|
await asAuthenticatedUser.create('Comment', createCommentVariables)
|
||||||
factory.create('Comment', { id: 'c456' })
|
|
||||||
])
|
|
||||||
await Promise.all([
|
|
||||||
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' })
|
|
||||||
])
|
|
||||||
|
|
||||||
const disableMutation = `
|
const disableMutation = `
|
||||||
mutation {
|
mutation {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ describe('report', () => {
|
|||||||
let headers
|
let headers
|
||||||
let returnedObject
|
let returnedObject
|
||||||
let variables
|
let variables
|
||||||
|
let createPostVariables
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
returnedObject = '{ description }'
|
returnedObject = '{ description }'
|
||||||
@ -128,8 +129,14 @@ describe('report', () => {
|
|||||||
|
|
||||||
describe('reported resource is a comment', () => {
|
describe('reported resource is a comment', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await factory.authenticateAs({ email: 'test@example.org', password: '1234' })
|
createPostVariables = {
|
||||||
await factory.create('Comment', { id: 'c34', content: 'Robert getting tired.' })
|
id: 'p1',
|
||||||
|
title: 'post to comment on',
|
||||||
|
content: 'please comment on me'
|
||||||
|
}
|
||||||
|
const asAuthenticatedUser = await factory.authenticateAs({ email: 'test@example.org', password: '1234' })
|
||||||
|
await asAuthenticatedUser.create('Post', createPostVariables)
|
||||||
|
await asAuthenticatedUser.create('Comment', { postId: 'p1', id: 'c34', content: 'Robert getting tired.' })
|
||||||
variables = { id: 'c34' }
|
variables = { id: 'c34' }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user