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 authenticateClient
|
||||
let createPostVariables
|
||||
let createCommentVariables
|
||||
|
||||
beforeEach(() => {
|
||||
createResource = () => {}
|
||||
authenticateClient = () => {
|
||||
@ -103,18 +106,21 @@ describe('disable', () => {
|
||||
variables = {
|
||||
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 () => {
|
||||
await factory.create('User', { id: 'u45', email: 'commenter@example.org', password: '1234' })
|
||||
await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
||||
await Promise.all([
|
||||
factory.create('Post', { id: 'p3' }),
|
||||
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' })
|
||||
])
|
||||
const asAuthenticatedUser = await factory.authenticateAs({ email: 'commenter@example.org', password: '1234' })
|
||||
await asAuthenticatedUser.create('Post', createPostVariables)
|
||||
await asAuthenticatedUser.create('Comment', createCommentVariables)
|
||||
}
|
||||
})
|
||||
|
||||
@ -277,17 +283,21 @@ describe('enable', () => {
|
||||
variables = {
|
||||
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 () => {
|
||||
await factory.create('User', { id: 'u123', email: 'author@example.org', password: '1234' })
|
||||
await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||
await Promise.all([
|
||||
factory.create('Post', { id: 'p9' }),
|
||||
factory.create('Comment', { id: 'c456' })
|
||||
])
|
||||
await Promise.all([
|
||||
factory.relate('Comment', 'Author', { from: 'u123', to: 'c456' })
|
||||
])
|
||||
const asAuthenticatedUser = await factory.authenticateAs({ email: 'author@example.org', password: '1234' })
|
||||
await asAuthenticatedUser.create('Post', createPostVariables)
|
||||
await asAuthenticatedUser.create('Comment', createCommentVariables)
|
||||
|
||||
const disableMutation = `
|
||||
mutation {
|
||||
|
||||
@ -9,6 +9,7 @@ describe('report', () => {
|
||||
let headers
|
||||
let returnedObject
|
||||
let variables
|
||||
let createPostVariables
|
||||
|
||||
beforeEach(async () => {
|
||||
returnedObject = '{ description }'
|
||||
@ -128,8 +129,14 @@ describe('report', () => {
|
||||
|
||||
describe('reported resource is a comment', () => {
|
||||
beforeEach(async () => {
|
||||
await factory.authenticateAs({ email: 'test@example.org', password: '1234' })
|
||||
await factory.create('Comment', { id: 'c34', content: 'Robert getting tired.' })
|
||||
createPostVariables = {
|
||||
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' }
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user