diff --git a/backend/package.json b/backend/package.json index 106e52a7c..1fdca3a28 100644 --- a/backend/package.json +++ b/backend/package.json @@ -69,22 +69,22 @@ "linkifyjs": "~2.1.8", "lodash": "~4.17.14", "merge-graphql-schemas": "^1.7.6", - "metascraper": "^5.11.4", + "metascraper": "^5.11.6", "metascraper-audio": "^5.11.1", - "metascraper-author": "^5.11.1", + "metascraper-author": "^5.11.6", "metascraper-clearbit-logo": "^5.3.0", "metascraper-date": "^5.11.1", "metascraper-description": "^5.11.1", "metascraper-image": "^5.11.1", "metascraper-lang": "^5.11.1", "metascraper-lang-detector": "^4.10.2", - "metascraper-logo": "^5.11.1", + "metascraper-logo": "^5.11.6", "metascraper-publisher": "^5.11.1", "metascraper-soundcloud": "^5.11.5", "metascraper-title": "^5.11.1", - "metascraper-url": "^5.11.1", + "metascraper-url": "^5.11.6", "metascraper-video": "^5.11.1", - "metascraper-youtube": "^5.11.1", + "metascraper-youtube": "^5.11.6", "migrate": "^1.6.2", "minimatch": "^3.0.4", "mustache": "^4.0.0", diff --git a/backend/src/db/seed.js b/backend/src/db/seed.js index 0de797314..00d9a9f46 100644 --- a/backend/src/db/seed.js +++ b/backend/src/db/seed.js @@ -822,6 +822,7 @@ 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 a94832725..34ff69b61 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.js @@ -22,6 +22,7 @@ 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 632e9de65..32912a42a 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.spec.js +++ b/backend/src/middleware/notifications/notificationsMiddleware.spec.js @@ -777,7 +777,26 @@ describe('notifications', () => { read: false, }, }), - ).resolves.toEqual(expected) + ).resolves.toMatchObject({ + data: { notifications: [] }, + errors: undefined, + }) + }) + + it('does not publish `NOTIFICATION_ADDED` to authenticated user', async () => { + await createCommentOnPostAction() + expect(publishSpy).toHaveBeenCalledWith( + 'NOTIFICATION_ADDED', + expect.objectContaining({ + notificationAdded: expect.objectContaining({ + reason: 'commented_on_post', + to: expect.objectContaining({ + id: 'postAuthor', // that's expected, it's not me but the post author + }), + }), + }), + ) + expect(publishSpy).toHaveBeenCalledTimes(1) }) }) }) diff --git a/backend/src/schema/resolvers/notifications.js b/backend/src/schema/resolvers/notifications.js index 1b6dc3107..0d14da7c8 100644 --- a/backend/src/schema/resolvers/notifications.js +++ b/backend/src/schema/resolvers/notifications.js @@ -73,6 +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 161e98dec..cdf17d9fe 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -37,7 +37,7 @@ afterEach(async () => { describe('given some notifications', () => { beforeEach(async () => { const categoryIds = ['cat1'] - // author = await factory.create('User', { id: 'author' }) + // 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' }), diff --git a/backend/yarn.lock b/backend/yarn.lock index 30c16a73e..d9ae7c5c6 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1162,10 +1162,10 @@ url-regex "~4.1.1" video-extensions "~1.1.0" -"@metascraper/helpers@^5.11.1": - version "5.11.1" - resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.11.1.tgz#227fdd0caf1d33f4b24a85298a355ce7ebb451df" - integrity sha512-oES/e6bwKBlT7WGa2ni3xbJMDx2rbFxSzbUhRX8D+Kylb8H2ThP07c7f+VXMPXWx5CPrNMai/Oyp5IczCf3v8g== +"@metascraper/helpers@^5.11.1", "@metascraper/helpers@^5.11.6": + version "5.11.6" + resolved "https://registry.yarnpkg.com/@metascraper/helpers/-/helpers-5.11.6.tgz#2fef2f420f06f4f8903cc6f699ccb79195950a60" + integrity sha512-DKCJMz5Q4wrBPZVfJdeNarmW2WHm3Y7D6M78KKA/D0mcXPikKLoiBxjyPtjc5tEE/5er+PYFijDBmyTT60M2bg== dependencies: audio-extensions "0.0.0" chrono-node "~1.4.3" @@ -6230,12 +6230,12 @@ metascraper-audio@^5.11.1: dependencies: "@metascraper/helpers" "^5.11.1" -metascraper-author@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/metascraper-author/-/metascraper-author-5.11.1.tgz#8abe6bcc21f5a72e481d6b4ff33b008ec740fdb0" - integrity sha512-VkduGrQd3baLoypCZV0zJwutdj7Dqpj3Oi8sdM6wSo0AJDiUD1oUbeQafJ6W616zqXFIeEANS35gARBFtHupog== +metascraper-author@^5.11.6: + version "5.11.6" + resolved "https://registry.yarnpkg.com/metascraper-author/-/metascraper-author-5.11.6.tgz#45002b550f26fa229a9e7460989ff3efe114cf27" + integrity sha512-OtxpUJR8h0A0J2pUdZrreWtDATJkWZEGO7Ru6aNiMpU4Otk6H5v6wFHR4S41rHVbrfXZzj2hiQV2RcZOu+3JPg== dependencies: - "@metascraper/helpers" "^5.11.1" + "@metascraper/helpers" "^5.11.6" lodash "~4.17.15" metascraper-clearbit-logo@^5.3.0: @@ -6282,12 +6282,12 @@ metascraper-lang@^5.11.1: dependencies: "@metascraper/helpers" "^5.11.1" -metascraper-logo@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/metascraper-logo/-/metascraper-logo-5.11.1.tgz#09a2c3c3c29a8447efbf4971370a6ec68494c1f5" - integrity sha512-B2QwyNea5dIZc3oSm2pfxEPaMeDeri0kLOumgNayGykSnqNHcCNpGhJUKxh6oeWOELcWc8nPv74a96xvz9YX3Q== +metascraper-logo@^5.11.6: + version "5.11.6" + resolved "https://registry.yarnpkg.com/metascraper-logo/-/metascraper-logo-5.11.6.tgz#c0f08939fd72021d015cc16e0bb43dc41d79dc5f" + integrity sha512-H1kumbrf+I4Ogwm7fFhSZDJU8STRMa7kg77/wnmOK+1sirH8d2NOzTrEhDdoRMmpGYiU3XNjfukvZJbqPu2mvg== dependencies: - "@metascraper/helpers" "^5.11.1" + "@metascraper/helpers" "^5.11.6" metascraper-publisher@^5.11.1: version "5.11.1" @@ -6312,12 +6312,12 @@ metascraper-title@^5.11.1: "@metascraper/helpers" "^5.11.1" lodash "~4.17.15" -metascraper-url@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/metascraper-url/-/metascraper-url-5.11.1.tgz#c0687c09889d81cf9317083eab289067328b4ca6" - integrity sha512-+BMkCEQA3+6gwklgeNclhVImDfmwPKMzVNzM2KcioD7sRUpm6+7cbcPFcf1VhGENxxz1TmHY2ZaLdRat/lsRDg== +metascraper-url@^5.11.6: + version "5.11.6" + resolved "https://registry.yarnpkg.com/metascraper-url/-/metascraper-url-5.11.6.tgz#ecd9b5d4898103b9b1dfbd1f5bc1359ebb7f3b81" + integrity sha512-kQ/CP7AZIsZXFai5PfrvhwSIrwYCngCXZIucmoas2V6hR0wEXkkPjISCMKmiFDvmBZMrVdzJ2xGFI0nhKAgfQw== dependencies: - "@metascraper/helpers" "^5.11.1" + "@metascraper/helpers" "^5.11.6" metascraper-video@^5.11.1: version "5.11.1" @@ -6327,22 +6327,22 @@ metascraper-video@^5.11.1: "@metascraper/helpers" "^5.11.1" lodash "~4.17.15" -metascraper-youtube@^5.11.1: - version "5.11.1" - resolved "https://registry.yarnpkg.com/metascraper-youtube/-/metascraper-youtube-5.11.1.tgz#475f2d7e9a4866fabaa955dc4f9f20015e20780e" - integrity sha512-Z7p/grewIuYhJKlemW28CN8q1w6sD6CvQaIS/ACvnU3sSoiWbiblfb4iQwP1NKpwGuuw/Vp+9kvauFYbojLh7w== +metascraper-youtube@^5.11.6: + version "5.11.6" + resolved "https://registry.yarnpkg.com/metascraper-youtube/-/metascraper-youtube-5.11.6.tgz#3135a2312bab2b6cd8d9575672ea0d521528b439" + integrity sha512-NUkPxNoxg7IfyBCmfy27guTRfMiTmNUlTv7iJgrQJ/WLV7FSzqZ16qioLf7aSSY2/H/LaCClo0Dzeb3qdHKn+g== dependencies: - "@metascraper/helpers" "^5.11.1" + "@metascraper/helpers" "^5.11.6" get-video-id "~3.1.4" is-reachable "~4.0.0" p-locate "~4.1.0" -metascraper@^5.11.4: - version "5.11.4" - resolved "https://registry.yarnpkg.com/metascraper/-/metascraper-5.11.4.tgz#91f13c9f39fd824cdd9bfe8d771576b9b856598e" - integrity sha512-GNYAwYuGwSm3P0p2Yi3OgYqttoYj1wgUDqbfnleN7tQRMKnTFinYw6YNYVfOniuNYl+CiJH4gg9ll2QpG8tzTw== +metascraper@^5.11.6: + version "5.11.6" + resolved "https://registry.yarnpkg.com/metascraper/-/metascraper-5.11.6.tgz#0dcae3fadfb0a40e5b9dcd0ccc34c84d7f7b821f" + integrity sha512-6rVHvzxocYdjctlW2Pi7NSxP9MSufcBZHgO66swfzkx/iEEfAKGUPUjbAOqjf9BeTw5zL8Oi8R2lBgtFinN/Tw== dependencies: - "@metascraper/helpers" "^5.11.1" + "@metascraper/helpers" "^5.11.6" cheerio "~1.0.0-rc.3" cheerio-advanced-selectors "~2.0.1" lodash "~4.17.15" diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 35c357366..550649524 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -396,6 +396,7 @@ When("open the notification menu and click on the first item", () => { }); }); + Then("see {int} unread notifications in the top menu", count => { cy.get(".notifications-menu").should("contain", count); }); diff --git a/webapp/components/Notification/Notification.spec.js b/webapp/components/Notification/Notification.spec.js index 5f9b40e3e..36e0e8d9d 100644 --- a/webapp/components/Notification/Notification.spec.js +++ b/webapp/components/Notification/Notification.spec.js @@ -252,7 +252,7 @@ describe('Notification', () => { it('has no class "read"', () => { wrapper = Wrapper() - expect(wrapper.classes()).not.toContain('read') + expect(wrapper.classes()).not.toContain('--read') }) describe('that is read', () => { @@ -261,8 +261,8 @@ describe('Notification', () => { wrapper = Wrapper() }) - it('has class "read"', () => { - expect(wrapper.classes()).toContain('read') + it('has class "--read"', () => { + expect(wrapper.classes()).toContain('--read') }) }) }) diff --git a/webapp/components/Notification/Notification.vue b/webapp/components/Notification/Notification.vue index b7063dc7b..2efa24240 100644 --- a/webapp/components/Notification/Notification.vue +++ b/webapp/components/Notification/Notification.vue @@ -175,6 +175,7 @@ export default { // .notification-content-header-text { // font-weight: 700; // margin-right: 0.1rem; + .notification { margin-bottom: $space-base; diff --git a/webapp/components/NotificationList/NotificationList.spec.js b/webapp/components/NotificationList/NotificationList.spec.js index 35625ecba..a68e929ab 100644 --- a/webapp/components/NotificationList/NotificationList.spec.js +++ b/webapp/components/NotificationList/NotificationList.spec.js @@ -73,6 +73,7 @@ describe('NotificationList.vue', () => { describe('click on a notification', () => { beforeEach(() => { + wrapper.find('.notification .notifications-card').trigger('click') }) diff --git a/webapp/components/UserTeaser/UserTeaser.vue b/webapp/components/UserTeaser/UserTeaser.vue index 05d180623..448eed787 100644 --- a/webapp/components/UserTeaser/UserTeaser.vue +++ b/webapp/components/UserTeaser/UserTeaser.vue @@ -125,3 +125,4 @@ export default { } } + diff --git a/webapp/locales/de.json b/webapp/locales/de.json index befed94eb..5e6b65a53 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -450,6 +450,7 @@ } }, "notifications": { + "comment": "Kommentar", "content": "Inhalt", "empty": "Bedaure, du hast momentan keinerlei Benachrichtigungen.", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index d704d1fb3..cd96bbe64 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -474,7 +474,8 @@ "category": "Report category", "description": "Description", "name": "Report" - }, + }, + "title": "Notifications", "user": "User" }, "post": { diff --git a/webapp/package.json b/webapp/package.json index fee5b792c..05f28e751 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -70,7 +70,7 @@ "apollo-client": "~2.6.8", "cookie-universal-nuxt": "~2.1.2", "cropperjs": "^1.5.5", - "cross-env": "~7.0.1", + "cross-env": "~7.0.2", "date-fns": "2.10.0", "express": "~4.17.1", "graphql": "~14.6.0", @@ -88,7 +88,7 @@ "v-tooltip": "~2.0.3", "validator": "^12.2.0", "vue-count-to": "~1.0.13", - "vue-infinite-loading": "^2.4.4", + "vue-infinite-loading": "^2.4.5", "vue-izitoast": "^1.2.1", "vue-scrollto": "^2.17.1", "vue-sweetalert-icons": "~4.2.0", diff --git a/webapp/yarn.lock b/webapp/yarn.lock index 2e03482a0..e352917b1 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -6158,10 +6158,10 @@ cropperjs@^1.5.5: resolved "https://registry.yarnpkg.com/cropperjs/-/cropperjs-1.5.6.tgz#82faf432bec709d828f2f7a96d1179198edaf0e2" integrity sha512-eAgWf4j7sNJIG329qUHIFi17PSV0VtuWyAu9glZSgu/KlQSrfTQOC2zAz+jHGa5fAB+bJldEnQwvJEaJ8zRf5A== -cross-env@~7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.1.tgz#c8e03412ea0e1370fe3f0066929a70b8e1e90c39" - integrity sha512-1+DmLosu38kC4s1H4HzNkcolwdANifu9+5bE6uKQCV4L6jvVdV9qdRAk8vV3GoWRe0x4z+K2fFhgoDMqwNsPqQ== +cross-env@~7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.2.tgz#bd5ed31339a93a3418ac4f3ca9ca3403082ae5f9" + integrity sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw== dependencies: cross-spawn "^7.0.1" @@ -16479,10 +16479,10 @@ vue-hot-reload-api@^2.3.0: resolved "https://registry.yarnpkg.com/vue-hot-reload-api/-/vue-hot-reload-api-2.3.3.tgz#2756f46cb3258054c5f4723de8ae7e87302a1ccf" integrity sha512-KmvZVtmM26BQOMK1rwUZsrqxEGeKiYSZGA7SNWE6uExx8UX/cj9hq2MRV/wWC3Cq6AoeDGk57rL9YMFRel/q+g== -vue-infinite-loading@^2.4.4: - version "2.4.4" - resolved "https://registry.yarnpkg.com/vue-infinite-loading/-/vue-infinite-loading-2.4.4.tgz#8a9defb9ceeea797c057cb36bdf558a4b2ce409f" - integrity sha512-eIFBcyKqkivtsDDq7Ee5ybDJVGLxIzU1NcBJCHG7Zx9Ic66QEGzSPs2OPJlGUdtu0/RS7KpUER35ZP/a7FdSOg== +vue-infinite-loading@^2.4.5: + version "2.4.5" + resolved "https://registry.yarnpkg.com/vue-infinite-loading/-/vue-infinite-loading-2.4.5.tgz#cc20fd40af7f20188006443c99b60470cf1de1b3" + integrity sha512-xhq95Mxun060bRnsOoLE2Be6BR7jYwuC89kDe18+GmCLVrRA/dU0jrGb12Xu6NjmKs+iTW0AA6saSEmEW4cR7g== vue-izitoast@^1.2.1: version "1.2.1"