mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Implement delete of comments when post is deleted
This commit is contained in:
parent
1b5d91bfd2
commit
660e3434aa
@ -146,10 +146,12 @@ export default {
|
||||
const transactionRes = await session.run(
|
||||
`
|
||||
MATCH (post:Post {id: $postId})
|
||||
OPTIONAL MATCH (post)<-[:COMMENTS]-(comment:Comment)
|
||||
SET post.deleted = TRUE
|
||||
SET post.image = 'DELETED'
|
||||
SET post.content = 'DELETED'
|
||||
SET post.contentExcerpt = 'DELETED'
|
||||
SET comment.deleted = TRUE
|
||||
RETURN post
|
||||
`,
|
||||
{ postId: args.id },
|
||||
|
||||
@ -417,6 +417,11 @@ describe('DeletePost', () => {
|
||||
content
|
||||
contentExcerpt
|
||||
image
|
||||
comments {
|
||||
deleted
|
||||
content
|
||||
contentExcerpt
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -466,6 +471,7 @@ describe('DeletePost', () => {
|
||||
content: 'DELETED',
|
||||
contentExcerpt: 'DELETED',
|
||||
image: 'DELETED',
|
||||
comments: [],
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -474,7 +480,40 @@ describe('DeletePost', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it.todo('marks all comments as deleted')
|
||||
describe('if there are comments on the post', () => {
|
||||
beforeEach(async () => {
|
||||
await factory.create('Comment', {
|
||||
postId: 'p4711',
|
||||
content: 'to be deleted comment content',
|
||||
contentExcerpt: 'to be deleted comment content',
|
||||
})
|
||||
})
|
||||
|
||||
it('marks the comments as deleted', async () => {
|
||||
const expected = {
|
||||
data: {
|
||||
DeletePost: {
|
||||
id: 'p4711',
|
||||
deleted: true,
|
||||
content: 'DELETED',
|
||||
contentExcerpt: 'DELETED',
|
||||
image: 'DELETED',
|
||||
comments: [
|
||||
{
|
||||
deleted: true,
|
||||
// Should we black out the comment content in the database, too?
|
||||
content: 'to be deleted comment content',
|
||||
contentExcerpt: 'to be deleted comment content',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
await expect(mutate({ mutation: deletePostMutation, variables })).resolves.toMatchObject(
|
||||
expected,
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user