From d75507bbceeb35ee1ddabcd131f871850785bdc7 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 1 Jun 2019 15:51:53 -0700 Subject: [PATCH] fix: fix disableNotificationsBadge aria-label (#1260) --- .../computations/timelineComputations.js | 14 ++++---- tests/spec/129-wellness.js | 36 +++++++++++++++++++ tests/utils.js | 1 + 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 tests/spec/129-wellness.js diff --git a/src/routes/_store/computations/timelineComputations.js b/src/routes/_store/computations/timelineComputations.js index 5716929d..068b15cb 100644 --- a/src/routes/_store/computations/timelineComputations.js +++ b/src/routes/_store/computations/timelineComputations.js @@ -167,16 +167,18 @@ export function timelineComputations (store) { ) store.compute('numberOfNotifications', - ['filteredTimelineNotificationItemSummaries'], - (filteredTimelineNotificationItemSummaries) => ( - filteredTimelineNotificationItemSummaries ? filteredTimelineNotificationItemSummaries.length : 0 + ['filteredTimelineNotificationItemSummaries', 'disableNotificationBadge'], + (filteredTimelineNotificationItemSummaries, disableNotificationBadge) => ( + (!disableNotificationBadge && filteredTimelineNotificationItemSummaries) + ? filteredTimelineNotificationItemSummaries.length + : 0 ) ) store.compute('hasNotifications', - ['numberOfNotifications', 'currentPage', 'disableNotificationBadge'], - (numberOfNotifications, currentPage, $disableNotificationBadge) => ( - !$disableNotificationBadge && currentPage !== 'notifications' && !!numberOfNotifications + ['numberOfNotifications', 'currentPage'], + (numberOfNotifications, currentPage) => ( + currentPage !== 'notifications' && !!numberOfNotifications ) ) } diff --git a/tests/spec/129-wellness.js b/tests/spec/129-wellness.js new file mode 100644 index 00000000..d716691e --- /dev/null +++ b/tests/spec/129-wellness.js @@ -0,0 +1,36 @@ +import { + settingsNavButton, + homeNavButton, + disableUnreadNotifications, + getFirstVisibleStatus, + getUrl, + notificationsNavButton, getTitleText, sleep +} from '../utils' +import { loginAsFoobar } from '../roles' +import { Selector as $ } from 'testcafe' +import { postAs } from '../serverActions' + +fixture`129-wellness.js` + .page`http://localhost:4002` + +test('Can disable unread notification counts', async t => { + await loginAsFoobar(t) + await t.click(settingsNavButton) + .click($('a').withText('Wellness')) + .click(disableUnreadNotifications) + .expect(disableUnreadNotifications.checked).ok() + .click(homeNavButton) + .expect(getUrl()).eql('http://localhost:4002/') + .expect(getFirstVisibleStatus().exists).ok() + await postAs('admin', 'hey @foobar') + await sleep(2000) + await t + .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications') + .expect(getTitleText()).notContains('(1)') + .click(settingsNavButton) + .click($('a').withText('Wellness')) + .click(disableUnreadNotifications) + .expect(disableUnreadNotifications.checked).notOk() + .expect(notificationsNavButton.getAttribute('aria-label')).eql('Notifications (1 notification)') + .expect(getTitleText()).contains('(1)') +}) diff --git a/tests/utils.js b/tests/utils.js index d11b64d3..efa189cc 100644 --- a/tests/utils.js +++ b/tests/utils.js @@ -49,6 +49,7 @@ export const markMediaSensitiveInput = $('#choice-mark-media-sensitive') export const neverMarkMediaSensitiveInput = $('#choice-never-mark-media-sensitive') export const removeEmojiFromDisplayNamesInput = $('#choice-omit-emoji-in-display-names') export const disableInfiniteScroll = $('#choice-disable-infinite-scroll') +export const disableUnreadNotifications = $('#choice-disable-unread-notification-counts') export const dialogOptionsOption = $(`.modal-dialog button`) export const emojiSearchInput = $('.emoji-mart-search input') export const confirmationDialogOKButton = $('.confirmation-dialog-form-flex button:nth-child(1)')