Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: zero bell to all notifications page [2823] #3219

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cypress/integration/common/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,13 @@ When("mention {string} in the text", mention => {
.click();
});

Then("the notification gets marked as read", () => {
cy.get(".notifications-menu-popover .notification")
.first()
.should("have.class", "--read");
Then("the unread counter is removed", () => {
cy.get('.notifications-menu .counter-icon').should('not.exist');
});

Then("there are no notifications in the top menu", () => {
cy.get(".notifications-menu").should("contain", "0");
Then("the notification menu button links to the all notifications page", () => {
cy.get(".notifications-menu").click();
cy.location("pathname").should("contain", "/notifications");
});

Given("there is an annoying user called {string}", name => {
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/notifications/Mentions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ Feature: Notification for a mention
And see 1 unread notifications in the top menu
And open the notification menu and click on the first item
Then I get to the post page of ".../hey-matt"
And the notification gets marked as read
But when I refresh the page
Then there are no notifications in the top menu
And the unread counter is removed
And the notification menu button links to the all notifications page

23 changes: 15 additions & 8 deletions webapp/components/NotificationMenu/NotificationMenu.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config, mount } from '@vue/test-utils'
import { config, mount, RouterLinkStub } from '@vue/test-utils'
import NotificationMenu from './NotificationMenu'

const localVue = global.localVue
Expand All @@ -11,6 +11,7 @@ describe('NotificationMenu.vue', () => {
let wrapper
let mocks
let data
let stubs
beforeEach(() => {
mocks = {
$t: jest.fn(),
Expand All @@ -20,6 +21,9 @@ describe('NotificationMenu.vue', () => {
notifications: [],
}
}
stubs = {
NuxtLink: RouterLinkStub,
}
})

describe('mount', () => {
Expand All @@ -28,20 +32,22 @@ describe('NotificationMenu.vue', () => {
data,
mocks,
localVue,
stubs,
})
}

it('counter displays 0', () => {
it('renders as link without counter', () => {
wrapper = Wrapper()
expect(wrapper.find('.count').text()).toEqual('0')
expect(wrapper.is('a.notifications-menu')).toBe(true)
expect(() => wrapper.get('.count')).toThrow()
})

it('no dropdown is rendered', () => {
wrapper = Wrapper()
expect(wrapper.contains('.dropdown')).toBe(false)
})

describe('given only unread notifications', () => {
describe('given only read notifications', () => {
beforeEach(() => {
data = () => {
return {
Expand All @@ -65,14 +71,15 @@ describe('NotificationMenu.vue', () => {
}
})

it('counter displays 0', () => {
it('renders as link without counter', () => {
wrapper = Wrapper()
expect(wrapper.find('.count').text()).toEqual('0')
expect(wrapper.is('a.notifications-menu')).toBe(true)
expect(() => wrapper.get('.count')).toThrow()
})

it('counter is not colored', () => {
it('no dropdown is rendered', () => {
wrapper = Wrapper()
expect(wrapper.find('.count').classes()).toContain('--inactive')
expect(wrapper.contains('.dropdown')).toBe(false)
})
})

Expand Down
10 changes: 7 additions & 3 deletions webapp/components/NotificationMenu/NotificationMenu.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<base-button v-if="!notifications.length" class="notifications-menu" disabled ghost circle>
<counter-icon icon="bell" :count="unreadNotificationsCount" danger />
</base-button>
<nuxt-link
v-if="!unreadNotificationsCount"
class="notifications-menu"
:to="{ name: 'notifications' }"
>
<base-button icon="bell" ghost circle />
</nuxt-link>
<dropdown v-else class="notifications-menu" offset="8" :placement="placement">
<template slot="default" slot-scope="{ toggleMenu }">
<base-button @click="toggleMenu" ghost circle>
Expand Down