Refine notification behaviour:

If you mark a post or comment as read even though you already marked the
corresponding notification as read, then you receive `null`.
This commit is contained in:
roschaefer 2019-08-29 21:59:23 +02:00
parent 2846a6a8d3
commit 3f121c7c4d
2 changed files with 15 additions and 1 deletions

View File

@ -62,7 +62,7 @@ export default {
let notification
try {
const cypher = `
MATCH (resource {id: $resourceId})-[notification:NOTIFIED]->(user:User {id:$id})
MATCH (resource {id: $resourceId})-[notification:NOTIFIED {read: FALSE}]->(user:User {id:$id})
SET notification.read = TRUE
RETURN resource, notification, user
`

View File

@ -265,6 +265,20 @@ describe('given some notifications', () => {
},
})
})
describe('but notification was already marked as read', () => {
beforeEach(async () => {
variables = {
...variables,
id: 'p2',
}
})
it('returns null', async () => {
const response = await mutate({ mutation: markAsReadMutation, variables })
expect(response.data.markAsRead).toEqual(null)
expect(response.errors).toBeUndefined()
})
})
})
describe('on a comment', () => {