From 0dfb776290e87fc2cdaf6dd66180f08ffc94bc5b Mon Sep 17 00:00:00 2001 From: Joseph Baylon Date: Tue, 10 Nov 2020 09:53:38 -0800 Subject: [PATCH] MM-30165 Detox/E2E: Add e2e tests for channel notification preference (#4949) * Detox/E2E: Add e2e tests for channel notification preference * Fixed unit snap files * Moved e2e to notifications and updated formatting * Added basic snapshot tests * Update app/components/radio_button/radio_button_group.test.js Co-authored-by: Elias Nahum * Update app/components/radio_button/radio_button_group.test.js Co-authored-by: Elias Nahum * Update app/components/radio_button/radio_button_group.test.js Co-authored-by: Elias Nahum * Update app/components/sidebars/settings/drawer_item.test.js Co-authored-by: Elias Nahum * Update app/screens/channel_info/edit_channel/edit_channel.tsx Co-authored-by: Elias Nahum * Update app/screens/channel_info/notification_preference/notification_preference.test.js Co-authored-by: Elias Nahum * Update app/screens/channel_info/notification_preference/notification_preference.tsx Co-authored-by: Elias Nahum * Update app/components/radio_button/radio_button_group.test.js Co-authored-by: Elias Nahum * Fix radio button group snap file * Simplified element call * Rename channel sidebar to main sidebar * Rename drawer button files * Update app/components/sidebars/settings/settings_sidebar.test.js Co-authored-by: Elias Nahum * Update app/screens/channel_info/channel_info_row.test.js Co-authored-by: Elias Nahum * Update comments Co-authored-by: Elias Nahum --- .../radio_button_group.test.js.snap | 82 +++++ app/components/radio_button/radio_button.js | 4 +- .../radio_button/radio_button_group.js | 2 + .../radio_button/radio_button_group.test.js | 43 +++ .../__snapshots__/drawer_item.test.js.snap | 94 ++++++ .../settings_sidebar.test.js.snap | 13 + .../sidebars/settings/drawer_item.js | 3 + .../sidebars/settings/drawer_item.test.js | 31 ++ .../settings/settings_sidebar.test.js | 31 ++ .../settings/settings_sidebar_base.js | 9 +- app/screens/channel/channel_base.js | 2 +- .../channel_nav_bar.test.js.snap | 4 +- ...ttings_sidebar_drawer_button.test.js.snap} | 4 +- .../channel_nav_bar/channel_nav_bar.js | 8 +- .../main_sidebar_drawer_button.test.js.snap} | 8 +- .../index.js | 4 +- .../main_sidebar_drawer_button.js} | 4 +- .../main_sidebar_drawer_button.test.js} | 20 +- ...n.js => settings_sidebar_drawer_button.js} | 6 +- ...=> settings_sidebar_drawer_button.test.js} | 12 +- .../__snapshots__/channel_info.test.js.snap | 5 + .../channel_info_row.test.js.snap | 71 +++++ app/screens/channel_info/channel_info.js | 2 + app/screens/channel_info/channel_info_row.js | 8 +- .../channel_info/channel_info_row.test.js | 36 +++ .../__snapshots__/edit_channel.test.js.snap | 1 + .../edit_channel/edit_channel.test.js | 1 + .../edit_channel/edit_channel.tsx | 4 +- .../notification_preference.test.js.snap | 45 +++ .../notification_preference.test.js | 30 ++ .../notification_preference.tsx | 4 +- ...annel_notification_preference.test.js.snap | 284 ++++++++++++++++++ ...channel_notification_preference.android.js | 5 +- .../channel_notification_preference.ios.js | 5 +- .../channel_notification_preference.test.js | 9 + app/screens/settings/general/settings.js | 6 +- .../notification_settings.test.js.snap | 2 + .../notification_settings.js | 6 +- .../notification_settings_mobile.android.js | 16 +- .../notification_settings_mobile.ios.js | 8 +- app/screens/settings/section_item.js | 6 +- app/screens/settings/settings_item/index.js | 3 + detox/e2e/support/ui/component/index.js | 6 +- .../{channel_sidebar.js => main_sidebar.js} | 10 +- .../e2e/support/ui/component/post_options.js | 5 +- .../support/ui/component/settings_sidebar.js | 23 ++ detox/e2e/support/ui/screen/channel.js | 13 +- detox/e2e/support/ui/screen/channel_info.js | 20 +- .../screen/channel_notification_preference.js | 42 +++ detox/e2e/support/ui/screen/create_channel.js | 10 +- .../e2e/support/ui/screen/direct_channels.js | 6 +- .../e2e/support/ui/screen/general_settings.js | 37 +++ detox/e2e/support/ui/screen/index.js | 10 +- detox/e2e/support/ui/screen/more_channels.js | 6 +- .../ui/screen/notification_settings.js | 37 +++ .../ui/screen/notification_settings_mobile.js | 66 ++++ detox/e2e/test/channel_info/header.e2e.js | 19 +- .../channels/create_public_channel.e2e.js | 8 +- .../test/main_sidebar/select_channel.e2e.js | 18 +- .../channel_notification_default.e2e.js | 135 +++++++++ .../channel_notification_preference.e2e.js | 155 ++++++++++ .../in_app_notification.e2e.js} | 0 detox/e2e/test/smoke_test/channels.e2e.js | 42 +-- 63 files changed, 1485 insertions(+), 124 deletions(-) create mode 100644 app/components/radio_button/__snapshots__/radio_button_group.test.js.snap create mode 100644 app/components/radio_button/radio_button_group.test.js create mode 100644 app/components/sidebars/settings/__snapshots__/drawer_item.test.js.snap create mode 100644 app/components/sidebars/settings/__snapshots__/settings_sidebar.test.js.snap create mode 100644 app/components/sidebars/settings/drawer_item.test.js create mode 100644 app/components/sidebars/settings/settings_sidebar.test.js rename app/screens/channel/channel_nav_bar/__snapshots__/{settings_drawer_button.test.js.snap => settings_sidebar_drawer_button.test.js.snap} (83%) rename app/screens/channel/channel_nav_bar/{channel_drawer_button/__snapshots__/channel_drawer_button.test.js.snap => main_sidebar_drawer_button/__snapshots__/main_sidebar_drawer_button.test.js.snap} (90%) rename app/screens/channel/channel_nav_bar/{channel_drawer_button => main_sidebar_drawer_button}/index.js (75%) rename app/screens/channel/channel_nav_bar/{channel_drawer_button/channel_drawer_button.js => main_sidebar_drawer_button/main_sidebar_drawer_button.js} (98%) rename app/screens/channel/channel_nav_bar/{channel_drawer_button/channel_drawer_button.test.js => main_sidebar_drawer_button/main_sidebar_drawer_button.test.js} (89%) rename app/screens/channel/channel_nav_bar/{settings_drawer_button.js => settings_sidebar_drawer_button.js} (93%) rename app/screens/channel/channel_nav_bar/{settings_drawer_button.test.js => settings_sidebar_drawer_button.test.js} (75%) create mode 100644 app/screens/channel_info/__snapshots__/channel_info_row.test.js.snap create mode 100644 app/screens/channel_info/channel_info_row.test.js create mode 100644 app/screens/channel_info/notification_preference/__snapshots__/notification_preference.test.js.snap create mode 100644 app/screens/channel_info/notification_preference/notification_preference.test.js create mode 100644 app/screens/channel_notification_preference/__snapshots__/channel_notification_preference.test.js.snap rename detox/e2e/support/ui/component/{channel_sidebar.js => main_sidebar.js} (86%) create mode 100644 detox/e2e/support/ui/component/settings_sidebar.js create mode 100644 detox/e2e/support/ui/screen/channel_notification_preference.js create mode 100644 detox/e2e/support/ui/screen/general_settings.js create mode 100644 detox/e2e/support/ui/screen/notification_settings.js create mode 100644 detox/e2e/support/ui/screen/notification_settings_mobile.js create mode 100644 detox/e2e/test/notifications/channel_notification_default.e2e.js create mode 100644 detox/e2e/test/notifications/channel_notification_preference.e2e.js rename detox/e2e/test/{in_app_notification/notification.e2e.js => notifications/in_app_notification.e2e.js} (100%) diff --git a/app/components/radio_button/__snapshots__/radio_button_group.test.js.snap b/app/components/radio_button/__snapshots__/radio_button_group.test.js.snap new file mode 100644 index 000000000..57e55cbc9 --- /dev/null +++ b/app/components/radio_button/__snapshots__/radio_button_group.test.js.snap @@ -0,0 +1,82 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`RadioButtonGroup should match snapshot 1`] = ` + + + + +`; diff --git a/app/components/radio_button/radio_button.js b/app/components/radio_button/radio_button.js index 9d4a8d532..4d350c568 100644 --- a/app/components/radio_button/radio_button.js +++ b/app/components/radio_button/radio_button.js @@ -15,6 +15,7 @@ const DEFAULT_OPACITY = 1; class RadioButton extends PureComponent { static propTypes = { + testID: PropTypes.string, label: PropTypes.string, theme: PropTypes.object, value: PropTypes.string, @@ -83,7 +84,7 @@ class RadioButton extends PureComponent { render() { const {scaleValue, opacityValue} = this.state; - const {theme, checked, disabled} = this.props; + const {testID, theme, checked, disabled} = this.props; const styles = getStyleSheet(theme); const color = checked ? theme.buttonBg : theme.centerChannelColor; @@ -91,6 +92,7 @@ class RadioButton extends PureComponent { return ( diff --git a/app/components/radio_button/radio_button_group.js b/app/components/radio_button/radio_button_group.js index 2c20e2d1e..1c421e18f 100644 --- a/app/components/radio_button/radio_button_group.js +++ b/app/components/radio_button/radio_button_group.js @@ -29,6 +29,7 @@ export default class RadioButtonGroup extends PureComponent { if (this.props.options.length) { options = this.props.options.map((option) => { const { + testID, value, label, disabled, @@ -39,6 +40,7 @@ export default class RadioButtonGroup extends PureComponent { return ( { + const baseProps = { + onSelect: jest.fn(), + name: 'name', + }; + + test('should match snapshot', () => { + const options = [{ + testID: 'radio-1', + label: 'label-1', + theme: Preferences.THEMES.default, + value: 'value', + checked: true, + disabled: false, + }, { + testID: 'radio-2', + label: 'label-2', + theme: Preferences.THEMES.default, + value: 'value', + checked: false, + disabled: true, + }]; + + const wrapper = shallowWithIntl( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); +}); diff --git a/app/components/sidebars/settings/__snapshots__/drawer_item.test.js.snap b/app/components/sidebars/settings/__snapshots__/drawer_item.test.js.snap new file mode 100644 index 000000000..910eab0da --- /dev/null +++ b/app/components/sidebars/settings/__snapshots__/drawer_item.test.js.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DrawerItem should match snapshot 1`] = ` + + + + + + + + + + + + + +`; diff --git a/app/components/sidebars/settings/__snapshots__/settings_sidebar.test.js.snap b/app/components/sidebars/settings/__snapshots__/settings_sidebar.test.js.snap new file mode 100644 index 000000000..e5b7bcd91 --- /dev/null +++ b/app/components/sidebars/settings/__snapshots__/settings_sidebar.test.js.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SettingsSidebar should match snapshot 1`] = ` + +`; diff --git a/app/components/sidebars/settings/drawer_item.js b/app/components/sidebars/settings/drawer_item.js index 808d852d5..05f15e5cb 100644 --- a/app/components/sidebars/settings/drawer_item.js +++ b/app/components/sidebars/settings/drawer_item.js @@ -11,6 +11,7 @@ import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; export default class DrawerItem extends PureComponent { static propTypes = { + testID: PropTypes.string, centered: PropTypes.bool, defaultMessage: PropTypes.string, i18nId: PropTypes.string, @@ -31,6 +32,7 @@ export default class DrawerItem extends PureComponent { render() { const { + testID, centered, defaultMessage, i18nId, @@ -81,6 +83,7 @@ export default class DrawerItem extends PureComponent { return ( diff --git a/app/components/sidebars/settings/drawer_item.test.js b/app/components/sidebars/settings/drawer_item.test.js new file mode 100644 index 000000000..db33ee794 --- /dev/null +++ b/app/components/sidebars/settings/drawer_item.test.js @@ -0,0 +1,31 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; +import {shallowWithIntl} from 'test/intl-test-helper'; + +import Preferences from '@mm-redux/constants/preferences'; + +import DrawerItem from './drawer_item'; + +describe('DrawerItem', () => { + const baseProps = { + onPress: jest.fn(), + testID: 'test-id', + centered: true, + defaultMessage: 'default message', + i18nId: 'i18-id', + iconName: 'icon-name', + isDestructor: true, + separator: true, + theme: Preferences.THEMES.default, + }; + + test('should match snapshot', () => { + const wrapper = shallowWithIntl( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); +}); diff --git a/app/components/sidebars/settings/settings_sidebar.test.js b/app/components/sidebars/settings/settings_sidebar.test.js new file mode 100644 index 000000000..4ed6cf465 --- /dev/null +++ b/app/components/sidebars/settings/settings_sidebar.test.js @@ -0,0 +1,31 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; +import {shallowWithIntl} from 'test/intl-test-helper'; + +import Preferences from '@mm-redux/constants/preferences'; + +import SettingsSidebar from './settings_sidebar.ios'; + +describe('SettingsSidebar', () => { + const baseProps = { + actions: { + logout: jest.fn(), + setStatus: jest.fn(), + }, + currentUser: { + id: 'user-id', + }, + status: 'offline', + theme: Preferences.THEMES.default, + }; + + test('should match snapshot', () => { + const wrapper = shallowWithIntl( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); +}); diff --git a/app/components/sidebars/settings/settings_sidebar_base.js b/app/components/sidebars/settings/settings_sidebar_base.js index 7bdd86326..4c33effe8 100644 --- a/app/components/sidebars/settings/settings_sidebar_base.js +++ b/app/components/sidebars/settings/settings_sidebar_base.js @@ -139,6 +139,7 @@ export default class SettingsSidebarBase extends PureComponent { const options = { topBar: { leftButtons: [{ + testID: 'close.settings.button', id: 'close-settings', icon: this.closeButton, }], @@ -188,7 +189,10 @@ export default class SettingsSidebarBase extends PureComponent { const {currentUser, theme} = this.props; return ( - + diff --git a/app/screens/channel/channel_base.js b/app/screens/channel/channel_base.js index dab9ef319..9d40d9ea9 100644 --- a/app/screens/channel/channel_base.js +++ b/app/screens/channel/channel_base.js @@ -184,7 +184,7 @@ export default class ChannelBase extends PureComponent { leftButtons: [{ id: 'close-info', icon: source, - testID: 'screen.channel_info.close', + testID: 'close.channel_info.button', }], }, }; diff --git a/app/screens/channel/channel_nav_bar/__snapshots__/channel_nav_bar.test.js.snap b/app/screens/channel/channel_nav_bar/__snapshots__/channel_nav_bar.test.js.snap index d7b345368..75d520ff2 100644 --- a/app/screens/channel/channel_nav_bar/__snapshots__/channel_nav_bar.test.js.snap +++ b/app/screens/channel/channel_nav_bar/__snapshots__/channel_nav_bar.test.js.snap @@ -18,7 +18,7 @@ exports[`ChannelNavBar should match, full snapshot 1`] = ` ] } > - @@ -57,7 +57,7 @@ exports[`ChannelNavBar should match, full snapshot 1`] = ` } } /> - diff --git a/app/screens/channel/channel_nav_bar/__snapshots__/settings_drawer_button.test.js.snap b/app/screens/channel/channel_nav_bar/__snapshots__/settings_sidebar_drawer_button.test.js.snap similarity index 83% rename from app/screens/channel/channel_nav_bar/__snapshots__/settings_drawer_button.test.js.snap rename to app/screens/channel/channel_nav_bar/__snapshots__/settings_sidebar_drawer_button.test.js.snap index 333fd3215..e4d002b4b 100644 --- a/app/screens/channel/channel_nav_bar/__snapshots__/settings_drawer_button.test.js.snap +++ b/app/screens/channel/channel_nav_bar/__snapshots__/settings_sidebar_drawer_button.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SettingDrawerButton should match, full snapshot 1`] = ` +exports[`SettingsSidebarDrawerButton should match, full snapshot 1`] = ` - @@ -123,7 +123,7 @@ export default class ChannelNavBar extends PureComponent { - + ); } diff --git a/app/screens/channel/channel_nav_bar/channel_drawer_button/__snapshots__/channel_drawer_button.test.js.snap b/app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/__snapshots__/main_sidebar_drawer_button.test.js.snap similarity index 90% rename from app/screens/channel/channel_nav_bar/channel_drawer_button/__snapshots__/channel_drawer_button.test.js.snap rename to app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/__snapshots__/main_sidebar_drawer_button.test.js.snap index 40d39b371..1905433e6 100644 --- a/app/screens/channel/channel_nav_bar/channel_drawer_button/__snapshots__/channel_drawer_button.test.js.snap +++ b/app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/__snapshots__/main_sidebar_drawer_button.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ChannelDrawerButton should match, full snapshot 1`] = ` +exports[`MainSidebarDrawerButton should match, full snapshot 1`] = ` `; -exports[`ChannelDrawerButton should match, full snapshot 2`] = ` +exports[`MainSidebarDrawerButton should match, full snapshot 2`] = ` {icon} diff --git a/app/screens/channel/channel_nav_bar/channel_drawer_button/channel_drawer_button.test.js b/app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/main_sidebar_drawer_button.test.js similarity index 89% rename from app/screens/channel/channel_nav_bar/channel_drawer_button/channel_drawer_button.test.js rename to app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/main_sidebar_drawer_button.test.js index 14254e2cc..6555ab4a7 100644 --- a/app/screens/channel/channel_nav_bar/channel_drawer_button/channel_drawer_button.test.js +++ b/app/screens/channel/channel_nav_bar/main_sidebar_drawer_button/main_sidebar_drawer_button.test.js @@ -10,7 +10,7 @@ import Badge from 'app/components/badge'; import PushNotification from 'app/push_notifications/push_notifications.ios'; import {shallowWithIntl} from 'test/intl-test-helper'; -import ChannelDrawerButton from './channel_drawer_button'; +import MainSidebarDrawerButton from './main_sidebar_drawer_button'; jest.mock('react-native-notifications', () => { let badgesCount = 0; @@ -37,7 +37,7 @@ jest.mock('react-native-notifications', () => { }; }); -describe('ChannelDrawerButton', () => { +describe('MainSidebarDrawerButton', () => { const baseProps = { openSidebar: jest.fn(), badgeCount: 0, @@ -49,7 +49,7 @@ describe('ChannelDrawerButton', () => { test('should match, full snapshot', () => { const wrapper = shallowWithIntl( - , + , ); // no badge to show @@ -70,7 +70,7 @@ describe('ChannelDrawerButton', () => { }; shallowWithIntl( - , + , ); expect(setApplicationIconBadgeNumber).not.toBeCalled(); NotificationsIOS.getBadgesCount((count) => expect(count).toBe(0)); @@ -84,7 +84,7 @@ describe('ChannelDrawerButton', () => { }; shallowWithIntl( - , + , ); expect(setApplicationIconBadgeNumber).toHaveBeenCalledTimes(1); NotificationsIOS.getBadgesCount((count) => expect(count).toBe(1)); @@ -98,7 +98,7 @@ describe('ChannelDrawerButton', () => { }; const wrapper = shallowWithIntl( - , + , ); NotificationsIOS.getBadgesCount((count) => expect(count).toBe(0)); @@ -116,7 +116,7 @@ describe('ChannelDrawerButton', () => { }; const wrapper = shallowWithIntl( - , + , ); wrapper.setProps({badgeCount: 2}); expect(setApplicationIconBadgeNumber).toHaveBeenCalledWith(2); @@ -129,21 +129,21 @@ describe('ChannelDrawerButton', () => { test('Should be accessible', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessible).toBeTruthy(); }); test('Should have the correct accessibilityHint', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessibilityHint).toEqual('Opens the channels and teams drawer'); }); test('Should have the correct accessibilityLabel', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessibilityLabel).toEqual('Channels and teams'); }); diff --git a/app/screens/channel/channel_nav_bar/settings_drawer_button.js b/app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.js similarity index 93% rename from app/screens/channel/channel_nav_bar/settings_drawer_button.js rename to app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.js index 3cceb2815..1e4582a3d 100644 --- a/app/screens/channel/channel_nav_bar/settings_drawer_button.js +++ b/app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.js @@ -17,7 +17,7 @@ import {preventDoubleTap} from '@utils/tap'; import {makeStyleSheetFromTheme} from '@utils/theme'; import {t} from '@utils/i18n'; -export class SettingDrawerButton extends PureComponent { +export class SettingsSidebarDrawerButton extends PureComponent { static propTypes = { openSidebar: PropTypes.func.isRequired, theme: PropTypes.object, @@ -70,7 +70,7 @@ export class SettingDrawerButton extends PureComponent { accessibilityHint={accessibilityHint} accessibilityLabel={accessibilityLabel} accessibilityRole='button' - testID='sidebar.settings.button' + testID='settings_sidebar_drawer.button' onPress={this.handlePress} style={style.container} > @@ -107,4 +107,4 @@ function mapStateToProps(state) { }; } -export default connect(mapStateToProps)(SettingDrawerButton); +export default connect(mapStateToProps)(SettingsSidebarDrawerButton); diff --git a/app/screens/channel/channel_nav_bar/settings_drawer_button.test.js b/app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.test.js similarity index 75% rename from app/screens/channel/channel_nav_bar/settings_drawer_button.test.js rename to app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.test.js index e0a1fca62..decbd0190 100644 --- a/app/screens/channel/channel_nav_bar/settings_drawer_button.test.js +++ b/app/screens/channel/channel_nav_bar/settings_sidebar_drawer_button.test.js @@ -4,11 +4,11 @@ import React from 'react'; import Preferences from '@mm-redux/constants/preferences'; -import {SettingDrawerButton} from './settings_drawer_button'; +import {SettingsSidebarDrawerButton} from './settings_sidebar_drawer_button'; import {shallowWithIntl} from 'test/intl-test-helper'; -describe('SettingDrawerButton', () => { +describe('SettingsSidebarDrawerButton', () => { const baseProps = { openSidebar: jest.fn(), theme: Preferences.THEMES.default, @@ -16,28 +16,28 @@ describe('SettingDrawerButton', () => { test('should match, full snapshot', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper).toMatchSnapshot(); }); test('Should be accessible', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessible).toBeTruthy(); }); test('Should have the correct accessibilityHint', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessibilityHint).toEqual('Opens the more options right hand sidebar'); }); test('Should have the correct accessibilityLabel', () => { const wrapper = shallowWithIntl( - , + , ); expect(wrapper.props().accessibilityLabel).toEqual('More Options'); }); diff --git a/app/screens/channel_info/__snapshots__/channel_info.test.js.snap b/app/screens/channel_info/__snapshots__/channel_info.test.js.snap index c018b780e..6b26c12e3 100644 --- a/app/screens/channel_info/__snapshots__/channel_info.test.js.snap +++ b/app/screens/channel_info/__snapshots__/channel_info.test.js.snap @@ -272,6 +272,7 @@ exports[`channelInfo should match snapshot 1`] = ` + + + + + detail + + + + +`; diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index dddd77331..ea812df37 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -131,6 +131,7 @@ export default class ChannelInfo extends PureComponent { {!isDirectMessage && <> @@ -155,6 +156,7 @@ export default class ChannelInfo extends PureComponent { theme={theme} /> diff --git a/app/screens/channel_info/channel_info_row.js b/app/screens/channel_info/channel_info_row.js index 6ca2b6465..3a3d07d05 100644 --- a/app/screens/channel_info/channel_info_row.js +++ b/app/screens/channel_info/channel_info_row.js @@ -25,7 +25,7 @@ function createTouchableComponent(children, action) { } function channelInfoRow(props) { - const {action, defaultMessage, detail, icon, iconColor, image, imageTintColor, rightArrow, textColor, textId, togglable, theme, shouldRender, isLandscape} = props; + const {testID, action, defaultMessage, detail, icon, iconColor, image, imageTintColor, rightArrow, textColor, textId, togglable, theme, shouldRender, isLandscape} = props; if (!shouldRender) { return null; @@ -70,7 +70,10 @@ function channelInfoRow(props) { } const RowComponent = ( - + {iconElement} { + const baseProps = { + action: jest.fn(), + testID: 'test-id', + defaultMessage: 'default-message', + detail: 'detail', + icon: 'icon', + iconColor: '#ababab', + image: 1, + imageTintColor: '#ffffff', + isLandscape: false, + rightArrow: true, + textId: 'text-id', + togglable: false, + textColor: '#000000', + theme: Preferences.THEMES.default, + }; + + test('should match snapshot', () => { + const wrapper = shallowWithIntl( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); +}); diff --git a/app/screens/channel_info/edit_channel/__snapshots__/edit_channel.test.js.snap b/app/screens/channel_info/edit_channel/__snapshots__/edit_channel.test.js.snap index e78414fa6..87473a7c2 100644 --- a/app/screens/channel_info/edit_channel/__snapshots__/edit_channel.test.js.snap +++ b/app/screens/channel_info/edit_channel/__snapshots__/edit_channel.test.js.snap @@ -40,6 +40,7 @@ exports[`ChannelInfo -> EditChannel should match snapshot for Edit Channel 1`] = isLandscape={false} rightArrow={true} shouldRender={true} + testID="test-id" textId="mobile.channel_info.edit" theme={ Object { diff --git a/app/screens/channel_info/edit_channel/edit_channel.test.js b/app/screens/channel_info/edit_channel/edit_channel.test.js index 11bf35a53..f97e48bd2 100644 --- a/app/screens/channel_info/edit_channel/edit_channel.test.js +++ b/app/screens/channel_info/edit_channel/edit_channel.test.js @@ -18,6 +18,7 @@ jest.mock('@utils/theme', () => { describe('ChannelInfo -> EditChannel', () => { const baseProps = { + testID: 'test-id', canEdit: true, isLandscape: false, theme: Preferences.THEMES.default, diff --git a/app/screens/channel_info/edit_channel/edit_channel.tsx b/app/screens/channel_info/edit_channel/edit_channel.tsx index e2878a82a..109385976 100644 --- a/app/screens/channel_info/edit_channel/edit_channel.tsx +++ b/app/screens/channel_info/edit_channel/edit_channel.tsx @@ -12,6 +12,7 @@ import {t} from '@utils/i18n'; import {preventDoubleTap} from '@utils/tap'; interface EditChannelProps { + testID?: string; canEdit: boolean; isLandscape: boolean; theme: Theme; @@ -33,7 +34,7 @@ export default class EditChannel extends PureComponent { }); render() { - const {canEdit, isLandscape, theme} = this.props; + const {testID, canEdit, isLandscape, theme} = this.props; if (!canEdit) { return null; @@ -43,6 +44,7 @@ export default class EditChannel extends PureComponent { <> +`; diff --git a/app/screens/channel_info/notification_preference/notification_preference.test.js b/app/screens/channel_info/notification_preference/notification_preference.test.js new file mode 100644 index 000000000..d2bfba623 --- /dev/null +++ b/app/screens/channel_info/notification_preference/notification_preference.test.js @@ -0,0 +1,30 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; +import {shallowWithIntl} from 'test/intl-test-helper'; + +import Preferences from '@mm-redux/constants/preferences'; + +import NotificationPreference from './notification_preference'; + +describe('NotificationPreference', () => { + const baseProps = { + testID: 'test-id', + channelId: 'channel-id', + userId: 'user-id', + notifyProps: { + push: 'default', + }, + isLandscape: false, + theme: Preferences.THEMES.default, + }; + + test('should match snapshot', () => { + const wrapper = shallowWithIntl( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); +}); diff --git a/app/screens/channel_info/notification_preference/notification_preference.tsx b/app/screens/channel_info/notification_preference/notification_preference.tsx index af96f25db..1b248857c 100644 --- a/app/screens/channel_info/notification_preference/notification_preference.tsx +++ b/app/screens/channel_info/notification_preference/notification_preference.tsx @@ -13,6 +13,7 @@ import {t} from '@utils/i18n'; import {preventDoubleTap} from '@utils/tap'; interface NotificationPreferenceProps { + testID?: string; channelId: string; userId: string; notifyProps: ChannelNotifyProps; @@ -65,7 +66,7 @@ export default class NotificationPreference extends PureComponent + + + + + + + + + } + selected={true} + theme={ + Object { + "awayIndicator": "#ffbc42", + "buttonBg": "#166de0", + "buttonColor": "#ffffff", + "centerChannelBg": "#ffffff", + "centerChannelColor": "#3d3c40", + "codeTheme": "github", + "dndIndicator": "#f74343", + "errorTextColor": "#fd5960", + "linkColor": "#2389d7", + "mentionBg": "#ffffff", + "mentionBj": "#ffffff", + "mentionColor": "#145dbf", + "mentionHighlightBg": "#ffe577", + "mentionHighlightLink": "#166de0", + "newMessageSeparator": "#ff8800", + "onlineIndicator": "#06d6a0", + "sidebarBg": "#145dbf", + "sidebarHeaderBg": "#1153ab", + "sidebarHeaderTextColor": "#ffffff", + "sidebarText": "#ffffff", + "sidebarTextActiveBorder": "#579eff", + "sidebarTextActiveColor": "#ffffff", + "sidebarTextHoverBg": "#4578bf", + "sidebarUnreadText": "#ffffff", + "type": "Mattermost", + } + } + /> + + + + + } + selected={false} + theme={ + Object { + "awayIndicator": "#ffbc42", + "buttonBg": "#166de0", + "buttonColor": "#ffffff", + "centerChannelBg": "#ffffff", + "centerChannelColor": "#3d3c40", + "codeTheme": "github", + "dndIndicator": "#f74343", + "errorTextColor": "#fd5960", + "linkColor": "#2389d7", + "mentionBg": "#ffffff", + "mentionBj": "#ffffff", + "mentionColor": "#145dbf", + "mentionHighlightBg": "#ffe577", + "mentionHighlightLink": "#166de0", + "newMessageSeparator": "#ff8800", + "onlineIndicator": "#06d6a0", + "sidebarBg": "#145dbf", + "sidebarHeaderBg": "#1153ab", + "sidebarHeaderTextColor": "#ffffff", + "sidebarText": "#ffffff", + "sidebarTextActiveBorder": "#579eff", + "sidebarTextActiveColor": "#ffffff", + "sidebarTextHoverBg": "#4578bf", + "sidebarUnreadText": "#ffffff", + "type": "Mattermost", + } + } + /> + + + + + } + selected={false} + theme={ + Object { + "awayIndicator": "#ffbc42", + "buttonBg": "#166de0", + "buttonColor": "#ffffff", + "centerChannelBg": "#ffffff", + "centerChannelColor": "#3d3c40", + "codeTheme": "github", + "dndIndicator": "#f74343", + "errorTextColor": "#fd5960", + "linkColor": "#2389d7", + "mentionBg": "#ffffff", + "mentionBj": "#ffffff", + "mentionColor": "#145dbf", + "mentionHighlightBg": "#ffe577", + "mentionHighlightLink": "#166de0", + "newMessageSeparator": "#ff8800", + "onlineIndicator": "#06d6a0", + "sidebarBg": "#145dbf", + "sidebarHeaderBg": "#1153ab", + "sidebarHeaderTextColor": "#ffffff", + "sidebarText": "#ffffff", + "sidebarTextActiveBorder": "#579eff", + "sidebarTextActiveColor": "#ffffff", + "sidebarTextHoverBg": "#4578bf", + "sidebarUnreadText": "#ffffff", + "type": "Mattermost", + } + } + /> + + + + + } + selected={false} + theme={ + Object { + "awayIndicator": "#ffbc42", + "buttonBg": "#166de0", + "buttonColor": "#ffffff", + "centerChannelBg": "#ffffff", + "centerChannelColor": "#3d3c40", + "codeTheme": "github", + "dndIndicator": "#f74343", + "errorTextColor": "#fd5960", + "linkColor": "#2389d7", + "mentionBg": "#ffffff", + "mentionBj": "#ffffff", + "mentionColor": "#145dbf", + "mentionHighlightBg": "#ffe577", + "mentionHighlightLink": "#166de0", + "newMessageSeparator": "#ff8800", + "onlineIndicator": "#06d6a0", + "sidebarBg": "#145dbf", + "sidebarHeaderBg": "#1153ab", + "sidebarHeaderTextColor": "#ffffff", + "sidebarText": "#ffffff", + "sidebarTextActiveBorder": "#579eff", + "sidebarTextActiveColor": "#ffffff", + "sidebarTextHoverBg": "#4578bf", + "sidebarUnreadText": "#ffffff", + "type": "Mattermost", + } + } + /> + + + + + + +`; diff --git a/app/screens/channel_notification_preference/channel_notification_preference.android.js b/app/screens/channel_notification_preference/channel_notification_preference.android.js index 4e9d69b1a..7608a1cac 100644 --- a/app/screens/channel_notification_preference/channel_notification_preference.android.js +++ b/app/screens/channel_notification_preference/channel_notification_preference.android.js @@ -39,7 +39,10 @@ export default class ChannelNotificationPreferenceAndroid extends ChannelNotific const options = this.getRadioItems(); return ( - + - + { + test('should match snapshot', () => { + const baseProps = makeProps('default'); + const wrapper = shallowWithIntlMessages( + , + ); + + expect(wrapper.getElement()).toMatchSnapshot(); + }); + test('should have correct setting selected', () => { checkNotificationSelected(null, 0); checkNotificationSelected(ViewTypes.NotificationLevels.DEFAULT, 0); diff --git a/app/screens/settings/general/settings.js b/app/screens/settings/general/settings.js index e2d14b43f..36b3854dd 100644 --- a/app/screens/settings/general/settings.js +++ b/app/screens/settings/general/settings.js @@ -189,7 +189,10 @@ class Settings extends PureComponent { } return ( - + + - + @@ -168,6 +174,7 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase { @@ -181,6 +188,7 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase { @@ -427,6 +435,7 @@ class NotificationSettingsMobileAndroid extends NotificationSettingsMobileBase { return ( + - + + {labelComponent} {descriptionComponent} diff --git a/app/screens/settings/settings_item/index.js b/app/screens/settings/settings_item/index.js index f1d2e0cea..d4225d12a 100644 --- a/app/screens/settings/settings_item/index.js +++ b/app/screens/settings/settings_item/index.js @@ -14,6 +14,7 @@ import getStyleSheet from './style'; export default class SettingsItem extends PureComponent { static propTypes = { + testID: PropTypes.string, defaultMessage: PropTypes.string.isRequired, messageValues: PropTypes.object, i18nId: PropTypes.string, @@ -78,6 +79,7 @@ export default class SettingsItem extends PureComponent { render() { const { + testID, iconName, onPress, rightComponent, @@ -126,6 +128,7 @@ export default class SettingsItem extends PureComponent { return ( diff --git a/detox/e2e/support/ui/component/index.js b/detox/e2e/support/ui/component/index.js index 1511323a4..4fdad11a5 100644 --- a/detox/e2e/support/ui/component/index.js +++ b/detox/e2e/support/ui/component/index.js @@ -2,11 +2,13 @@ // See LICENSE.txt for license information. import Autocomplete from './autocomplete'; -import ChannelSidebar from './channel_sidebar'; +import MainSidebar from './main_sidebar'; import PostOptions from './post_options'; +import SettingsSidebar from './settings_sidebar'; export { Autocomplete, - ChannelSidebar, + MainSidebar, PostOptions, + SettingsSidebar, }; diff --git a/detox/e2e/support/ui/component/channel_sidebar.js b/detox/e2e/support/ui/component/main_sidebar.js similarity index 86% rename from detox/e2e/support/ui/component/channel_sidebar.js rename to detox/e2e/support/ui/component/main_sidebar.js index 8254d7f69..0f25a7851 100644 --- a/detox/e2e/support/ui/component/channel_sidebar.js +++ b/detox/e2e/support/ui/component/main_sidebar.js @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -class ChannelSidebar { +class MainSidebar { testID = { mainSidebar: 'main.sidebar', channelItemDisplayName: 'channel_item.display_name', @@ -17,7 +17,9 @@ class ChannelSidebar { addDirectChannel = element(by.id(this.testID.addDirectChannel)); toBeVisible = async () => { - await expect(element(by.id(this.testID.mainSidebar))).toBeVisible(); + await expect(this.mainSidebar).toBeVisible(); + + return this.mainSidebar; } getChannelByDisplayName = (displayName) => { @@ -31,5 +33,5 @@ class ChannelSidebar { } } -const channelSidebar = new ChannelSidebar(); -export default channelSidebar; +const mainSidebar = new MainSidebar(); +export default mainSidebar; diff --git a/detox/e2e/support/ui/component/post_options.js b/detox/e2e/support/ui/component/post_options.js index 37e328e18..f7ceb08cf 100644 --- a/detox/e2e/support/ui/component/post_options.js +++ b/detox/e2e/support/ui/component/post_options.js @@ -7,10 +7,13 @@ class PostOptions { openReactionPicker: 'open.reaction_picker', } + postOptions = element(by.id(this.testID.postOptions)); openReactionPicker = element(by.id(this.testID.openReactionPicker)); toBeVisible = async () => { - await expect(element(by.id(this.testID.postOptions))).toBeVisible(); + await expect(this.postOptions).toBeVisible(); + + return postOptions; } } diff --git a/detox/e2e/support/ui/component/settings_sidebar.js b/detox/e2e/support/ui/component/settings_sidebar.js new file mode 100644 index 000000000..9d559a584 --- /dev/null +++ b/detox/e2e/support/ui/component/settings_sidebar.js @@ -0,0 +1,23 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +class SettingsSidebar { + testID = { + settingsSidebar: 'settings.sidebar', + settingsAction: 'settings.sidebar.settings.action', + logoutAction: 'settings.sidebar.logout.action', + } + + settingsSidebar = element(by.id(this.testID.settingsSidebar)); + settingsAction = element(by.id(this.testID.settingsAction)); + logoutAction = element(by.id(this.testID.logoutAction)); + + toBeVisible = async () => { + await expect(this.settingsSidebar).toBeVisible(); + + return this.settingsSidebar; + } +} + +const settingsSidebar = new SettingsSidebar(); +export default settingsSidebar; diff --git a/detox/e2e/support/ui/screen/channel.js b/detox/e2e/support/ui/screen/channel.js index 9be38a8dd..b04128b61 100644 --- a/detox/e2e/support/ui/screen/channel.js +++ b/detox/e2e/support/ui/screen/channel.js @@ -1,12 +1,13 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {SettingsSidebar} from '@support/ui/component'; import {LoginScreen, SelectServerScreen} from '@support/ui/screen'; class ChannelScreen { testID = { channelScreen: 'channel.screen', - channelDrawerButton: 'channel_drawer.button', + mainSidebarDrawerButton: 'main_sidebar_drawer.button', channelIntro: 'channel_intro.beginning.text', channelNavBarTitle: 'channel.nav_bar.title', channelSearchButton: 'channel.search.button', @@ -14,11 +15,11 @@ class ChannelScreen { disabledSendButton: 'disabled_send.button', postInput: 'post.input', sendButton: 'send.button', - sidebarSettingsButton: 'sidebar.settings.button', + settingsSidebarDrawerButton: 'settings_sidebar_drawer.button', } channelScreen = element(by.id(this.testID.channelScreen)); - channelDrawerButton = element(by.id(this.testID.channelDrawerButton)); + mainSidebarDrawerButton = element(by.id(this.testID.mainSidebarDrawerButton)); channelIntro = element(by.id(this.testID.channelIntro)); channelNavBarTitle = element(by.id(this.testID.channelNavBarTitle)); channelSearchButton = element(by.id(this.testID.channelSearchButton)); @@ -26,7 +27,7 @@ class ChannelScreen { disabledSendButton = element(by.id(this.testID.disabledSendButton)); postInput = element(by.id(this.testID.postInput)); sendButton = element(by.id(this.testID.sendButton)); - sidebarSettingsButton = element(by.id(this.testID.sidebarSettingsButton)); + settingsSidebarDrawerButton = element(by.id(this.testID.settingsSidebarDrawerButton)); toBeVisible = async () => { await expect(this.channelScreen).toBeVisible(); @@ -42,8 +43,8 @@ class ChannelScreen { } logout = async () => { - await this.sidebarSettingsButton.tap(); - await element(by.text('Logout')).tap(); + await this.settingsSidebarDrawerButton.tap(); + await SettingsSidebar.logoutAction.tap(); await SelectServerScreen.toBeVisible(); } } diff --git a/detox/e2e/support/ui/screen/channel_info.js b/detox/e2e/support/ui/screen/channel_info.js index ebaf35dfc..115500377 100644 --- a/detox/e2e/support/ui/screen/channel_info.js +++ b/detox/e2e/support/ui/screen/channel_info.js @@ -2,34 +2,40 @@ // See LICENSE.txt for license information. import {ChannelScreen} from '@support/ui/screen'; +import {timeouts, wait} from '@support/utils'; class ChannelInfoScreen { testID = { channelInfoScreen: 'channel_info.screen', - channelInfoClose: 'screen.channel_info.close', + closeChannelInfoButton: 'close.channel_info.button', channelIconGMMemberCount: 'channel_icon.gm_member_count', + notificationPreferenceAction: 'channel_info.notification_preference.action', + editChannelAction: 'channel_info.edit_channel.action', } channelInfoScreen = element(by.id(this.testID.channelInfoScreen)); - channelInfoClose = element(by.id(this.testID.channelInfoClose)); + closeChannelInfoButton = element(by.id(this.testID.closeChannelInfoButton)); channelIconGMMemberCount = element(by.id(this.testID.channelIconGMMemberCount)); + notificationPreferenceAction = element(by.id(this.testID.notificationPreferenceAction)); + editChannelAction = element(by.id(this.testID.editChannelAction)); toBeVisible = async () => { - const screen = await this.channelInfoScreen; - await expect(screen).toBeVisible(); + await wait(timeouts.TWO_SEC); + await expect(this.channelInfoScreen).toBeVisible(); - return screen; + return this.channelInfoScreen; } open = async () => { - // # Open channel info + // # Open channel info screen await ChannelScreen.channelTitleButton.tap(); return this.toBeVisible(); } close = async () => { - await this.channelInfoClose.tap(); + await wait(timeouts.TWO_SEC); + await this.closeChannelInfoButton.tap(); await expect(this.channelInfoScreen).not.toBeVisible(); } } diff --git a/detox/e2e/support/ui/screen/channel_notification_preference.js b/detox/e2e/support/ui/screen/channel_notification_preference.js new file mode 100644 index 000000000..dd263720a --- /dev/null +++ b/detox/e2e/support/ui/screen/channel_notification_preference.js @@ -0,0 +1,42 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {ChannelInfoScreen} from '@support/ui/screen'; + +class ChannelNotificationPreferenceScreen { + testID = { + channelNotificationPreferenceScreen: 'channel_notification_preference.screen', + backButton: 'screen.back.button', + } + + channelNotificationPreferenceScreen = element(by.id(this.testID.channelNotificationPreferenceScreen)); + backButton = element(by.id(this.testID.backButton)); + + titleText = 'Mobile Notifications'; + headerText = 'Send Notifications'; + optionDefaultText = 'Global default'; + optionAllText = 'For all activity'; + optionMentionsText = 'Only mentions and direct messages'; + optionNeverText = 'Never'; + + toBeVisible = async () => { + await expect(this.channelNotificationPreferenceScreen).toBeVisible(); + + return this.channelNotificationPreferenceScreen; + } + + open = async () => { + // # Open channel notification preference screen + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + return this.toBeVisible(); + } + + back = async () => { + await this.backButton.tap(); + await expect(this.channelNotificationPreferenceScreen).not.toBeVisible(); + } +} + +const channelNotificationPreferenceScreen = new ChannelNotificationPreferenceScreen(); +export default channelNotificationPreferenceScreen; diff --git a/detox/e2e/support/ui/screen/create_channel.js b/detox/e2e/support/ui/screen/create_channel.js index 9965747e6..ff64b87bd 100644 --- a/detox/e2e/support/ui/screen/create_channel.js +++ b/detox/e2e/support/ui/screen/create_channel.js @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {ChannelScreen} from '@support/ui/screen'; +import {ChannelInfoScreen} from '@support/ui/screen'; class CreateChannelScreen { testID = { @@ -27,9 +27,11 @@ class CreateChannelScreen { } open = async () => { - // # Open channel info then tap 'Edit Channel' - await ChannelScreen.channelTitleButton.tap(); - await element(by.text('Edit Channel')).tap(); + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Edit Channel + await ChannelInfoScreen.editChannelAction.tap(); return this.toBeVisible(); } diff --git a/detox/e2e/support/ui/screen/direct_channels.js b/detox/e2e/support/ui/screen/direct_channels.js index 83e04deff..da3b2dc48 100644 --- a/detox/e2e/support/ui/screen/direct_channels.js +++ b/detox/e2e/support/ui/screen/direct_channels.js @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {ChannelScreen} from '@support/ui/component'; -import {ChannelSidebar} from '@support/ui/screen'; +import {MainSidebar} from '@support/ui/screen'; class DirectChannelsScreen { testID = { @@ -24,8 +24,8 @@ class DirectChannelsScreen { } open = async () => { - await ChannelScreen.channelDrawerButton.tap(); - await ChannelSidebar.addDirectChannel.tap(); + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.addDirectChannel.tap(); return this.toBeVisible(); } diff --git a/detox/e2e/support/ui/screen/general_settings.js b/detox/e2e/support/ui/screen/general_settings.js new file mode 100644 index 000000000..456a7644e --- /dev/null +++ b/detox/e2e/support/ui/screen/general_settings.js @@ -0,0 +1,37 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {SettingsSidebar} from '@support/ui/component'; + +class GeneralSettingsScreen { + testID = { + generalSettingsScreen: 'general_settings.screen', + closeSettingsButton: 'close.settings.button', + notificationsAction: 'general_settings.notifications.action', + } + + generalSettingsScreen = element(by.id(this.testID.generalSettingsScreen)); + closeSettingsButton = element(by.id(this.testID.closeSettingsButton)); + notificationsAction = element(by.id(this.testID.notificationsAction)); + + toBeVisible = async () => { + await expect(this.generalSettingsScreen).toBeVisible(); + + return this.generalSettingsScreen; + } + + open = async () => { + // # Open general settings screen + await SettingsSidebar.settingsAction.tap(); + + return this.toBeVisible(); + } + + close = async () => { + await this.closeSettingsButton.tap(); + await expect(this.generalSettingsScreen).not.toBeVisible(); + } +} + +const generalSettingsScreen = new GeneralSettingsScreen(); +export default generalSettingsScreen; diff --git a/detox/e2e/support/ui/screen/index.js b/detox/e2e/support/ui/screen/index.js index e1864ce5e..a7978a536 100644 --- a/detox/e2e/support/ui/screen/index.js +++ b/detox/e2e/support/ui/screen/index.js @@ -3,28 +3,36 @@ import AddReactionScreen from './add_reaction'; import ChannelInfoScreen from './channel_info'; +import ChannelNotificationPreferenceScreen from './channel_notification_preference'; import ChannelScreen from './channel'; import CreateChannelScreen from './create_channel'; import DirectChannelsScreen from './direct_channels'; import EditChannelScreen from './edit_channel'; import EditPostScreen from './edit_post'; +import GeneralSettingsScreen from './general_settings'; import LoginScreen from './login'; import MoreChannelsScreen from './more_channels'; import NotificationScreen from './notification'; +import NotificationSettingsMobileScreen from './notification_settings_mobile'; +import NotificationSettingsScreen from './notification_settings'; import SearchScreen from './search'; import SelectServerScreen from './select_server'; export { AddReactionScreen, - ChannelScreen, ChannelInfoScreen, + ChannelNotificationPreferenceScreen, + ChannelScreen, CreateChannelScreen, DirectChannelsScreen, EditChannelScreen, EditPostScreen, + GeneralSettingsScreen, LoginScreen, MoreChannelsScreen, NotificationScreen, + NotificationSettingsMobileScreen, + NotificationSettingsScreen, SearchScreen, SelectServerScreen, }; diff --git a/detox/e2e/support/ui/screen/more_channels.js b/detox/e2e/support/ui/screen/more_channels.js index 6a8e22c1b..2c107b834 100644 --- a/detox/e2e/support/ui/screen/more_channels.js +++ b/detox/e2e/support/ui/screen/more_channels.js @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {ChannelScreen} from '@support/ui/component'; -import {ChannelSidebar} from '@support/ui/screen'; +import {MainSidebar} from '@support/ui/screen'; class MoreChannelsScreen { testID = { @@ -20,8 +20,8 @@ class MoreChannelsScreen { } open = async () => { - await ChannelScreen.channelDrawerButton.tap(); - await ChannelSidebar.addChannel.tap(); + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.addChannel.tap(); return this.toBeVisible(); } diff --git a/detox/e2e/support/ui/screen/notification_settings.js b/detox/e2e/support/ui/screen/notification_settings.js new file mode 100644 index 000000000..866043f1f --- /dev/null +++ b/detox/e2e/support/ui/screen/notification_settings.js @@ -0,0 +1,37 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {GeneralSettingsScreen} from '@support/ui/screen'; + +class NotificationSettingsScreen { + testID = { + notificationSettingsScreen: 'notification_settings.screen', + backButton: 'screen.back.button', + mobileAction: 'notification_settings.mobile.action', + } + + notificationSettingsScreen = element(by.id(this.testID.notificationSettingsScreen)); + backButton = element(by.id(this.testID.backButton)); + mobileAction = element(by.id(this.testID.mobileAction)); + + toBeVisible = async () => { + await expect(this.notificationSettingsScreen).toBeVisible(); + + return this.notificationSettingsScreen; + } + + open = async () => { + // # Open notification settings screen + await GeneralSettingsScreen.notificationAction.tap(); + + return this.toBeVisible(); + } + + back = async () => { + await this.backButton.tap(); + await expect(this.notificationSettingsScreen).not.toBeVisible(); + } +} + +const notificationSettingsScreen = new NotificationSettingsScreen(); +export default notificationSettingsScreen; diff --git a/detox/e2e/support/ui/screen/notification_settings_mobile.js b/detox/e2e/support/ui/screen/notification_settings_mobile.js new file mode 100644 index 000000000..f33b2f5bc --- /dev/null +++ b/detox/e2e/support/ui/screen/notification_settings_mobile.js @@ -0,0 +1,66 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {NotificationSettingsScreen} from '@support/ui/screen'; + +class NotificationSettingsMobileScreen { + testID = { + notificationSettingsMobileScreen: 'notification_settings_mobile.screen', + backButton: 'screen.back.button', + allAction: 'notification_settings_mobile.all.action', + mentionsAction: 'notification_settings_mobile.mentions.action', + neverAction: 'notification_settings_mobile.never.action', + + // ANDROID ONLY + pushAction: 'notification_settings_mobile.push.action', + pushModal: 'notification_settings_mobile.push.modal', + pushModalCancelButton: 'notification_settings_mobile.push_modal_cancel.button', + pushModalSaveButton: 'notification_settings_mobile.push_modal_save.button', + } + + notificationSettingsMobileScreen = element(by.id(this.testID.notificationSettingsMobileScreen)); + backButton = element(by.id(this.testID.backButton)); + allAction = element(by.id(this.testID.allAction)); + mentionsAction = element(by.id(this.testID.mentionsAction)); + neverAction = element(by.id(this.testID.neverAction)); + + // ANDROID ONLY + pushAction = element(by.id(this.testID.pushAction)); + pushModal = element(by.id(this.testID.pushModal)); + pushModalCancelButton = element(by.id(this.testID.pushModalCancelButton)); + pushModalSaveButton = element(by.id(this.testID.pushModalSaveButton)); + + toBeVisible = async () => { + await expect(this.notificationSettingsMobileScreen).toBeVisible(); + + return this.notificationSettingsMobileScreen; + } + + open = async () => { + // # Open notification settings mobile screen + await NotificationSettingsScreen.mobileAction.tap(); + + return this.toBeVisible(); + } + + back = async () => { + await this.backButton.tap(); + await expect(this.notificationSettingsMobileScreen).not.toBeVisible(); + } + + getPushActionFor(pushKey) { + switch (pushKey) { + case 'all': + return this.allAction; + case 'mentions': + return this.mentionsAction; + case 'never': + return this.neverAction; + default: + throw new Error('Not a valid push option: ' + pushKey); + } + } +} + +const notificationSettingsMobileScreen = new NotificationSettingsMobileScreen(); +export default notificationSettingsMobileScreen; diff --git a/detox/e2e/test/channel_info/header.e2e.js b/detox/e2e/test/channel_info/header.e2e.js index 46af796f0..865b58e8d 100644 --- a/detox/e2e/test/channel_info/header.e2e.js +++ b/detox/e2e/test/channel_info/header.e2e.js @@ -7,10 +7,10 @@ // - Use element testID when selecting an element. Create one if none. // ******************************************************************* -import {ChannelSidebar} from '@support/ui/component'; +import {MainSidebar} from '@support/ui/component'; import { - ChannelScreen, ChannelInfoScreen, + ChannelScreen, DirectChannelsScreen, } from '@support/ui/screen'; import {timeouts, wait} from '@support/utils'; @@ -27,18 +27,21 @@ describe('Channel Info Header', () => { }); it('MM-T3406 should render correct GM member count in channel info header', async () => { - // # Open drawer - await ChannelScreen.channelDrawerButton.tap(); - await expect(element(by.text('DIRECT MESSAGES'))).toBeVisible(); + // # Open main sidebar + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.toBeVisible(); // # Open Direct Channels screen - await ChannelSidebar.addDirectChannel.tap(); + await MainSidebar.addDirectChannel.tap(); await DirectChannelsScreen.toBeVisible(); // # Wait for some profiles to load await wait(timeouts.ONE_SEC); - const {getUserAtIndex, startButton} = DirectChannelsScreen; + const { + getUserAtIndex, + startButton, + } = DirectChannelsScreen; // # Select 3 profiles await getUserAtIndex(0).tap(); @@ -48,7 +51,7 @@ describe('Channel Info Header', () => { // # Create a GM with selected profiles await startButton.tap(); - // # Open channel info modal + // # Open channel info screen await ChannelInfoScreen.open(); // * Verify GM member count is 3 diff --git a/detox/e2e/test/channels/create_public_channel.e2e.js b/detox/e2e/test/channels/create_public_channel.e2e.js index 8a5ac76f9..22f0c9ce9 100644 --- a/detox/e2e/test/channels/create_public_channel.e2e.js +++ b/detox/e2e/test/channels/create_public_channel.e2e.js @@ -9,7 +9,7 @@ import jestExpect from 'expect'; -import {ChannelSidebar} from '@support/ui/component'; +import {MainSidebar} from '@support/ui/component'; import { ChannelScreen, ChannelInfoScreen, @@ -31,10 +31,10 @@ describe('Channels', () => { it('MM-T3201 Create public channel', async () => { // # Go to channel sidebar list - await ChannelScreen.channelDrawerButton.tap(); + await ChannelScreen.mainSidebarDrawerButton.tap(); // # Tap on + public channels - await ChannelSidebar.addChannel.tap(); + await MainSidebar.addChannel.tap(); // * Expect a list of public channels, initially empty await MoreChannelsScreen.toBeVisible(); @@ -77,7 +77,7 @@ describe('Channels', () => { // * Expect a redirection to the created channel await expect(ChannelScreen.channelIntro).toHaveText('Beginning of ' + expectedChannelName); - // # Open channel info + // # Open channel info screen await ChannelInfoScreen.open(); // * Expect to see channel header and purpose in channel info diff --git a/detox/e2e/test/main_sidebar/select_channel.e2e.js b/detox/e2e/test/main_sidebar/select_channel.e2e.js index 665f7cec1..3332a587b 100644 --- a/detox/e2e/test/main_sidebar/select_channel.e2e.js +++ b/detox/e2e/test/main_sidebar/select_channel.e2e.js @@ -7,7 +7,7 @@ // - Use element testID when selecting an element. Create one if none. // ******************************************************************* -import {ChannelSidebar} from '@support/ui/component'; +import {MainSidebar} from '@support/ui/component'; import {ChannelScreen} from '@support/ui/screen'; import {isAndroid} from '@support/utils'; import {Setup} from '@support/server_api'; @@ -27,28 +27,28 @@ describe('Select channel', () => { }); it('MM-T3412 should close the sidebar menu when selecting the same channel', async () => { - const {channelDrawerButton, channelNavBarTitle} = ChannelScreen; + const {mainSidebarDrawerButton, channelNavBarTitle} = ChannelScreen; - // # Open channel drawer (with at least one unread channel) - await channelDrawerButton.tap(); + // # Open main sidebar (with at least one unread channel) + await mainSidebarDrawerButton.tap(); // * Main sidebar should be visible - await ChannelSidebar.toBeVisible(); + await MainSidebar.toBeVisible(); // # Tap a channel to view it - const channelItem = ChannelSidebar.getChannelByDisplayName(newChannel.display_name); + const channelItem = MainSidebar.getChannelByDisplayName(newChannel.display_name); await channelItem.tap(); // * Selected channel should be visible await expect(channelNavBarTitle).toHaveText(newChannel.display_name); - // # Open channel drawer again and select the same channel - await channelDrawerButton.tap(); + // # Open main sidebar again and select the same channel + await mainSidebarDrawerButton.tap(); await channelItem.tap(); // * Drawer should not be visible on Android if (isAndroid()) { - await expect(ChannelSidebar.mainSidebar).not.toBeVisible(); + await expect(MainSidebar.mainSidebar).not.toBeVisible(); } // * Selected channel should remain the same diff --git a/detox/e2e/test/notifications/channel_notification_default.e2e.js b/detox/e2e/test/notifications/channel_notification_default.e2e.js new file mode 100644 index 000000000..dd6457498 --- /dev/null +++ b/detox/e2e/test/notifications/channel_notification_default.e2e.js @@ -0,0 +1,135 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +// ******************************************************************* +// - [#] indicates a test step (e.g. # Go to a screen) +// - [*] indicates an assertion (e.g. * Check the title) +// - Use element testID when selecting an element. Create one if none. +// ******************************************************************* + +import { + MainSidebar, + SettingsSidebar, +} from '@support/ui/component'; +import { + ChannelInfoScreen, + ChannelNotificationPreferenceScreen, + ChannelScreen, + GeneralSettingsScreen, + NotificationSettingsMobileScreen, + NotificationSettingsScreen, +} from '@support/ui/screen'; +import {Setup} from '@support/server_api'; +import {isAndroid} from '@support/utils'; + +describe('Channel Notification Preference - Default', () => { + let testChannel; + + beforeAll(async () => { + const {user, channel} = await Setup.apiInit(); + testChannel = channel; + await ChannelScreen.open(user); + }); + + beforeEach(async () => { + // # Open main sidebar + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.toBeVisible(); + + // # Go to channel + await MainSidebar.getChannelByDisplayName(testChannel.display_name).tap(); + }); + + afterAll(async () => { + await ChannelScreen.logout(); + }); + + afterEach(async () => { + // # Close channel info screen + await ChannelInfoScreen.close(); + }); + + it('MM-T3376_1 should be able to select Global Default option and display Default next to Mobile Notifications', async () => { + // # Set global notifications to mentions + await setGlobalNotificationsTo('mentions'); + + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Mobile Notifications + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + // # Tap on For all activity option + await element(by.text(`${ChannelNotificationPreferenceScreen.optionDefaultText} (Mentions)`)).tap(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + + // * Verify notification level Default abbreviation + await ChannelInfoScreen.toBeVisible(); + await expect(element(by.id(ChannelInfoScreen.testID.notificationPreferenceAction).withDescendant(by.text('Default')))).toBeVisible(); + }); + + it('MM-T3376_2 should display correct Global default value on channel info mobile notifications options', async () => { + // # Set global notifications to never + await setGlobalNotificationsTo('never'); + + // * Verify Global default (Never) is displayed + await ChannelInfoScreen.open(); + await ChannelInfoScreen.notificationPreferenceAction.tap(); + await expect(element(by.text(`${ChannelNotificationPreferenceScreen.optionDefaultText} (Never)`))).toBeVisible(); + + // # Go back to channel info screen + ChannelNotificationPreferenceScreen.back(); + await ChannelInfoScreen.close(); + + // # Set global notifications to all + await setGlobalNotificationsTo('all'); + + // * Verify Global default (All) is displayed + await ChannelInfoScreen.open(); + await ChannelInfoScreen.notificationPreferenceAction.tap(); + await expect(element(by.text(`${ChannelNotificationPreferenceScreen.optionDefaultText} (All)`))).toBeVisible(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + }); +}); + +async function setGlobalNotificationsTo(pushKey) { + // # Open settings sidebar + await ChannelScreen.settingsSidebarDrawerButton.tap(); + await SettingsSidebar.toBeVisible(); + + // # Open general settings screen + await SettingsSidebar.settingsAction.tap(); + await GeneralSettingsScreen.toBeVisible(); + + // # Open notification settings screen + await GeneralSettingsScreen.notificationsAction.tap(); + await NotificationSettingsScreen.toBeVisible(); + + // # Open notifications settings mobile screen + await NotificationSettingsScreen.mobileAction.tap(); + await NotificationSettingsMobileScreen.toBeVisible(); + + // # Tap on Send Notifications option if Android + if (isAndroid()) { + await NotificationSettingsMobileScreen.pushAction.tap(); + await expect(NotificationSettingsMobileScreen.pushModal).toBeVisible(); + } + + // # Tap on push activity option + await NotificationSettingsMobileScreen.getPushActionFor(pushKey).tap(); + + // # Tap on Save button if Android + if (isAndroid()) { + await NotificationSettingsMobileScreen.pushModalSaveButton.tap(); + } + + // # Navigate back to channel screen + await NotificationSettingsMobileScreen.toBeVisible(); + await NotificationSettingsMobileScreen.back(); + await NotificationSettingsScreen.back(); + await GeneralSettingsScreen.close(); +} diff --git a/detox/e2e/test/notifications/channel_notification_preference.e2e.js b/detox/e2e/test/notifications/channel_notification_preference.e2e.js new file mode 100644 index 000000000..0fc5a8bd9 --- /dev/null +++ b/detox/e2e/test/notifications/channel_notification_preference.e2e.js @@ -0,0 +1,155 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +// ******************************************************************* +// - [#] indicates a test step (e.g. # Go to a screen) +// - [*] indicates an assertion (e.g. * Check the title) +// - Use element testID when selecting an element. Create one if none. +// ******************************************************************* + +import {MainSidebar} from '@support/ui/component'; +import { + ChannelInfoScreen, + ChannelNotificationPreferenceScreen, + ChannelScreen, + DirectChannelsScreen, +} from '@support/ui/screen'; +import {Setup} from '@support/server_api'; +import {isAndroid} from '@support/utils'; + +describe('Channel Notification Preference', () => { + let testChannel; + + beforeAll(async () => { + const {user, channel} = await Setup.apiInit(); + testChannel = channel; + await ChannelScreen.open(user); + }); + + beforeEach(async () => { + // # Open main sidebar + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.toBeVisible(); + + // # Go to channel + await MainSidebar.getChannelByDisplayName(testChannel.display_name).tap(); + }); + + afterAll(async () => { + await ChannelScreen.logout(); + }); + + afterEach(async () => { + // # Close channel info screen + await ChannelInfoScreen.close(); + }); + + it('MM-T3375_1 should display Mobile Notifications option for non-DM Channels', async () => { + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Mobile Notifications + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + const { + titleText, + headerText, + optionDefaultText, + optionAllText, + optionMentionsText, + optionNeverText, + } = ChannelNotificationPreferenceScreen; + + // * Verify title, header, and options + await expect(element(by.text(titleText))).toBeVisible(); + await expect(element(by.text(isAndroid() ? headerText : headerText.toUpperCase()))).toBeVisible(); + await expect(element(by.text(`${optionDefaultText} (Mentions)`))).toBeVisible(); + await expect(element(by.text(optionAllText))).toBeVisible(); + await expect(element(by.text(optionMentionsText))).toBeVisible(); + await expect(element(by.text(optionNeverText))).toBeVisible(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + }); + + it('MM-T3375_2 should not display Mobile Notifications option for DM Channel', async () => { + // # Open main sidebar + await ChannelScreen.mainSidebarDrawerButton.tap(); + await MainSidebar.toBeVisible(); + + // # Open Direct Channels screen + await MainSidebar.addDirectChannel.tap(); + await DirectChannelsScreen.toBeVisible(); + + const { + getUserAtIndex, + startButton, + } = DirectChannelsScreen; + + // # Select 1 profile + await getUserAtIndex(0).tap(); + + // # Create a DM with selected profile + await startButton.tap(); + + // # Open channel info screen + await ChannelInfoScreen.open(); + + // * Verify Mobile Notifications is not displayed + await expect(ChannelInfoScreen.notificationPreferenceAction).not.toBeVisible(); + }); + + it('MM-T3377 should be able to select For all activity option and display All next to Mobile Notifications', async () => { + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Mobile Notifications + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + // # Tap on For all activity option + await element(by.text(ChannelNotificationPreferenceScreen.optionAllText)).tap(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + + // * Verify notification level All abbreviation + await ChannelInfoScreen.toBeVisible(); + await expect(element(by.id(ChannelInfoScreen.testID.notificationPreferenceAction).withDescendant(by.text('All')))).toBeVisible(); + }); + + it('MM-T3378 should be able to select Only mentions and direct messages option and display Mentions next to Mobile Notifications', async () => { + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Mobile Notifications + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + // # Tap on For all activity option + await element(by.text(ChannelNotificationPreferenceScreen.optionMentionsText)).tap(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + + // * Verify notification level Mentions abbreviation + await ChannelInfoScreen.toBeVisible(); + await expect(element(by.id(ChannelInfoScreen.testID.notificationPreferenceAction).withDescendant(by.text('Mentions')))).toBeVisible(); + }); + + it('MM-T3379 should be able to select Never option and display Never next to Mobile Notifications', async () => { + // # Open channel info screen + await ChannelInfoScreen.open(); + + // # Tap on Mobile Notifications + await ChannelInfoScreen.notificationPreferenceAction.tap(); + + // # Tap on For all activity option + await element(by.text(ChannelNotificationPreferenceScreen.optionNeverText)).tap(); + + // # Tap on back button + ChannelNotificationPreferenceScreen.back(); + + // * Verify notification level Never abbreviation + await ChannelInfoScreen.toBeVisible(); + await expect(element(by.id(ChannelInfoScreen.testID.notificationPreferenceAction).withDescendant(by.text('Never')))).toBeVisible(); + }); +}); diff --git a/detox/e2e/test/in_app_notification/notification.e2e.js b/detox/e2e/test/notifications/in_app_notification.e2e.js similarity index 100% rename from detox/e2e/test/in_app_notification/notification.e2e.js rename to detox/e2e/test/notifications/in_app_notification.e2e.js diff --git a/detox/e2e/test/smoke_test/channels.e2e.js b/detox/e2e/test/smoke_test/channels.e2e.js index c5b6062ae..f98d467b8 100644 --- a/detox/e2e/test/smoke_test/channels.e2e.js +++ b/detox/e2e/test/smoke_test/channels.e2e.js @@ -8,7 +8,7 @@ // ******************************************************************* import {ChannelScreen} from '@support/ui/screen'; -import {ChannelSidebar} from '@support/ui/component'; +import {MainSidebar} from '@support/ui/component'; import {Setup, Channel} from '@support/server_api'; describe('Unread channels', () => { @@ -34,38 +34,38 @@ describe('Unread channels', () => { }); it('MM-T3187 Unread channels sort at top', async () => { - const {channelDrawerButton} = ChannelScreen; + const {mainSidebarDrawerButton} = ChannelScreen; - // # Open channel drawer (with at least one unread channel) - await channelDrawerButton.tap(); + // # Open main sidebar (with at least one unread channel) + await mainSidebarDrawerButton.tap(); // * Channel should be visible - await ChannelSidebar.toBeVisible(); + await MainSidebar.toBeVisible(); // * Verify unread channel(s) display at top of channel list (with mentions first, if any), in alphabetical order, with title "Unreads" await expect(element(by.text('UNREADS'))).toBeVisible(); - await ChannelSidebar.hasChannelAtIndex(0, aChannel.display_name); - await ChannelSidebar.hasChannelAtIndex(1, newChannel.display_name); - await ChannelSidebar.hasChannelAtIndex(2, zChannel.display_name); + await MainSidebar.hasChannelAtIndex(0, aChannel.display_name); + await MainSidebar.hasChannelAtIndex(1, newChannel.display_name); + await MainSidebar.hasChannelAtIndex(2, zChannel.display_name); // # Tap an unread channel to view it - await ChannelSidebar.getChannelByDisplayName(aChannel.display_name).tap(); - await channelDrawerButton.tap(); - await ChannelSidebar.getChannelByDisplayName(newChannel.display_name).tap(); - await channelDrawerButton.tap(); - await ChannelSidebar.getChannelByDisplayName(zChannel.display_name).tap(); + await MainSidebar.getChannelByDisplayName(aChannel.display_name).tap(); + await mainSidebarDrawerButton.tap(); + await MainSidebar.getChannelByDisplayName(newChannel.display_name).tap(); + await mainSidebarDrawerButton.tap(); + await MainSidebar.getChannelByDisplayName(zChannel.display_name).tap(); - // # Open channel drawer again - await channelDrawerButton.tap(); + // # Open main sidebar again + await mainSidebarDrawerButton.tap(); // * Channel you just read is no longer listed in Unreads await expect(element(by.text('UNREADS'))).not.toBeVisible(); await expect(element(by.text('PUBLIC CHANNELS'))).toBeVisible(); - await ChannelSidebar.hasChannelAtIndex(0, aChannel.display_name); - await ChannelSidebar.hasChannelAtIndex(1, newChannel.display_name); - await ChannelSidebar.hasChannelAtIndex(2, 'Off-Topic'); - await ChannelSidebar.hasChannelAtIndex(3, 'Town Square'); - await ChannelSidebar.hasChannelAtIndex(4, zChannel.display_name); - await ChannelSidebar.getChannelByDisplayName(aChannel.display_name).tap(); + await MainSidebar.hasChannelAtIndex(0, aChannel.display_name); + await MainSidebar.hasChannelAtIndex(1, newChannel.display_name); + await MainSidebar.hasChannelAtIndex(2, 'Off-Topic'); + await MainSidebar.hasChannelAtIndex(3, 'Town Square'); + await MainSidebar.hasChannelAtIndex(4, zChannel.display_name); + await MainSidebar.getChannelByDisplayName(aChannel.display_name).tap(); }); });