From dfaa2257f0fb20db0dffd0eaabcb4c6c93fefa72 Mon Sep 17 00:00:00 2001 From: Lukasz Jagiela Date: Thu, 6 Nov 2025 17:35:38 +0100 Subject: [PATCH] test: add remaining e2e tests for notifications --- .../notifications-center/EmptyState.tsx | 8 ++- .../SubscriptionsDropDown.tsx | 18 ++++-- .../notifications/NotificationCenterAssert.ts | 16 +++-- .../NotificationsEmptyStateAssert.ts | 19 ++++++ .../notifications/NotificationsMenuAssert.ts | 4 ++ .../SubscriptionsDropdownAssert.ts | 21 +++++++ .../src/assert/topNavigationAssert.ts | 10 ++- .../notifications/NotificationCenter.ts | 36 ++++++----- .../notifications/NotificationsEmptyState.ts | 45 ++++++++++++++ .../notifications/SubscriptionsDropdown.ts | 55 +++++++++++++++++ .../NotificationsCenterExtended.feature | 49 ++++++++++++++- .../features/NotificationsCenterPopup.feature | 45 +++++++++++++- .../e2e-tests/src/steps/notificationsSteps.ts | 61 +++++++++++++++++-- 13 files changed, 350 insertions(+), 37 deletions(-) create mode 100644 packages/e2e-tests/src/assert/notifications/NotificationsEmptyStateAssert.ts create mode 100644 packages/e2e-tests/src/assert/notifications/SubscriptionsDropdownAssert.ts create mode 100644 packages/e2e-tests/src/elements/notifications/NotificationsEmptyState.ts create mode 100644 packages/e2e-tests/src/elements/notifications/SubscriptionsDropdown.ts diff --git a/apps/browser-extension-wallet/src/features/notifications-center/EmptyState.tsx b/apps/browser-extension-wallet/src/features/notifications-center/EmptyState.tsx index 1b092654f..92f348176 100644 --- a/apps/browser-extension-wallet/src/features/notifications-center/EmptyState.tsx +++ b/apps/browser-extension-wallet/src/features/notifications-center/EmptyState.tsx @@ -9,10 +9,12 @@ export const EmptyState = (): React.ReactElement => { return ( - + - {t('notificationsCenter.emptyState.title')} - {t('notificationsCenter.emptyState.description')} + {t('notificationsCenter.emptyState.title')} + + {t('notificationsCenter.emptyState.description')} + ); diff --git a/apps/browser-extension-wallet/src/features/notifications-center/SubscriptionsDropDown.tsx b/apps/browser-extension-wallet/src/features/notifications-center/SubscriptionsDropDown.tsx index 9065b6979..07f2edbfd 100644 --- a/apps/browser-extension-wallet/src/features/notifications-center/SubscriptionsDropDown.tsx +++ b/apps/browser-extension-wallet/src/features/notifications-center/SubscriptionsDropDown.tsx @@ -22,9 +22,14 @@ export const SubscriptionsDropDown = ({ const { t } = useTranslation(); return ( - + - {t('notificationsCenter.chooseSubject')} + + {t('notificationsCenter.chooseSubject')} + {topics.map((topic) => ( - + {topic.name} onTopicChange(topic, isChecked)} /> diff --git a/packages/e2e-tests/src/assert/notifications/NotificationCenterAssert.ts b/packages/e2e-tests/src/assert/notifications/NotificationCenterAssert.ts index b3428ea0e..b5a10f884 100644 --- a/packages/e2e-tests/src/assert/notifications/NotificationCenterAssert.ts +++ b/packages/e2e-tests/src/assert/notifications/NotificationCenterAssert.ts @@ -13,8 +13,8 @@ class NotificationCenterAssert { await NotificationCenter.sectionTitleCounter.waitForDisplayed(); expect(await NotificationCenter.getCounterValue()).to.be.greaterThan(0); - await NotificationCenter.subscriptionsDropdown.waitForDisplayed(); - expect(await NotificationCenter.subscriptionsDropdown.getText()).to.equal( + await NotificationCenter.subscriptionsButton.waitForDisplayed(); + expect(await NotificationCenter.subscriptionsButton.getText()).to.equal( await t('notificationsCenter.subscriptions') ); if (mode === 'extended') { @@ -65,7 +65,11 @@ class NotificationCenterAssert { } } - async assertSeeExpectedNumberOfUnreadNotifications(expectedCount: number, location: 'menu' | 'page') { + async assertSeeExpectedNumberOfNotifications( + expectedCount: number, + location: 'menu' | 'page', + status: 'read' | 'unread' + ) { for (let i = 1; i <= expectedCount; i++) { const notification = new NotificationListItem(location, i); await notification.title.waitForDisplayed(); @@ -77,7 +81,7 @@ class NotificationCenterAssert { expect(publisher).to.not.be.empty; const isUnread = await notification.isUnread(); - expect(isUnread).to.be.true; + expect(isUnread).to.equal(status === 'unread'); } } @@ -97,6 +101,10 @@ class NotificationCenterAssert { } ); } + + async assertSeeMarkAllAsReadButton(shouldSee: boolean) { + await NotificationCenter.markAllAsReadButton.waitForDisplayed({ reverse: !shouldSee }); + } } export default new NotificationCenterAssert(); diff --git a/packages/e2e-tests/src/assert/notifications/NotificationsEmptyStateAssert.ts b/packages/e2e-tests/src/assert/notifications/NotificationsEmptyStateAssert.ts new file mode 100644 index 000000000..47ce8ccd4 --- /dev/null +++ b/packages/e2e-tests/src/assert/notifications/NotificationsEmptyStateAssert.ts @@ -0,0 +1,19 @@ +import NotificationsEmptyState from '../../elements/notifications/NotificationsEmptyState'; +import { expect } from 'chai'; +import { t } from '../../utils/translationService'; + +class NotificationsEmptyStateAssert { + async assertSeeEmptyState(location: 'menu' | 'page') { + const emptyState = new NotificationsEmptyState(location); + + await emptyState.emptyStateImage.waitForDisplayed(); + + await emptyState.emptyStateTitle.waitForDisplayed(); + expect(await emptyState.getTitle()).to.equal(await t('notificationsCenter.emptyState.title')); + + await emptyState.emptyStateDescription.waitForDisplayed(); + expect(await emptyState.getDescription()).to.equal(await t('notificationsCenter.emptyState.description')); + } +} + +export default new NotificationsEmptyStateAssert(); diff --git a/packages/e2e-tests/src/assert/notifications/NotificationsMenuAssert.ts b/packages/e2e-tests/src/assert/notifications/NotificationsMenuAssert.ts index 06b2502cf..295684613 100644 --- a/packages/e2e-tests/src/assert/notifications/NotificationsMenuAssert.ts +++ b/packages/e2e-tests/src/assert/notifications/NotificationsMenuAssert.ts @@ -42,6 +42,10 @@ class NotificationsMenuAssert { return { unreadCount, readCount }; } + + async assertSeeMarkAllAsReadButton(shouldSee: boolean) { + await NotificationsMenu.markAllAsReadButton.waitForDisplayed({ reverse: !shouldSee }); + } } export default new NotificationsMenuAssert(); diff --git a/packages/e2e-tests/src/assert/notifications/SubscriptionsDropdownAssert.ts b/packages/e2e-tests/src/assert/notifications/SubscriptionsDropdownAssert.ts new file mode 100644 index 000000000..88bf870c2 --- /dev/null +++ b/packages/e2e-tests/src/assert/notifications/SubscriptionsDropdownAssert.ts @@ -0,0 +1,21 @@ +import SubscriptionsDropdown from '../../elements/notifications/SubscriptionsDropdown'; +import { expect } from 'chai'; +import { t } from '../../utils/translationService'; + +class SubscriptionsDropdownAssert { + async assertSeeSubscriptionsDropdown() { + await SubscriptionsDropdown.dropdownMenu.waitForDisplayed(); + + await SubscriptionsDropdown.dropdownDescription.waitForDisplayed(); + expect(await SubscriptionsDropdown.getDropdownDescriptionText()).to.equal( + await t('notificationsCenter.chooseSubject') + ); + } + + async assertTopicSubscriptionState(topicId: string, shouldBeSubscribed: boolean) { + const isSubscribed = await SubscriptionsDropdown.isTopicSubscribed(topicId); + expect(isSubscribed).to.equal(shouldBeSubscribed); + } +} + +export default new SubscriptionsDropdownAssert(); diff --git a/packages/e2e-tests/src/assert/topNavigationAssert.ts b/packages/e2e-tests/src/assert/topNavigationAssert.ts index a69d751b6..f21c42da2 100644 --- a/packages/e2e-tests/src/assert/topNavigationAssert.ts +++ b/packages/e2e-tests/src/assert/topNavigationAssert.ts @@ -33,8 +33,14 @@ class TopNavigationAssert { } async assertSeeUnreadNotificationsCounter(expectedCount: number) { - await MenuHeader.unreadNotificationsCounter.waitForDisplayed(); - expect(await MenuHeader.unreadNotificationsCounter.getText()).to.equal(expectedCount > 9 ? '9+' : expectedCount); + if (expectedCount === 0) { + await MenuHeader.unreadNotificationsCounter.waitForDisplayed({ reverse: true }); + } else { + await MenuHeader.unreadNotificationsCounter.waitForDisplayed(); + expect(await MenuHeader.unreadNotificationsCounter.getText()).to.equal( + expectedCount > 9 ? '9+' : expectedCount.toString() + ); + } } async assertLogoPresent() { diff --git a/packages/e2e-tests/src/elements/notifications/NotificationCenter.ts b/packages/e2e-tests/src/elements/notifications/NotificationCenter.ts index 530b2dce9..bf4cf72f6 100644 --- a/packages/e2e-tests/src/elements/notifications/NotificationCenter.ts +++ b/packages/e2e-tests/src/elements/notifications/NotificationCenter.ts @@ -6,7 +6,7 @@ class NotificationCenter { private readonly SECTION_TITLE = '[data-testid="section-title"]'; private readonly NAVIGATION_BUTTON_BACK = '[data-testid="navigation-button-arrow"]'; private readonly SECTION_TITLE_COUNTER = '[data-testid="section-title-counter"]'; - private readonly SUBSCRIPTIONS_DROPDOWN = '[data-testid="subscriptions"]'; + private readonly SUBSCRIPTIONS_BUTTON = '[data-testid="subscriptions"]'; private readonly MARK_ALL_AS_READ_BUTTON = '[data-testid="mark-all-as-read-button"]'; private readonly NOTIFICATIONS_LIST = '[data-testid="notifications-list"]'; @@ -22,8 +22,8 @@ class NotificationCenter { return $(this.SECTION_TITLE_COUNTER); } - get subscriptionsDropdown(): ChainablePromiseElement { - return $(this.SUBSCRIPTIONS_DROPDOWN); + get subscriptionsButton(): ChainablePromiseElement { + return $(this.SUBSCRIPTIONS_BUTTON); } get markAllAsReadButton(): ChainablePromiseElement { @@ -34,19 +34,23 @@ class NotificationCenter { return $(this.NOTIFICATIONS_LIST); } - async clickBackButton(): Promise { - await this.navigationButtonBack.waitForClickable(); - await this.navigationButtonBack.click(); - } - - async clickSubscriptionsDropdown(): Promise { - await this.subscriptionsDropdown.waitForClickable(); - await this.subscriptionsDropdown.click(); - } - - async clickMarkAllAsReadButton(): Promise { - await this.markAllAsReadButton.waitForClickable(); - await this.markAllAsReadButton.click(); + async clickOnButton(button: 'Back' | 'Subscriptions' | 'Mark all as read') { + switch (button) { + case 'Back': + await this.navigationButtonBack.waitForClickable(); + await this.navigationButtonBack.click(); + break; + case 'Subscriptions': + await this.subscriptionsButton.waitForClickable(); + await this.subscriptionsButton.click(); + break; + case 'Mark all as read': + await this.markAllAsReadButton.waitForClickable(); + await this.markAllAsReadButton.click(); + break; + default: + throw new Error(`Unsupported button: ${button}`); + } } async getCounterValue(): Promise { diff --git a/packages/e2e-tests/src/elements/notifications/NotificationsEmptyState.ts b/packages/e2e-tests/src/elements/notifications/NotificationsEmptyState.ts new file mode 100644 index 000000000..9f67974a3 --- /dev/null +++ b/packages/e2e-tests/src/elements/notifications/NotificationsEmptyState.ts @@ -0,0 +1,45 @@ +/* global WebdriverIO */ +import type { ChainablePromiseElement } from 'webdriverio'; + +class NotificationsEmptyState { + private readonly EMPTY_STATE_IMAGE = '[data-testid="empty-state-image"]'; + private readonly EMPTY_STATE_TITLE = '[data-testid="empty-state-title"]'; + private readonly EMPTY_STATE_DESCRIPTION = '[data-testid="empty-state-description"]'; + + private static readonly ANT_DROPDOWN_MENU = '.ant-dropdown-menu'; + private static readonly PAGE_CONTENT = ':is(#content, #contentLayout)'; + + private readonly location: 'menu' | 'page'; + + constructor(location: 'menu' | 'page') { + this.location = location; + } + + private getSelector(elementSelector: string): string { + const wrapper = + this.location === 'menu' ? NotificationsEmptyState.ANT_DROPDOWN_MENU : NotificationsEmptyState.PAGE_CONTENT; + return `${wrapper} ${elementSelector}`; + } + + get emptyStateImage(): ChainablePromiseElement { + return $(this.getSelector(this.EMPTY_STATE_IMAGE)); + } + + get emptyStateTitle(): ChainablePromiseElement { + return $(this.getSelector(this.EMPTY_STATE_TITLE)); + } + + get emptyStateDescription(): ChainablePromiseElement { + return $(this.getSelector(this.EMPTY_STATE_DESCRIPTION)); + } + + async getTitle(): Promise { + return await this.emptyStateTitle.getText(); + } + + async getDescription(): Promise { + return await this.emptyStateDescription.getText(); + } +} + +export default NotificationsEmptyState; diff --git a/packages/e2e-tests/src/elements/notifications/SubscriptionsDropdown.ts b/packages/e2e-tests/src/elements/notifications/SubscriptionsDropdown.ts new file mode 100644 index 000000000..6a27de375 --- /dev/null +++ b/packages/e2e-tests/src/elements/notifications/SubscriptionsDropdown.ts @@ -0,0 +1,55 @@ +/* global WebdriverIO */ +import type { ChainablePromiseElement } from 'webdriverio'; + +class SubscriptionsDropdown { + private readonly DROPDOWN_MENU = '[data-testid="subscriptions-dropdown"]'; + private readonly DROPDOWN_DESCRIPTION = '[data-testid="subscriptions-dropdown-description"]'; + + get dropdownDescription(): ChainablePromiseElement { + return $(this.DROPDOWN_DESCRIPTION); + } + + private getTopicToggleSwitchSelector(topicId: string): string { + return `[data-testid="subscriptions-${topicId}-toggle-switch"]`; + } + + get dropdownMenu(): ChainablePromiseElement { + return $(this.DROPDOWN_MENU); + } + + getTopicToggleSwitch(topicId: string): ChainablePromiseElement { + return $(this.getTopicToggleSwitchSelector(topicId)); + } + + async getDropdownDescriptionText(): Promise { + return await this.dropdownDescription.getText(); + } + + async isTopicSubscribed(topicId: string): Promise { + const toggleSwitch = this.getTopicToggleSwitch(topicId); + const ariaChecked = await toggleSwitch.getAttribute('aria-checked'); + return ariaChecked === 'true'; + } + + async toggleTopic(topicId: string): Promise { + const toggleSwitch = this.getTopicToggleSwitch(topicId); + await toggleSwitch.waitForClickable(); + await toggleSwitch.click(); + } + + async enableTopic(topicId: string): Promise { + const isSubscribed = await this.isTopicSubscribed(topicId); + if (!isSubscribed) { + await this.toggleTopic(topicId); + } + } + + async disableTopic(topicId: string): Promise { + const isSubscribed = await this.isTopicSubscribed(topicId); + if (isSubscribed) { + await this.toggleTopic(topicId); + } + } +} + +export default new SubscriptionsDropdown(); diff --git a/packages/e2e-tests/src/features/NotificationsCenterExtended.feature b/packages/e2e-tests/src/features/NotificationsCenterExtended.feature index 1db7ff4a9..0f9b2533c 100644 --- a/packages/e2e-tests/src/features/NotificationsCenterExtended.feature +++ b/packages/e2e-tests/src/features/NotificationsCenterExtended.feature @@ -27,7 +27,7 @@ Feature: Notification Center - extended view And I click "Notifications" button on page header When I click on "View all" button in the "Notifications menu" Then "Notification center" is displayed in extended mode - And "Notifications page" contains 3 unread notifications with all details + And "Notifications center" contains 3 unread notifications with all details And the dynamically added notification is displayed in the "Notifications center" with unread marker @LW-tbd4 @@ -75,3 +75,50 @@ Feature: Notification Center - extended view Then Remove notification modal is displayed When I click "Cancel" button in the remove notification modal Then the dynamically added notification is displayed in the "Notifications center" with unread marker + + @LW-tbd8 + Scenario: Extended View - Notification Center - remove all notifications and verify empty state + And I visit Notifications page in extended mode + And "Notifications center" contains 2 unread notifications with all details + And I click on remove button for notification number 1 in the "Notifications center" + And I click "Remove" button in the remove notification modal + And I click on remove button for notification number 1 in the "Notifications center" + When I click "Remove" button in the remove notification modal + Then Notifications empty state is displayed in the "Notifications center" + When I click "Notifications" button on page header + Then Notifications empty state is displayed in the "Notifications menu" + + @LW-tbd9 + Scenario Outline: Extended View - Notification Center - mark all notifications as read from + And I add a new notification dynamically + And "Notifications" button indicates 3 unread notifications + And + And "Notifications " contains 3 unread notifications with all details + When I click on "Mark all as read" button in the "Notifications " + And I do not see "Mark all as read" button in "Notifications " + Then "Notifications " contains 3 read notifications with all details + And "Notifications" button indicates 0 unread notifications + Examples: + | location | navigation_step | + | menu | I click "Notifications" button on page header | + | center | I visit Notifications page in extended mode | + + @LW-tbd10 + Scenario: Extended View - Notification Center - manage topic subscriptions and verify notification filtering + And I visit Notifications page in extended mode + And "Notifications center" contains 2 unread notifications with all details + When I click on "Subscriptions" button in the "Notifications center" + Then Subscriptions dropdown is displayed + And topic "topic-1" is enabled in subscriptions dropdown + And topic "topic-2" is enabled in subscriptions dropdown + When I disable topic "topic-2" in subscriptions dropdown + Then topic "topic-2" is disabled in subscriptions dropdown + And I click on "Subscriptions" button in the "Notifications center" + When I add a new notification dynamically + Then the dynamically added notification is not displayed in the "Notifications center" with unread marker + And I click on "Subscriptions" button in the "Notifications center" + When I enable topic "topic-2" in subscriptions dropdown + And topic "topic-2" is enabled in subscriptions dropdown + And I click on "Subscriptions" button in the "Notifications center" + And I add a new notification dynamically + Then the dynamically added notification is displayed in the "Notifications center" with unread marker diff --git a/packages/e2e-tests/src/features/NotificationsCenterPopup.feature b/packages/e2e-tests/src/features/NotificationsCenterPopup.feature index 3677512ac..73ea6ad59 100644 --- a/packages/e2e-tests/src/features/NotificationsCenterPopup.feature +++ b/packages/e2e-tests/src/features/NotificationsCenterPopup.feature @@ -27,7 +27,7 @@ Feature: Notification Center - popup view And I click "Notifications" button on page header When I click on "View all" button in the "Notifications menu" Then "Notification center" is displayed in popup mode - And "Notifications page" contains 3 unread notifications with all details + And "Notifications center" contains 3 unread notifications with all details And the dynamically added notification is displayed in the "Notifications center" with unread marker @LW-tbd4 @@ -75,3 +75,46 @@ Feature: Notification Center - popup view Then Remove notification modal is displayed When I click "Cancel" button in the remove notification modal Then the dynamically added notification is displayed in the "Notifications center" with unread marker + + @LW-tbd8 + Scenario: Popup View - Notification Center - remove all notifications and verify empty state + And I visit Notifications page in popup mode + And "Notifications center" contains 2 unread notifications with all details + And I click on remove button for notification number 1 in the "Notifications center" + And I click "Remove" button in the remove notification modal + And I click on remove button for notification number 1 in the "Notifications center" + When I click "Remove" button in the remove notification modal + Then Notifications empty state is displayed in the "Notifications center" + When I click "Notifications" button on page header + Then Notifications empty state is displayed in the "Notifications menu" + + @LW-tbd9 + Scenario: Popup View - Notification Center - mark all notifications as read from menu + And I add a new notification dynamically + And "Notifications" button indicates 3 unread notifications + And I click "Notifications" button on page header + And "Notifications menu" contains 3 unread notifications with all details + When I click on "Mark all as read" button in the "Notifications menu" + And I do not see "Mark all as read" button in "Notifications menu" + Then "Notifications menu" contains 3 read notifications with all details + And "Notifications" button indicates 0 unread notifications + + @LW-tbd10 + Scenario: Popup View - Notification Center - manage topic subscriptions and verify notification filtering + And I visit Notifications page in popup mode + And "Notifications center" contains 2 unread notifications with all details + When I click on "Subscriptions" button in the "Notifications center" + Then Subscriptions dropdown is displayed + And topic "topic-1" is enabled in subscriptions dropdown + And topic "topic-2" is enabled in subscriptions dropdown + When I disable topic "topic-2" in subscriptions dropdown + Then topic "topic-2" is disabled in subscriptions dropdown + And I click on "Subscriptions" button in the "Notifications center" + When I add a new notification dynamically + Then the dynamically added notification is not displayed in the "Notifications center" with unread marker + And I click on "Subscriptions" button in the "Notifications center" + When I enable topic "topic-2" in subscriptions dropdown + And topic "topic-2" is enabled in subscriptions dropdown + And I click on "Subscriptions" button in the "Notifications center" + And I add a new notification dynamically + Then the dynamically added notification is displayed in the "Notifications center" with unread marker diff --git a/packages/e2e-tests/src/steps/notificationsSteps.ts b/packages/e2e-tests/src/steps/notificationsSteps.ts index c9300f984..bd37e7503 100644 --- a/packages/e2e-tests/src/steps/notificationsSteps.ts +++ b/packages/e2e-tests/src/steps/notificationsSteps.ts @@ -4,11 +4,14 @@ import NotificationsMenuAssert from '../assert/notifications/NotificationsMenuAs import NotificationCenterAssert from '../assert/notifications/NotificationCenterAssert'; import NotificationDetailsAssert from '../assert/notifications/NotificationDetailsAssert'; import RemoveNotificationModalAssert from '../assert/notifications/RemoveNotificationModalAssert'; +import NotificationsEmptyStateAssert from '../assert/notifications/NotificationsEmptyStateAssert'; +import SubscriptionsDropdownAssert from '../assert/notifications/SubscriptionsDropdownAssert'; import NotificationsMenu from '../elements/notifications/NotificationsMenu'; import NotificationCenter from '../elements/notifications/NotificationCenter'; import NotificationDetails from '../elements/notifications/NotificationDetails'; import RemoveNotificationModal from '../elements/notifications/RemoveNotificationModal'; import NotificationListItem from '../elements/notifications/NotificationListItem'; +import SubscriptionsDropdown from '../elements/notifications/SubscriptionsDropdown'; import { NotificationsManager, Topic, Notification } from '../utils/NotificationsManager'; const TEST_TOPICS: Topic[] = [ @@ -55,11 +58,11 @@ const DYNAMIC_NOTIFICATION: Notification = { Then( /^"Notifications" button indicates (\d) unread notifications$/, - async (unreadCount: number) => await topNavigationAssert.assertSeeUnreadNotificationsCounter(unreadCount) + async (unreadCount: string) => await topNavigationAssert.assertSeeUnreadNotificationsCounter(Number(unreadCount)) ); Then( - /^"Notifications menu" is displayed with (all read|some unread) messages$/, + /^"Notifications menu" is displayed with (all read|some unread|no) messages$/, async (messagesStatus: 'all read' | 'some unread' | 'no') => { await NotificationsMenuAssert.assertSeeNotificationsMenu(messagesStatus); } @@ -72,6 +75,22 @@ When( } ); +When( + /^I click on "(Back|Subscriptions|Mark all as read)" button in the "Notifications center"$/, + async (button: 'Back' | 'Subscriptions' | 'Mark all as read') => { + await NotificationCenter.clickOnButton(button); + } +); + +Then( + /^I (see|do not see) "Mark all as read" button in "Notifications (menu|center)"$/, + async (shouldSee: 'see' | 'do not see', location: 'menu' | 'center') => { + await (location === 'menu' + ? NotificationsMenuAssert.assertSeeMarkAllAsReadButton(shouldSee === 'see') + : NotificationCenterAssert.assertSeeMarkAllAsReadButton(shouldSee === 'see')); + } +); + When( /^I click on "(View all|Remove|Back)" button in the Notification details view$/, async (button: 'View all' | 'Remove' | 'Back') => { @@ -118,7 +137,6 @@ Then( const topic = TEST_TOPICS.find((t) => t.id === DYNAMIC_NOTIFICATION.message.topicId); const location = where === 'menu' ? 'menu' : 'page'; const isRead = readStatus === 'read'; - await NotificationCenterAssert.waitForNonEmptyNotification(location); await NotificationCenterAssert.assertSeeFirstUnreadNotificationWithTopicAndTitle( topic?.name || '', @@ -135,9 +153,13 @@ Then(/^"Notification center" is displayed in (popup|extended) mode$/, async (mod }); Then( - /^"Notifications (menu|page)" contains (\d+) unread notifications with all details$/, - async (location: 'menu' | 'page', expectedCount: number) => { - await NotificationCenterAssert.assertSeeExpectedNumberOfUnreadNotifications(expectedCount, location); + /^"Notifications (menu|center)" contains (\d+) (unread|read) notifications with all details$/, + async (location: 'menu' | 'center', expectedCount: number, readStatus: 'unread' | 'read') => { + await NotificationCenterAssert.assertSeeExpectedNumberOfNotifications( + expectedCount, + location === 'menu' ? 'menu' : 'page', + readStatus + ); } ); @@ -173,3 +195,30 @@ When(/^I click "(Cancel|Remove)" button in the remove notification modal$/, asyn await (button === 'Cancel' ? RemoveNotificationModal.clickCancel() : RemoveNotificationModal.clickConfirm()); await browser.pause(1000); // small delay to give some time for removal to complete }); + +Then( + /^Notifications empty state is displayed in the "Notifications (menu|center)"$/, + async (location: 'menu' | 'center') => { + await NotificationsEmptyStateAssert.assertSeeEmptyState(location === 'menu' ? 'menu' : 'page'); + } +); + +Then(/^Subscriptions dropdown is displayed$/, async () => { + await SubscriptionsDropdownAssert.assertSeeSubscriptionsDropdown(); +}); + +When( + /^I (enable|disable) topic "(topic-\d+)" in subscriptions dropdown$/, + async (action: 'enable' | 'disable', topicId: string) => { + await (action === 'enable' + ? SubscriptionsDropdown.enableTopic(topicId) + : SubscriptionsDropdown.disableTopic(topicId)); + } +); + +Then( + /^topic "(topic-\d+)" is (enabled|disabled) in subscriptions dropdown$/, + async (topicId: string, state: 'enabled' | 'disabled') => { + await SubscriptionsDropdownAssert.assertTopicSubscriptionState(topicId, state === 'enabled'); + } +);