diff --git a/backend/src/middleware/validation/index.js b/backend/src/middleware/validation/index.js index 2a1bf0cfa..8fba13529 100644 --- a/backend/src/middleware/validation/index.js +++ b/backend/src/middleware/validation/index.js @@ -17,8 +17,8 @@ const validateUpdateComment = async (resolve, root, args, context, info) => { if (!args.content || content.length < COMMENT_MIN_LENGTH) { throw new UserInputError(`Comment must be at least ${COMMENT_MIN_LENGTH} character long!`) } - /* eslint-disable-next-line no-return-await */ - return await resolve(root, args, context, info) + + return resolve(root, args, context, info) } export default { diff --git a/backend/src/schema/resolvers/comments.spec.js b/backend/src/schema/resolvers/comments.spec.js index 0143e83f8..88cdbe37a 100644 --- a/backend/src/schema/resolvers/comments.spec.js +++ b/backend/src/schema/resolvers/comments.spec.js @@ -188,22 +188,24 @@ describe('CreateComment', () => { }) describe('ManageComments', () => { - let manageCommentsUserParams + let authorParams beforeEach(async () => { - manageCommentsUserParams = { + authorParams = { email: 'author@example.org', password: '1234', } - createCommentVariables = { + const asAuthor = Factory() + await asAuthor.create('User', authorParams) + await asAuthor.authenticateAs(authorParams) + await asAuthor.create('Post', { + id: 'p1', + content: 'Post to be commented', + }) + await asAuthor.create('Comment', { id: 'c456', postId: 'p1', - content: "I'm authorised to comment", - } - await factory.create('User', manageCommentsUserParams) - headers = await login(manageCommentsUserParams) - client = new GraphQLClient(host, { headers }) - await client.request(createPostMutation, createPostVariables) - await client.request(createCommentMutation, createCommentVariables) + content: 'Comment to be deleted', + }) }) describe('UpdateComment', () => { @@ -249,6 +251,11 @@ describe('ManageComments', () => { }) describe('authenticated as author', () => { + beforeEach(async () => { + headers = await login(authorParams) + client = new GraphQLClient(host, { headers }) + }) + it('updates the comment', async () => { const expected = { UpdateComment: { @@ -304,6 +311,11 @@ describe('ManageComments', () => { }) describe('authenticated as author', () => { + beforeEach(async () => { + headers = await login(authorParams) + client = new GraphQLClient(host, { headers }) + }) + it('deletes the comment', async () => { const expected = { DeleteComment: { diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 1fdfad7cf..7684c3f75 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -11,7 +11,7 @@