From 0844968d816d85a8f522bebe2f5c12b4b64b0251 Mon Sep 17 00:00:00 2001 From: Dhani Date: Wed, 25 Oct 2023 20:28:30 +0700 Subject: [PATCH] [MM-53166] Reset notification sounds modal selection when settings canceled (#24871) * fix: 24849 - reset notification selection * test: 24849 - add notification e2e test * test: 24849 - add notification e2e test * fix: 24849 - lint error * feat: 24849 - add and enable calls plugin * fix: 24849 - fix plugins lint * fix: 24849 - e2e and desktop component * fix: 24849 - e2e class queries * test: 24829 - update snapshot * test: 24849 - change MM code and remove call sound --------- Co-authored-by: dhnlr Co-authored-by: Mattermost Build --- ...otification_when_settings_canceled_spec.js | 66 +++++++++++++++++++ ...esktop_notification_settings.test.tsx.snap | 10 +++ .../desktop_notification_settings.tsx | 15 +++-- 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 e2e-tests/cypress/tests/integration/channels/notifications/reset_notification_when_settings_canceled_spec.js diff --git a/e2e-tests/cypress/tests/integration/channels/notifications/reset_notification_when_settings_canceled_spec.js b/e2e-tests/cypress/tests/integration/channels/notifications/reset_notification_when_settings_canceled_spec.js new file mode 100644 index 0000000000..e14f97bee8 --- /dev/null +++ b/e2e-tests/cypress/tests/integration/channels/notifications/reset_notification_when_settings_canceled_spec.js @@ -0,0 +1,66 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +// *************************************************************** +// - [#] indicates a test step (e.g. # Go to a page) +// - [*] indicates an assertion (e.g. * Check the title) +// - Use element ID when selecting an element. Create one if none. +// *************************************************************** + +// Stage: @prod +// Group: @channels @notifications + +describe('Notifications', () => { + before(() => { + cy.apiInitSetup().then(({team, user, channel}) => { + // # Login as user and visit channel + cy.apiLogin(user); + cy.visit(`/${team.name}/channels/${channel.name}`); + }); + }); + + it('MM-T5458 Notification sound modal selection should reset when settings canceled', () => { + // # Call function that clicks on Settings -> Notifications -> Desktop Notifications -> Notification sound -> Change sound -> Cancel -> Desktop Notifications + openSettingsAndChangeNotification(); + }); + + function openSettingsAndChangeNotification() { + // # Open 'Settings' modal + cy.uiOpenSettingsModal().within(() => { + // # Navigate to Desktop Notification Settings + navigateToDesktopNotificationSettings(); + + // # Change Notification selection + setNotificationSound(); + + // # Click Cancel button + cy.uiCancelButton().click(); + + // # Navigate to Desktop Notification Settings + navigateToDesktopNotificationSettings(); + cy.uiClose(); + }); + } + + function setNotificationSound() { + // # Change Notification sound selection value is set to Down + cy.get('#displaySoundNotification').click(); + cy.findByText('Down').click(); + + // * Verify Notification display changed to Down + verifyNotificationSelectionValue('Down'); + } + + function navigateToDesktopNotificationSettings() { + // # Click on the 'Edit' button next to Desktop Notifications + cy.get('#desktopEdit').should('be.visible').click(); + + // * Verify that the Notification sound is set to Bing + verifyNotificationSelectionValue('Bing'); + } + + function verifyNotificationSelectionValue(value) { + // * Verify that the Notification sound is set to certain value + cy.get('#displaySoundNotification').findByTestId('displaySoundNotificationValue').should('contain', value); + } +}); diff --git a/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/__snapshots__/desktop_notification_settings.test.tsx.snap b/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/__snapshots__/desktop_notification_settings.test.tsx.snap index ff64ca5c19..9614706dd2 100644 --- a/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/__snapshots__/desktop_notification_settings.test.tsx.snap +++ b/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/__snapshots__/desktop_notification_settings.test.tsx.snap @@ -844,6 +844,11 @@ exports[`components/user_settings/notifications/DesktopNotificationSettings shou className="react-select notification-sound-dropdown" classNamePrefix="react-select" clearable={false} + components={ + Object { + "SingleValue": [Function], + } + } defaultInputValue="" defaultMenuIsOpen={false} defaultValue={null} @@ -1033,6 +1038,11 @@ exports[`components/user_settings/notifications/DesktopNotificationSettings shou className="react-select notification-sound-dropdown" classNamePrefix="react-select" clearable={false} + components={ + Object { + "SingleValue": [Function], + } + } defaultInputValue="" defaultMenuIsOpen={false} defaultValue={null} diff --git a/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/desktop_notification_settings.tsx b/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/desktop_notification_settings.tsx index c07970f34f..280318ccd4 100644 --- a/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/desktop_notification_settings.tsx +++ b/webapp/channels/src/components/user_settings/notifications/desktop_notification_setting/desktop_notification_settings.tsx @@ -53,11 +53,9 @@ export default class DesktopNotificationSettings extends React.PureComponent
{props.children}
}} />); } @@ -191,6 +190,7 @@ export default class DesktopNotificationSettings extends React.PureComponent
{props.children}
}} />); } @@ -502,10 +502,15 @@ export default class DesktopNotificationSettings extends React.PureComponent