diff --git a/frontend/cypress/e2e/notifications/notification-filters.cy.ts b/frontend/cypress/e2e/notifications/notification-filters.cy.ts new file mode 100644 index 000000000..058ce369f --- /dev/null +++ b/frontend/cypress/e2e/notifications/notification-filters.cy.ts @@ -0,0 +1,96 @@ +import { resetData } from '../../support/seed' + +describe('Notification filters', () => { + let alpha: string + let beta: string + let alphaSpace: string + let betaSpace: string + + const mentionHtml = + '
Ping @Member
' + + beforeEach(() => { + resetData('two_communities').then((ids) => { + ;[alpha, beta] = (ids.communities as string[]).map(String) + ;[alphaSpace, betaSpace] = (ids.spaces as string[]).map(String) + }) + cy.then(() => { + for (const [space, title] of [ + [alphaSpace, 'Alpha thread'], + [betaSpace, 'Beta thread'], + [alphaSpace, 'Padding one'], + [alphaSpace, 'Padding two'], + [alphaSpace, 'Padding three'], + ]) { + cy.task('requestAsUser', { + user: 'member2@example.com', + method: 'POST', + path: '/api/v2/document/GP Discussion', + body: { title, project: space, content: mentionHtml }, + }) + } + }) + cy.loginAs('member') + cy.intercept('GET', '**/api/v2/document/GP%20Notification*').as('notificationList') + cy.visit('/g/notifications') + cy.wait('@notificationList') + }) + + it('lists both mentions under a day label', () => { + cy.contains('[data-slot="list-group-header"]', 'Today').should('be.visible') + cy.contains('Alpha thread').should('be.visible') + cy.contains('Beta thread').should('be.visible') + }) + + it('narrows to the picked community', () => { + cy.button('All communities').click() + cy.contains('[role="option"]', 'Alpha').click() + cy.get('body').type('{esc}') + cy.wait('@notificationList') + + cy.contains('Alpha thread').should('be.visible') + cy.contains('Beta thread').should('not.exist') + cy.button('Alpha').should('be.visible').click() + cy.contains('[role="option"]', 'Beta').click() + cy.get('body').type('{esc}') + cy.button('2 communities').should('be.visible') + + cy.button('Clear').click() + cy.wait('@notificationList') + cy.contains('Beta thread').should('be.visible') + }) + + it('narrows to the picked space', () => { + cy.button('All spaces').click() + cy.contains('[role="option"]', 'Beta Space').click() + cy.get('body').type('{esc}') + cy.wait('@notificationList') + + cy.contains('Beta thread').should('be.visible') + cy.contains('Alpha thread').should('not.exist') + }) + + it('keeps today’s rows under the Today filter and shows the day on an empty day', () => { + cy.button('All dates').click() + cy.button('Today').click() + cy.wait('@notificationList') + cy.button('Today').should('be.visible') + cy.contains('Alpha thread').should('be.visible') + cy.contains('Beta thread').should('be.visible') + + cy.window().then((win) => { + win.localStorage.setItem( + 'gameplan:notificationFilters', + JSON.stringify({ + communities: [], + spaces: [], + date: { kind: 'range', from: '2020-01-01', to: '2020-01-01' }, + }), + ) + }) + cy.reload() + cy.wait('@notificationList') + cy.contains('1 January 2020').should('be.visible') + cy.contains('Nothing here').should('be.visible') + }) +}) diff --git a/frontend/src/components/DiscussionNotificationBell.vue b/frontend/src/components/DiscussionNotificationBell.vue new file mode 100644 index 000000000..90ddb30f8 --- /dev/null +++ b/frontend/src/components/DiscussionNotificationBell.vue @@ -0,0 +1,35 @@ + +