From 5dfd0f9ada8745bee75f635c876c551af8a1f0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 9 Mar 2020 09:54:43 +0100 Subject: [PATCH] Merge fixes and lint fixes --- backend/src/db/seed.js | 1 - .../notifications/notificationsMiddleware.js | 1 - .../notificationsMiddleware.spec.js | 5 +- backend/src/schema/resolvers/notifications.js | 2 +- .../schema/resolvers/notifications.spec.js | 66 +------------------ .../components/Notification/Notification.vue | 28 ++++---- .../NotificationList/NotificationList.spec.js | 1 - webapp/components/UserTeaser/UserTeaser.vue | 1 - 8 files changed, 18 insertions(+), 87 deletions(-) diff --git a/backend/src/db/seed.js b/backend/src/db/seed.js index 00d9a9f46..0de797314 100644 --- a/backend/src/db/seed.js +++ b/backend/src/db/seed.js @@ -822,7 +822,6 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] louie.relateTo(p10, 'shouted'), ]) - const [ reportAgainstDagobert, reportAgainstHuey, diff --git a/backend/src/middleware/notifications/notificationsMiddleware.js b/backend/src/middleware/notifications/notificationsMiddleware.js index 34ff69b61..a94832725 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.js @@ -22,7 +22,6 @@ const handleContentDataOfPost = async (resolve, root, args, context, resolveInfo return post } - const handleContentDataOfComment = async (resolve, root, args, context, resolveInfo) => { const { content } = args let idsOfUsers = extractMentionedUsers(content) diff --git a/backend/src/middleware/notifications/notificationsMiddleware.spec.js b/backend/src/middleware/notifications/notificationsMiddleware.spec.js index 32912a42a..6da74ee22 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.spec.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.spec.js @@ -777,10 +777,7 @@ describe('notifications', () => { read: false, }, }), - ).resolves.toMatchObject({ - data: { notifications: [] }, - errors: undefined, - }) + ).resolves.toEqual(expected) }) it('does not publish `NOTIFICATION_ADDED` to authenticated user', async () => { diff --git a/backend/src/schema/resolvers/notifications.js b/backend/src/schema/resolvers/notifications.js index 0d14da7c8..ac038b494 100644 --- a/backend/src/schema/resolvers/notifications.js +++ b/backend/src/schema/resolvers/notifications.js @@ -73,7 +73,7 @@ export default { } }, }, - + Mutation: { markAsRead: async (parent, args, context, resolveInfo) => { const { user: currentUser } = context diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index cdf17d9fe..7236a0972 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -37,60 +37,6 @@ afterEach(async () => { describe('given some notifications', () => { beforeEach(async () => { const categoryIds = ['cat1'] - // Wolle author = await factory.create('User', { id: 'author' }) - // user = await factory.create('User', { id: 'you' }) - // const [neighbor, badWomen] = await Promise.all([ - // factory.create('User', { id: 'neighbor' }), - // factory.create('User', { id: 'badWomen', name: 'Mrs. Badwomen' }), - // factory.create('Category', { id: 'cat1' }), - // ]) - // const [post1, post2, post3, post4] = await Promise.all([ - // factory.create('Post', { author, id: 'p1', categoryIds, content: 'Not for you' }), - // factory.create('Post', { - // author, - // id: 'p2', - // categoryIds, - // content: 'Already seen post mention', - // }), - // factory.create('Post', { - // author, - // id: 'p3', - // categoryIds, - // content: 'You have been mentioned in a post', - // }), - // factory.create('Post', { - // author, - // id: 'p4', - // categoryIds, - // title: 'Bad Post', - // content: 'I am bad content !!!', - // }), - // ]) - // const [comment1, comment2, comment3, comment4] = await Promise.all([ - // factory.create('Comment', { - // author, - // postId: 'p3', - // id: 'c1', - // content: 'You have seen this comment mentioning already', - // }), - // factory.create('Comment', { - // author, - // postId: 'p3', - // id: 'c2', - // content: 'You have been mentioned in a comment', - // }), - // factory.create('Comment', { - // author, - // postId: 'p3', - // id: 'c3', - // content: 'Somebody else was mentioned in a comment', - // }), - // factory.create('Comment', { - // author, - // postId: 'p4', - // id: 'c4', - // content: 'I am harassing content in a harassing comment to a bad post !!!', - // }), author = await Factory.build('user', { id: 'author' }) user = await Factory.build('user', { id: 'you' }) const [neighbor, badWomen] = await Promise.all([ @@ -222,15 +168,9 @@ describe('given some notifications', () => { // report notifications const [reportOnUser, reportOnPost, reportOnComment] = await Promise.all([ - factory.create('Report', { - id: 'reportOnUser', - }), - factory.create('Report', { - id: 'reportOnPost', - }), - factory.create('Report', { - id: 'reportOnComment', - }), + Factory.build('report', { id: 'reportOnUser' }), + Factory.build('report', { id: 'reportOnPost' }), + Factory.build('report', { id: 'reportOnComment' }), ]) await Promise.all([ reportOnUser.relateTo(user, 'filed', { diff --git a/webapp/components/Notification/Notification.vue b/webapp/components/Notification/Notification.vue index 2efa24240..121965a0f 100644 --- a/webapp/components/Notification/Notification.vue +++ b/webapp/components/Notification/Notification.vue @@ -19,7 +19,7 @@ --> - @@ -103,19 +103,17 @@ :user="notificationData.user" />

- {{ $t(`notifications.comment`) }}: + + {{ $t(`notifications.comment`) }}: + {{ notificationData.contentExcerpt | removeHtml }}

- - {{ $t(`notifications.report.category`) }}: - + {{ $t(`notifications.report.category`) }}: {{ $t('report.reason.category.options.' + notificationData.report.reasonCategory) }}
- - {{ $t(`notifications.report.description`) }}: - + {{ $t(`notifications.report.description`) }}: