diff --git a/.vscode/settings.json b/.vscode/settings.json index 9acbf50bd..2091e5e03 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,4 +9,4 @@ ], "editor.formatOnSave": false, "eslint.autoFixOnSave": true -} \ No newline at end of file +} diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index d712ee9b1..a25200667 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -351,10 +351,12 @@ When("I log in with the following credentials:", table => { }); When("open the notification menu and click on the first item", () => { - cy.get(".notifications-menu").click(); + cy.get(".notifications-menu").invoke('show').click(); // "invoke('show')" because of the delay for show the menu cy.get(".notification-mention-post") .first() - .click(); + .click({ + force: true + }); }); Then("see {int} unread notifications in the top menu", count => { diff --git a/cypress/integration/notifications/Mentions.feature b/cypress/integration/notifications/Mentions.feature index d3c123863..7523e3d05 100644 --- a/cypress/integration/notifications/Mentions.feature +++ b/cypress/integration/notifications/Mentions.feature @@ -1,4 +1,4 @@ -Feature: Notifications for a mentions +Feature: Notification for a mention As a user I want to be notified if sb. mentions me in a post or comment In order join conversations about or related to me diff --git a/webapp/components/notifications/Notification/Notification.spec.js b/webapp/components/notifications/Notification/Notification.spec.js index 9ca47e7a0..54e6b4ab3 100644 --- a/webapp/components/notifications/Notification/Notification.spec.js +++ b/webapp/components/notifications/Notification/Notification.spec.js @@ -69,16 +69,16 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.commented_on_post', + 'notifications.reason.commented_on_post', ) }) it('renders title', () => { wrapper = Wrapper() expect(wrapper.text()).toContain("It's a post title") }) - it('renders the "Comment:"', () => { + it('renders the identifier "notifications.comment"', () => { wrapper = Wrapper() - expect(wrapper.text()).toContain('Comment:') + expect(wrapper.text()).toContain('notifications.comment') }) it('renders the contentExcerpt', () => { wrapper = Wrapper() @@ -119,7 +119,7 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.mentioned_in_post', + 'notifications.reason.mentioned_in_post', ) }) it('renders title', () => { @@ -169,7 +169,7 @@ describe('Notification', () => { it('renders reason', () => { wrapper = Wrapper() expect(wrapper.find('.reason-text-for-test').text()).toEqual( - 'notifications.menu.mentioned_in_comment', + 'notifications.reason.mentioned_in_comment', ) }) it('renders title', () => { @@ -177,9 +177,9 @@ describe('Notification', () => { expect(wrapper.text()).toContain("It's a post title") }) - it('renders the "Comment:"', () => { + it('renders the identifier "notifications.comment"', () => { wrapper = Wrapper() - expect(wrapper.text()).toContain('Comment:') + expect(wrapper.text()).toContain('notifications.comment') }) it('renders the contentExcerpt', () => { diff --git a/webapp/components/notifications/Notification/Notification.vue b/webapp/components/notifications/Notification/Notification.vue index 93ca42980..dc9383c85 100644 --- a/webapp/components/notifications/Notification/Notification.vue +++ b/webapp/components/notifications/Notification/Notification.vue @@ -5,7 +5,7 @@ - {{ $t(`notifications.menu.${notification.reason}`) }} + {{ $t(`notifications.reason.${notification.reason}`) }} @@ -23,7 +23,9 @@ >
- Comment: + + {{ $t(`notifications.comment`) }}: + {{ from.contentExcerpt | removeHtml }}
diff --git a/webapp/components/notifications/NotificationMenu/NotificationMenu.spec.js b/webapp/components/notifications/NotificationMenu/NotificationMenu.spec.js index b8d988b58..2145b7d6e 100644 --- a/webapp/components/notifications/NotificationMenu/NotificationMenu.spec.js +++ b/webapp/components/notifications/NotificationMenu/NotificationMenu.spec.js @@ -46,11 +46,46 @@ describe('NotificationMenu.vue', () => { expect(wrapper.contains('.dropdown')).toBe(false) }) + describe('given only unread notifications', () => { + beforeEach(() => { + data = () => { + return { + displayedNotifications: [ + { + id: 'notification-41', + read: true, + post: { + id: 'post-1', + title: 'some post title', + contentExcerpt: 'this is a post content', + author: { + id: 'john-1', + slug: 'john-doe', + name: 'John Doe', + }, + }, + }, + ], + } + } + }) + + it('counter displays 0', () => { + wrapper = Wrapper() + expect(wrapper.find('ds-button-stub').text()).toEqual('0') + }) + + it('button is not primary', () => { + wrapper = Wrapper() + expect(wrapper.find('ds-button-stub').props('primary')).toBe(false) + }) + }) + describe('given some notifications', () => { beforeEach(() => { data = () => { return { - notifications: [ + displayedNotifications: [ { id: 'notification-41', read: false, @@ -79,15 +114,34 @@ describe('NotificationMenu.vue', () => { }, }, }, + { + id: 'notification-43', + read: true, + post: { + id: 'post-3', + title: 'read post title', + contentExcerpt: 'this is yet another post content', + author: { + id: 'john-1', + slug: 'john-doe', + name: 'John Doe', + }, + }, + }, ], } } }) - it('displays the total number of notifications', () => { + it('displays the number of unread notifications', () => { wrapper = Wrapper() expect(wrapper.find('ds-button-stub').text()).toEqual('2') }) + + it('renders primary button', () => { + wrapper = Wrapper() + expect(wrapper.find('ds-button-stub').props('primary')).toBe(true) + }) }) }) }) diff --git a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue index 51b90089f..9c3ed0bd7 100644 --- a/webapp/components/notifications/NotificationMenu/NotificationMenu.vue +++ b/webapp/components/notifications/NotificationMenu/NotificationMenu.vue @@ -1,16 +1,16 @@