diff --git a/app/components/channel_list/__snapshots__/index.test.tsx.snap b/app/components/channel_list/__snapshots__/index.test.tsx.snap index 5ba97ed56d..4894321965 100644 --- a/app/components/channel_list/__snapshots__/index.test.tsx.snap +++ b/app/components/channel_list/__snapshots__/index.test.tsx.snap @@ -91,6 +91,7 @@ exports[`components/channel_list should render channels error 1`] = ` "marginLeft": 4, } } + testID="channel_list_header.chevron.button" > Channel diff --git a/app/components/channel_list/categories/body/category_body.tsx b/app/components/channel_list/categories/body/category_body.tsx index 5b257dc38d..615e5cf320 100644 --- a/app/components/channel_list/categories/body/category_body.tsx +++ b/app/components/channel_list/categories/body/category_body.tsx @@ -42,6 +42,7 @@ const CategoryBody = ({currentChannelId, sortedChannels, category, hiddenChannel channel={item} isActive={item.id === currentChannelId} collapsed={category.collapsed} + testID={`category.${category.displayName.replace(/ /g, '_').toLocaleLowerCase()}.channel_list_item`} /> ); }, [currentChannelId, category.collapsed]); diff --git a/app/components/channel_list/categories/body/channel/__snapshots__/channel_list_item.test.tsx.snap b/app/components/channel_list/categories/body/channel/__snapshots__/channel_list_item.test.tsx.snap index 3a0156ef24..25cd8f94c6 100644 --- a/app/components/channel_list/categories/body/channel/__snapshots__/channel_list_item.test.tsx.snap +++ b/app/components/channel_list/categories/body/channel/__snapshots__/channel_list_item.test.tsx.snap @@ -46,6 +46,7 @@ exports[`components/channel_list/categories/body/channel/item should match snaps "paddingLeft": 2, } } + testID="channel_list_item.hello.collapsed.false" > Hello! diff --git a/app/components/channel_list/categories/body/channel/channel_list_item.test.tsx b/app/components/channel_list/categories/body/channel/channel_list_item.test.tsx index e6a1764f22..c52dd3ade4 100644 --- a/app/components/channel_list/categories/body/channel/channel_list_item.test.tsx +++ b/app/components/channel_list/categories/body/channel/channel_list_item.test.tsx @@ -37,6 +37,7 @@ describe('components/channel_list/categories/body/channel/item', () => { isMuted={false} collapsed={false} currentUserId={'id'} + testID='channel_list_item' />, ); diff --git a/app/components/channel_list/categories/body/channel/channel_list_item.tsx b/app/components/channel_list/categories/body/channel/channel_list_item.tsx index ea15d4b5a2..df9ab080de 100644 --- a/app/components/channel_list/categories/body/channel/channel_list_item.tsx +++ b/app/components/channel_list/categories/body/channel/channel_list_item.tsx @@ -66,9 +66,10 @@ type Props = { myChannel?: MyChannelModel; collapsed: boolean; currentUserId: string; + testID?: string; } -const ChannelListItem = ({channel, isActive, currentUserId, isMuted, myChannel, collapsed}: Props) => { +const ChannelListItem = ({channel, isActive, currentUserId, isMuted, myChannel, collapsed, testID}: Props) => { const {formatMessage} = useIntl(); const theme = useTheme(); const styles = getStyleSheet(theme); @@ -124,7 +125,10 @@ const ChannelListItem = ({channel, isActive, currentUserId, isMuted, myChannel, return ( - + 0} @@ -139,6 +143,7 @@ const ChannelListItem = ({channel, isActive, currentUserId, isMuted, myChannel, ellipsizeMode='tail' numberOfLines={1} style={textStyles} + testID={`${testID}.${channel.name}.display_name`} > {displayName} diff --git a/app/components/channel_list/categories/header/__snapshots__/header.test.tsx.snap b/app/components/channel_list/categories/header/__snapshots__/header.test.tsx.snap index 78edcb292f..f07dbb110b 100644 --- a/app/components/channel_list/categories/header/__snapshots__/header.test.tsx.snap +++ b/app/components/channel_list/categories/header/__snapshots__/header.test.tsx.snap @@ -17,6 +17,7 @@ exports[`components/channel_list/categories/header should match snapshot 1`] = ` "opacity": 1, } } + testID="category_header.custom.collapsed.false" > TEST CATEGORY diff --git a/app/components/channel_list/categories/header/header.tsx b/app/components/channel_list/categories/header/header.tsx index e502680c64..378d276c9f 100644 --- a/app/components/channel_list/categories/header/header.tsx +++ b/app/components/channel_list/categories/header/header.tsx @@ -74,14 +74,20 @@ const CategoryHeader = ({category, hasChannels}: Props) => { } return ( - + - + {category.displayName.toUpperCase()} diff --git a/app/components/channel_list/header/__snapshots__/header.test.tsx.snap b/app/components/channel_list/header/__snapshots__/header.test.tsx.snap index f07273d48b..91c6653c7c 100644 --- a/app/components/channel_list/header/__snapshots__/header.test.tsx.snap +++ b/app/components/channel_list/header/__snapshots__/header.test.tsx.snap @@ -71,6 +71,7 @@ exports[`components/channel_list/header Channel List Header Component should mat "marginLeft": 4, } } + testID="channel_list_header.chevron.button" > {displayName} - + { browseChannels: { icon: 'globe', text: intl.formatMessage({id: 'plus_menu.browse_channels.title', defaultMessage: 'Browse Channels'}), + testID: 'plus_menu_item.browse_channels', }, createNewChannel: { icon: 'plus', text: intl.formatMessage({id: 'plus_menu.create_new_channel.title', defaultMessage: 'Create New Channel'}), + testID: 'plus_menu_item.create_new_channel', }, openDirectMessage: { icon: 'account-outline', text: intl.formatMessage({id: 'plus_menu.open_direct_message.title', defaultMessage: 'Open a Direct Message'}), + testID: 'plus_menu_item.open_direct_message', }, }; const itemType = menuItems[pickerAction]; @@ -38,6 +41,7 @@ const PlusMenuItem = ({pickerAction, onPress}: PlusMenuItemProps) => { text={itemType.text} icon={itemType.icon} onPress={onPress} + testID={itemType.testID} /> ); diff --git a/app/components/channel_list/search/__snapshots__/index.test.tsx.snap b/app/components/channel_list/search/__snapshots__/index.test.tsx.snap index 199aa70a64..a1f41d51f6 100644 --- a/app/components/channel_list/search/__snapshots__/index.test.tsx.snap +++ b/app/components/channel_list/search/__snapshots__/index.test.tsx.snap @@ -55,6 +55,7 @@ exports[`Search Field should match snapshot 1`] = ` }, ] } + testID="channel_list.search_field.find_channels.input" /> `; diff --git a/app/components/channel_list/search/index.tsx b/app/components/channel_list/search/index.tsx index b7e8a2f1a9..f629782fe4 100644 --- a/app/components/channel_list/search/index.tsx +++ b/app/components/channel_list/search/index.tsx @@ -60,6 +60,7 @@ const SearchField = () => { style={[textStyles, styles.input]} placeholder='Find Channels' placeholderTextColor={changeOpacity(theme.sidebarText, 0.72)} + testID='channel_list.search_field.find_channels.input' /> ); diff --git a/app/components/channel_list/threads/__snapshots__/index.test.tsx.snap b/app/components/channel_list/threads/__snapshots__/index.test.tsx.snap index cd2f561d20..abde3fdf35 100644 --- a/app/components/channel_list/threads/__snapshots__/index.test.tsx.snap +++ b/app/components/channel_list/threads/__snapshots__/index.test.tsx.snap @@ -14,6 +14,7 @@ exports[`Threads Component should match snapshot 1`] = ` onResponderTerminationRequest={[Function]} onStartShouldSetResponder={[Function]} onStartShouldSetResponderCapture={[Function]} + testID="channel_list.threads.button" > { * - Add right-side number badge */ return ( - goToScreen(Screens.CHANNEL, 'Channel', {}, {topBar: {visible: false}})} > + goToScreen(Screens.CHANNEL, 'Channel', {}, {topBar: {visible: false}})} + testID='channel_list.threads.button' + > - + - + {usernameDisplay} diff --git a/app/screens/browse_channels/channel_list.tsx b/app/screens/browse_channels/channel_list.tsx index d380d8a994..7b1e0ec6d0 100644 --- a/app/screens/browse_channels/channel_list.tsx +++ b/app/screens/browse_channels/channel_list.tsx @@ -125,7 +125,7 @@ export default function ChannelList({ - + {channel.displayName} {isBot && diff --git a/app/screens/channel/channel_post_list/intro/options/index.tsx b/app/screens/channel/channel_post_list/intro/options/index.tsx index b5c4c65f0a..ceb557422e 100644 --- a/app/screens/channel/channel_post_list/intro/options/index.tsx +++ b/app/screens/channel/channel_post_list/intro/options/index.tsx @@ -55,6 +55,7 @@ const IntroOptions = ({channelId, header, favorite, people, theme}: Props) => { iconName='account-plus-outline' label={formatMessage({id: 'intro.add_people', defaultMessage: 'Add People'})} onPress={onAddPeople} + testID='channel_post_list.intro.option_item.add_people' theme={theme} /> } @@ -64,6 +65,7 @@ const IntroOptions = ({channelId, header, favorite, people, theme}: Props) => { iconName='pencil-outline' label={formatMessage({id: 'intro.set_header', defaultMessage: 'Set Header'})} onPress={onSetHeader} + testID='channel_post_list.intro.option_item.set_header' theme={theme} /> } @@ -77,6 +79,7 @@ const IntroOptions = ({channelId, header, favorite, people, theme}: Props) => { iconName='information-outline' label={formatMessage({id: 'intro.channel_details', defaultMessage: 'Details'})} onPress={onDetails} + testID='channel_post_list.intro.option_item.channel_details' theme={theme} /> diff --git a/app/screens/channel/channel_post_list/intro/options/item.tsx b/app/screens/channel/channel_post_list/intro/options/item.tsx index e36ae444d4..2fbf827071 100644 --- a/app/screens/channel/channel_post_list/intro/options/item.tsx +++ b/app/screens/channel/channel_post_list/intro/options/item.tsx @@ -14,6 +14,7 @@ type Props = { iconName: string; label: string; onPress: () => void; + testID?: string; theme: Theme; } @@ -40,7 +41,7 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ }, })); -const IntroItem = ({applyMargin, color, iconName, label, onPress, theme}: Props) => { +const IntroItem = ({applyMargin, color, iconName, label, onPress, testID, theme}: Props) => { const styles = getStyleSheet(theme); const pressedStyle = useCallback(({pressed}: PressableStateCallbackType) => { const style = [styles.container]; @@ -59,6 +60,7 @@ const IntroItem = ({applyMargin, color, iconName, label, onPress, theme}: Props) {({pressed}) => ( <> @@ -67,7 +69,10 @@ const IntroItem = ({applyMargin, color, iconName, label, onPress, theme}: Props) color={pressed ? theme.linkColor : color || changeOpacity(theme.centerChannelColor, 0.56)} size={24} /> - + {label} diff --git a/app/screens/channel/channel_post_list/intro/public_or_private_channel/public_or_private_channel.tsx b/app/screens/channel/channel_post_list/intro/public_or_private_channel/public_or_private_channel.tsx index 31e75ffd2e..3a5289bf20 100644 --- a/app/screens/channel/channel_post_list/intro/public_or_private_channel/public_or_private_channel.tsx +++ b/app/screens/channel/channel_post_list/intro/public_or_private_channel/public_or_private_channel.tsx @@ -116,7 +116,10 @@ const PublicOrPrivateChannel = ({channel, creator, roles, theme}: Props) => { return ( {illustration} - + {channel.displayName} diff --git a/app/screens/channel/channel_post_list/intro/townsquare/index.tsx b/app/screens/channel/channel_post_list/intro/townsquare/index.tsx index bccc657208..39f6a726d3 100644 --- a/app/screens/channel/channel_post_list/intro/townsquare/index.tsx +++ b/app/screens/channel/channel_post_list/intro/townsquare/index.tsx @@ -46,7 +46,10 @@ const TownSquare = ({channelId, displayName, roles, theme}: Props) => { return ( - + {displayName} + ); diff --git a/app/screens/create_direct_message/selected_users/index.tsx b/app/screens/create_direct_message/selected_users/index.tsx index efc028b3f0..2eba3bce88 100644 --- a/app/screens/create_direct_message/selected_users/index.tsx +++ b/app/screens/create_direct_message/selected_users/index.tsx @@ -82,7 +82,7 @@ export default function SelectedUsers({ user={selectedIds[id]} teammateNameDisplay={teammateNameDisplay} onRemove={onRemove} - testID='more_direct_messages.selected_user' + testID='create_direct_message.selected_user' />, ); } diff --git a/app/screens/create_direct_message/selected_users/selected_user.tsx b/app/screens/create_direct_message/selected_users/selected_user.tsx index d126d3166e..3b27e72220 100644 --- a/app/screens/create_direct_message/selected_users/selected_user.tsx +++ b/app/screens/create_direct_message/selected_users/selected_user.tsx @@ -85,7 +85,7 @@ export default function SelectedUser({ > {displayUsername(user, intl.locale, teammateNameDisplay)} diff --git a/app/screens/create_direct_message/user_list.tsx b/app/screens/create_direct_message/user_list.tsx index 0111678efa..7f2909129e 100644 --- a/app/screens/create_direct_message/user_list.tsx +++ b/app/screens/create_direct_message/user_list.tsx @@ -167,7 +167,7 @@ export default function UserList({ selectable={canAdd} selected={selected} enabled={canAdd} - testID='more_direct_messages.user_list.user_item' + testID='create_direct_message.user_list.user_item' teammateNameDisplay={teammateNameDisplay} user={item} /> @@ -233,7 +233,7 @@ export default function UserList({ renderItem={renderItem} scrollEventThrottle={SCROLL_EVENT_THROTTLE} style={style.list} - testID={testID} + testID={`${testID}.flat_list`} /> ); }; @@ -257,7 +257,7 @@ export default function UserList({ sections={data} style={style.list} stickySectionHeadersEnabled={false} - testID={testID} + testID={`${testID}.section_list`} onEndReached={fetchMore} /> ); diff --git a/detox/e2e/support/ui/component/index.ts b/detox/e2e/support/ui/component/index.ts index f3f0c00838..a5eace445b 100644 --- a/detox/e2e/support/ui/component/index.ts +++ b/detox/e2e/support/ui/component/index.ts @@ -2,7 +2,11 @@ // See LICENSE.txt for license information. import Alert from './alert'; +import NavigationHeader from './navigation_header'; +import PlusMenu from './plus_menu'; export { Alert, + NavigationHeader, + PlusMenu, }; diff --git a/detox/e2e/support/ui/component/navigation_header.ts b/detox/e2e/support/ui/component/navigation_header.ts new file mode 100644 index 0000000000..2185d3444b --- /dev/null +++ b/detox/e2e/support/ui/component/navigation_header.ts @@ -0,0 +1,17 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +class NavigationHeader { + testID = { + backButton: 'navigation.header.back', + headerTitle: 'navigation.header.title', + headerSubtitle: 'navigation.header.subtitle', + }; + + backButton = element(by.id(this.testID.backButton)); + headerTitle = element(by.id(this.testID.headerTitle)); + headerSubtitle = element(by.id(this.testID.headerSubtitle)); +} + +const navigationHeader = new NavigationHeader(); +export default navigationHeader; diff --git a/detox/e2e/support/ui/component/plus_menu.ts b/detox/e2e/support/ui/component/plus_menu.ts new file mode 100644 index 0000000000..713e2d39c0 --- /dev/null +++ b/detox/e2e/support/ui/component/plus_menu.ts @@ -0,0 +1,17 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +class PlusMenu { + testID = { + browseChannelsItem: 'plus_menu_item.browse_channels', + createNewChannelItem: 'plus_menu_item.create_new_channel', + openDirectMessageItem: 'plus_menu_item.open_direct_message', + }; + + browseChannelsItem = element(by.id(this.testID.browseChannelsItem)); + createNewChannelItem = element(by.id(this.testID.createNewChannelItem)); + openDirectMessageItem = element(by.id(this.testID.openDirectMessageItem)); +} + +const plusMenu = new PlusMenu(); +export default plusMenu; diff --git a/detox/e2e/support/ui/screen/browse_channels.ts b/detox/e2e/support/ui/screen/browse_channels.ts new file mode 100644 index 0000000000..eab3180275 --- /dev/null +++ b/detox/e2e/support/ui/screen/browse_channels.ts @@ -0,0 +1,54 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {ChannelListScreen} from '@support/ui/screen'; +import {timeouts} from '@support/utils'; +import {expect} from 'detox'; + +class BrowseChannelsScreen { + testID = { + browseChannelsScreen: 'browse_channels.screen', + closeButton: 'close.browse_channels.button', + searchInput: 'browse_channels.search_bar.search.input', + searchClearButton: 'browse_channels.search_bar.search.clear.button', + searchCancelButton: 'browse_channels.search_bar.search.cancel.button', + flatChannelList: 'browse_channels.channel_list.flat_list', + }; + + browseChannelsScreen = element(by.id(this.testID.browseChannelsScreen)); + closeButton = element(by.id(this.testID.closeButton)); + searchInput = element(by.id(this.testID.searchInput)); + searchClearButton = element(by.id(this.testID.searchClearButton)); + searchCancelButton = element(by.id(this.testID.searchCancelButton)); + flatChannelList = element(by.id(this.testID.flatChannelList)); + + getChannelItem = (channelName: string) => { + return element(by.id(`browse_channels.custom_list.channel_item.${channelName}`)); + }; + + getChannelItemDisplayName = (channelName: string) => { + return element(by.id(`browse_channels.custom_list.channel_item.${channelName}.display_name`)); + }; + + toBeVisible = async () => { + await waitFor(this.browseChannelsScreen).toExist().withTimeout(timeouts.TEN_SEC); + + return this.browseChannelsScreen; + }; + + open = async () => { + // # Open browse channels screen + await ChannelListScreen.headerPlusButton.tap(); + await ChannelListScreen.browseChannelsItem.tap(); + + return this.toBeVisible(); + }; + + close = async () => { + await this.closeButton.tap(); + await expect(this.browseChannelsScreen).not.toBeVisible(); + }; +} + +const browseChannelsScreen = new BrowseChannelsScreen(); +export default browseChannelsScreen; diff --git a/detox/e2e/support/ui/screen/channel.ts b/detox/e2e/support/ui/screen/channel.ts new file mode 100644 index 0000000000..89210c5803 --- /dev/null +++ b/detox/e2e/support/ui/screen/channel.ts @@ -0,0 +1,50 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {NavigationHeader} from '@support/ui/component'; +import {ChannelListScreen} from '@support/ui/screen'; +import {timeouts} from '@support/utils'; +import {expect} from 'detox'; + +class ChannelScreen { + testID = { + channelScreen: 'channel.screen', + introDisplayName: 'channel_post_list.intro.display_name', + introOptionAddPeopleItem: 'channel_post_list.intro.option_item.add_people', + introOptionSetHeaderItem: 'channel_post_list.intro.option_item.set_header', + introOptionChannelDetailsItem: 'channel_post_list.intro.option_item.channel_details', + }; + + channelScreen = element(by.id(this.testID.channelScreen)); + introDisplayName = element(by.id(this.testID.introDisplayName)); + introOptionAddPeopleItem = element(by.id(this.testID.introOptionAddPeopleItem)); + introOptionSetHeaderItem = element(by.id(this.testID.introOptionSetHeaderItem)); + introOptionChannelDetailsItem = element(by.id(this.testID.introOptionChannelDetailsItem)); + backButton = NavigationHeader.backButton; + headerTitle = NavigationHeader.headerTitle; + + getIntroOptionItemLabel = (introOptionItemTestId: string) => { + return element(by.id(`${introOptionItemTestId}.label`)); + }; + + toBeVisible = async () => { + await waitFor(this.channelScreen).toExist().withTimeout(timeouts.TEN_SEC); + + return this.channelScreen; + }; + + open = async (categoryKey: string, channelName: string) => { + // # Open channel screen + await ChannelListScreen.getChannelListItemDisplayName(categoryKey, channelName).tap(); + + return this.toBeVisible(); + }; + + back = async () => { + await this.backButton.tap(); + await expect(this.channelScreen).not.toBeVisible(); + }; +} + +const channelScreen = new ChannelScreen(); +export default channelScreen; diff --git a/detox/e2e/support/ui/screen/channel_list.ts b/detox/e2e/support/ui/screen/channel_list.ts index 9d4364265e..6027e4d814 100644 --- a/detox/e2e/support/ui/screen/channel_list.ts +++ b/detox/e2e/support/ui/screen/channel_list.ts @@ -1,6 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import {PlusMenu} from '@support/ui/component'; import {HomeScreen} from '@support/ui/screen'; import {timeouts} from '@support/utils'; @@ -10,12 +11,47 @@ class ChannelListScreen { serverIcon: 'channel_list.servers.server_icon', headerTeamDisplayName: 'channel_list_header.team_display_name', headerServerDisplayName: 'channel_list_header.server_display_name', + headerChevronButton: 'channel_list_header.chevron.button', + headerPlusButton: 'channel_list_header.plus.button', + findChannelsInput: 'channel_list.search_field.find_channels.input', + threadsButton: 'channel_list.threads.button', }; channelListScreen = element(by.id(this.testID.channelListScreen)); serverIcon = element(by.id(this.testID.serverIcon)); headerTeamDisplayName = element(by.id(this.testID.headerTeamDisplayName)); headerServerDisplayName = element(by.id(this.testID.headerServerDisplayName)); + headerChevronButton = element(by.id(this.testID.headerChevronButton)); + headerPlusButton = element(by.id(this.testID.headerPlusButton)); + findChannelsInput = element(by.id(this.testID.findChannelsInput)); + threadsButton = element(by.id(this.testID.threadsButton)); + browseChannelsItem = PlusMenu.browseChannelsItem; + createNewChannelItem = PlusMenu.createNewChannelItem; + openDirectMessageItem = PlusMenu.openDirectMessageItem; + + getCategoryCollapsed = (categoryKey: string) => { + return element(by.id(`category_header.${categoryKey}.collapsed.true`)); + }; + + getCategoryExpanded = (categoryKey: string) => { + return element(by.id(`category_header.${categoryKey}.collapsed.false`)); + }; + + getCategoryHeaderDisplayName = (categoryKey: string) => { + return element(by.id(`category_header.${categoryKey}.display_name`)); + }; + + getChannelListItemCollapsed = (categoryKey: string, channelName: string) => { + return element(by.id(`category.${categoryKey}.channel_list_item.${channelName}.collapsed.true`)); + }; + + getChannelListItemExpanded = (categoryKey: string, channelName: string) => { + return element(by.id(`category.${categoryKey}.channel_list_item.${channelName}.collapsed.false`)); + }; + + getChannelListItemDisplayName = (categoryKey: string, channelName: string) => { + return element(by.id(`category.${categoryKey}.channel_list_item.${channelName}.display_name`)); + }; toBeVisible = async () => { await waitFor(this.channelListScreen).toExist().withTimeout(timeouts.TEN_SEC); diff --git a/detox/e2e/support/ui/screen/create_direct_message.ts b/detox/e2e/support/ui/screen/create_direct_message.ts new file mode 100644 index 0000000000..ca82e4d8a9 --- /dev/null +++ b/detox/e2e/support/ui/screen/create_direct_message.ts @@ -0,0 +1,74 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import {ChannelListScreen} from '@support/ui/screen'; +import {timeouts} from '@support/utils'; +import {expect} from 'detox'; + +class CreateDirectMessageScreen { + testID = { + createDirectMessageScreen: 'create_direct_message.screen', + closeButton: 'close.create_direct_message.button', + startButton: 'create_direct_message.start.button', + searchInput: 'create_direct_message.search_bar.search.input', + searchClearButton: 'create_direct_message.search_bar.search.clear.button', + searchCancelButton: 'create_direct_message.search_bar.search.cancel.button', + flatUserList: 'create_direct_message.user_list.flat_list', + sectionUserList: 'create_direct_message.user_list.section_list', + }; + + createDirectMessageScreen = element(by.id(this.testID.createDirectMessageScreen)); + closeButton = element(by.id(this.testID.closeButton)); + startButton = element(by.id(this.testID.startButton)); + searchInput = element(by.id(this.testID.searchInput)); + searchClearButton = element(by.id(this.testID.searchClearButton)); + searchCancelButton = element(by.id(this.testID.searchCancelButton)); + flatUserList = element(by.id(this.testID.flatUserList)); + sectionUserList = element(by.id(this.testID.sectionUserList)); + + getSelectedUser = (userId: string) => { + return element(by.id(`create_direct_message.selected_user.${userId}`)); + }; + + getSelectedUserDisplayName = (userId: string) => { + return element(by.id(`create_direct_message.selected_user.${userId}.display_name`)); + }; + + getSelectedUserRemoveButton = (userId: string) => { + return element(by.id(`create_direct_message.selected_user.${userId}.remove.button`)); + }; + + getUserItem = (userId: string) => { + return element(by.id(`create_direct_message.user_list.user_item.${userId}`)); + }; + + getUserItemProfilePicture = (userId: string) => { + return element(by.id(`create_direct_message.user_list.user_item.${userId}.profile_picture`)); + }; + + getUserItemDisplayName = (userId: string) => { + return element(by.id(`create_direct_message.user_list.user_item.${userId}.display_name`)); + }; + + toBeVisible = async () => { + await waitFor(this.createDirectMessageScreen).toExist().withTimeout(timeouts.TEN_SEC); + + return this.createDirectMessageScreen; + }; + + open = async () => { + // # Open create direct message screen + await ChannelListScreen.headerPlusButton.tap(); + await ChannelListScreen.openDirectMessageItem.tap(); + + return this.toBeVisible(); + }; + + close = async () => { + await this.closeButton.tap(); + await expect(this.createDirectMessageScreen).not.toBeVisible(); + }; +} + +const createDirectMessageScreen = new CreateDirectMessageScreen(); +export default createDirectMessageScreen; diff --git a/detox/e2e/support/ui/screen/index.ts b/detox/e2e/support/ui/screen/index.ts index 6218be8714..723217e72c 100644 --- a/detox/e2e/support/ui/screen/index.ts +++ b/detox/e2e/support/ui/screen/index.ts @@ -2,7 +2,10 @@ // See LICENSE.txt for license information. import AccountScreen from './account'; +import BrowseChannelsScreen from './browse_channels'; +import ChannelScreen from './channel'; import ChannelListScreen from './channel_list'; +import CreateDirectMessageScreen from './create_direct_message'; import EditServerScreen from './edit_server'; import HomeScreen from './home'; import LoginScreen from './login'; @@ -11,7 +14,10 @@ import ServerListScreen from './server_list'; export { AccountScreen, + BrowseChannelsScreen, + ChannelScreen, ChannelListScreen, + CreateDirectMessageScreen, EditServerScreen, HomeScreen, LoginScreen, diff --git a/detox/e2e/support/ui/screen/login.ts b/detox/e2e/support/ui/screen/login.ts index 046a8ad0c1..a87a402b64 100644 --- a/detox/e2e/support/ui/screen/login.ts +++ b/detox/e2e/support/ui/screen/login.ts @@ -9,6 +9,11 @@ class LoginScreen { testID = { loginScreen: 'login.screen', backButton: 'screen.back.button', + titleLoginToAccount: 'login_options.title.login_to_account', + titleCantLogin: 'login_options.title.cant_login', + descriptionEnterCredentials: 'login_options.description.enter_credentials', + descriptionSelectOption: 'login_options.description.select_option', + descriptionNone: 'login_options.description.none', usernameInput: 'login_form.username.input', usernameInputError: 'login_form.username.input.error', passwordInput: 'login_form.password.input', @@ -20,6 +25,11 @@ class LoginScreen { loginScreen = element(by.id(this.testID.loginScreen)); backButton = element(by.id(this.testID.backButton)); + titleLoginToAccount = element(by.id(this.testID.titleLoginToAccount)); + titleCantLogin = element(by.id(this.testID.titleCantLogin)); + descriptionEnterCredentials = element(by.id(this.testID.descriptionEnterCredentials)); + descriptionSelectOption = element(by.id(this.testID.descriptionSelectOption)); + descriptionNone = element(by.id(this.testID.descriptionNone)); usernameInput = element(by.id(this.testID.usernameInput)); usernameInputError = element(by.id(this.testID.usernameInputError)); passwordInput = element(by.id(this.testID.passwordInput)); diff --git a/detox/e2e/support/ui/screen/server.ts b/detox/e2e/support/ui/screen/server.ts index f5290d0f0b..fb6b6b6c19 100644 --- a/detox/e2e/support/ui/screen/server.ts +++ b/detox/e2e/support/ui/screen/server.ts @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import {timeouts} from '@support/utils'; +import {expect} from 'detox'; class ServerScreen { testID = { @@ -47,6 +48,11 @@ class ServerScreen { await this.serverDisplayNameInput.replaceText(serverDisplayName); await this.connectButton.tap(); }; + + close = async () => { + await this.closeButton.tap(); + await expect(this.serverScreen).not.toBeVisible(); + }; } const serverScreen = new ServerScreen(); diff --git a/detox/e2e/test/channels/browse_channels.e2e.ts b/detox/e2e/test/channels/browse_channels.e2e.ts new file mode 100644 index 0000000000..911b16fcc4 --- /dev/null +++ b/detox/e2e/test/channels/browse_channels.e2e.ts @@ -0,0 +1,94 @@ +// 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 { + Channel, + Setup, +} from '@support/server_api'; +import { + serverOneUrl, + siteOneUrl, +} from '@support/test_config'; +import { + BrowseChannelsScreen, + ChannelScreen, + ChannelListScreen, + HomeScreen, + LoginScreen, + ServerScreen, +} from '@support/ui/screen'; +import {expect} from 'detox'; + +describe('Channels - Browse Channels', () => { + const serverOneDisplayName = 'Server 1'; + const channelsCategory = 'channels'; + let testTeam: any; + + beforeAll(async () => { + const {team, user} = await Setup.apiInit(siteOneUrl); + testTeam = team; + + // # Log in to server + await ServerScreen.connectToServer(serverOneUrl, serverOneDisplayName); + await LoginScreen.login(user); + }); + + beforeEach(async () => { + // * Verify on channel list screen + await ChannelListScreen.toBeVisible(); + }); + + afterAll(async () => { + // # Log out + await HomeScreen.logout(); + }); + + it('MM-T4729_1 - should match elements on browse channels screen', async () => { + // # Open browse channels screen + await BrowseChannelsScreen.open(); + + // * Verify basic elements on browse channels screen + await expect(BrowseChannelsScreen.closeButton).toBeVisible(); + await expect(BrowseChannelsScreen.searchInput).toBeVisible(); + await expect(BrowseChannelsScreen.flatChannelList).toBeVisible(); + + // # Go back to channel list screen + await BrowseChannelsScreen.close(); + }); + + it('MM-T4729_2 - should be able to browse and join channels', async () => { + // # As admin, create a new channel so that user can join + const {channel} = await Channel.apiCreateChannel(siteOneUrl, {teamId: testTeam.id}); + + // * Verify new channel does not appear on channel list screen + await expect(ChannelListScreen.getChannelListItemDisplayName(channelsCategory, channel.display_name)).not.toExist(); + + // # Open browse channels screen and search for the new channel name to join + await BrowseChannelsScreen.open(); + await BrowseChannelsScreen.searchInput.replaceText(channel.name); + + // * Verify search returns the new channel item + await expect(BrowseChannelsScreen.getChannelItemDisplayName(channel.name)).toHaveText(channel.display_name); + + // # Tap on the new channel item + await BrowseChannelsScreen.getChannelItem(channel.name).tap(); + + // * Verify on new channel screen + await ChannelScreen.toBeVisible(); + await expect(ChannelScreen.headerTitle).toHaveText(channel.display_name); + await expect(ChannelScreen.introDisplayName).toHaveText(channel.display_name); + + // # Go back to channel list screen + await ChannelScreen.back(); + await ChannelListScreen.toBeVisible(); + + // * Verify new channel is added to channel list + await expect(ChannelListScreen.getChannelListItemDisplayName(channelsCategory, channel.name)).toBeVisible(); + }); +}); diff --git a/detox/e2e/test/channels/channel_list.e2e.ts b/detox/e2e/test/channels/channel_list.e2e.ts new file mode 100644 index 0000000000..5e356a96a8 --- /dev/null +++ b/detox/e2e/test/channels/channel_list.e2e.ts @@ -0,0 +1,156 @@ +// 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 {Setup} from '@support/server_api'; +import { + serverOneUrl, + siteOneUrl, +} from '@support/test_config'; +import { + BrowseChannelsScreen, + ChannelScreen, + ChannelListScreen, + CreateDirectMessageScreen, + HomeScreen, + LoginScreen, + ServerScreen, +} from '@support/ui/screen'; +import {expect} from 'detox'; + +describe('Channels - Channel List', () => { + const serverOneDisplayName = 'Server 1'; + const channelsCategory = 'channels'; + const directMessagesCategory = 'direct_messages'; + const offTopicChannelName = 'off-topic'; + const townSquareChannelName = 'town-square'; + let testChannel: any; + let testTeam: any; + + beforeAll(async () => { + const {channel, team, user} = await Setup.apiInit(siteOneUrl); + testChannel = channel; + testTeam = team; + + // # Log in to server + await ServerScreen.connectToServer(serverOneUrl, serverOneDisplayName); + await LoginScreen.login(user); + }); + + beforeEach(async () => { + // * Verify on channel list screen + await ChannelListScreen.toBeVisible(); + }); + + afterAll(async () => { + // # Log out + await HomeScreen.logout(); + }); + + it('MM-T4728_1 - should match elements on channel list screen', async () => { + // * Verify basic elements on channel list screen + await expect(ChannelListScreen.serverIcon).toBeVisible(); + await expect(ChannelListScreen.headerTeamDisplayName).toHaveText(testTeam.display_name); + await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); + await expect(ChannelListScreen.headerChevronButton).toBeVisible(); + await expect(ChannelListScreen.headerPlusButton).toBeVisible(); + await expect(ChannelListScreen.threadsButton).toBeVisible(); + await expect(ChannelListScreen.getCategoryHeaderDisplayName(channelsCategory)).toHaveText('CHANNELS'); + await expect(ChannelListScreen.getChannelListItemDisplayName(channelsCategory, testChannel.name)).toHaveText(testChannel.display_name); + await expect(ChannelListScreen.getChannelListItemDisplayName(channelsCategory, offTopicChannelName)).toHaveText('Off-Topic'); + await expect(ChannelListScreen.getChannelListItemDisplayName(channelsCategory, townSquareChannelName)).toHaveText('Town Square'); + await expect(ChannelListScreen.getCategoryHeaderDisplayName(directMessagesCategory)).toHaveText('DIRECT MESSAGES'); + }); + + it('MM-T4728_2 - should be able to switch between channels', async () => { + // # Tap on a first channel + await ChannelListScreen.getChannelListItemDisplayName(channelsCategory, testChannel.name).tap(); + + // * Verify on first channel + await ChannelScreen.toBeVisible(); + await expect(ChannelScreen.headerTitle).toHaveText(testChannel.display_name); + await expect(ChannelScreen.introDisplayName).toHaveText(testChannel.display_name); + + // # Go back to channel list screen and tap on a second channel + await ChannelScreen.backButton.tap(); + await ChannelListScreen.toBeVisible(); + await ChannelListScreen.getChannelListItemDisplayName(channelsCategory, offTopicChannelName).tap(); + + // * Verify on second channel + await ChannelScreen.toBeVisible(); + await expect(ChannelScreen.headerTitle).toHaveText('Off-Topic'); + await expect(ChannelScreen.introDisplayName).toHaveText('Off-Topic'); + + // # Go back to channel list screen + await ChannelScreen.back(); + }); + + it('MM-T4728_3 - should be able to collapse and expand categories', async () => { + // # Go to a channel to make it active and go back to channel list screen + await ChannelListScreen.getChannelListItemDisplayName(channelsCategory, testChannel.name).tap(); + await ChannelScreen.toBeVisible(); + await ChannelScreen.backButton.tap(); + + // * Verify on channel list screen + await ChannelListScreen.toBeVisible(); + + // # Toggle channels category to collapse + await ChannelListScreen.getCategoryExpanded(channelsCategory).tap(); + + // * Verify category is collapsed and only currently active channel is listed + await expect(ChannelListScreen.getCategoryCollapsed(channelsCategory)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemExpanded(channelsCategory, testChannel.name)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemCollapsed(channelsCategory, offTopicChannelName)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemCollapsed(channelsCategory, townSquareChannelName)).toBeVisible(); + + // # Toggle channels category to expand + await ChannelListScreen.getCategoryCollapsed(channelsCategory).tap(); + + // * Verify category is expanded and all channels are listed + await expect(ChannelListScreen.getCategoryExpanded(channelsCategory)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemExpanded(channelsCategory, testChannel.name)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemExpanded(channelsCategory, offTopicChannelName)).toBeVisible(); + await expect(ChannelListScreen.getChannelListItemExpanded(channelsCategory, townSquareChannelName)).toBeVisible(); + }); + + it('MM-T4728_4 - should be able to go to browse channels screen', async () => { + // # Tap on plus menu button and tap on browse channels item + await ChannelListScreen.headerPlusButton.tap(); + await ChannelListScreen.browseChannelsItem.tap(); + + // * Verify on browse channels screen + await BrowseChannelsScreen.toBeVisible(); + + // # Go back to channel list screen + await BrowseChannelsScreen.close(); + }); + + it('MM-T4728_5 - should be able to go to create direct message screen', async () => { + // # Tap on plus menu button and tap on open a direct message item + await ChannelListScreen.headerPlusButton.tap(); + await ChannelListScreen.openDirectMessageItem.tap(); + + // * Verify on create direct message screen + await CreateDirectMessageScreen.toBeVisible(); + + // # Go back to channel list screen + await CreateDirectMessageScreen.close(); + }); + + xit('MM-T4728_6 - should be able to go to create channel screen', async () => { + // NOT YET IMPLEMENTED + }); + + xit('MM-T4728_7 - should be able to go to threads screen', async () => { + // NOT YET IMPLEMENTED + }); + + xit('MM-T4728_8 - should be able to find channels', async () => { + // NOT YET IMPLEMENTED + }); +}); diff --git a/detox/e2e/test/channels/create_direct_message.e2e.ts b/detox/e2e/test/channels/create_direct_message.e2e.ts new file mode 100644 index 0000000000..8ff9f5c2b8 --- /dev/null +++ b/detox/e2e/test/channels/create_direct_message.e2e.ts @@ -0,0 +1,148 @@ +// 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 { + Setup, + Team, + User, +} from '@support/server_api'; +import { + serverOneUrl, + siteOneUrl, +} from '@support/test_config'; +import { + ChannelScreen, + ChannelListScreen, + CreateDirectMessageScreen, + HomeScreen, + LoginScreen, + ServerScreen, +} from '@support/ui/screen'; +import {expect} from 'detox'; + +describe('Channels - Create Direct Message', () => { + const serverOneDisplayName = 'Server 1'; + const directMessagesCategory = 'direct_messages'; + let testTeam: any; + + beforeAll(async () => { + const {team, user} = await Setup.apiInit(siteOneUrl); + testTeam = team; + + // # Log in to server + await ServerScreen.connectToServer(serverOneUrl, serverOneDisplayName); + await LoginScreen.login(user); + }); + + beforeEach(async () => { + // * Verify on channel list screen + await ChannelListScreen.toBeVisible(); + }); + + afterAll(async () => { + // # Log out + await HomeScreen.logout(); + }); + + it('MM-T4730_1 - should match elements on create direct message screen', async () => { + // # Open create direct message screen + await CreateDirectMessageScreen.open(); + + // * Verify basic elements on create direct message screen + await expect(CreateDirectMessageScreen.closeButton).toBeVisible(); + await expect(CreateDirectMessageScreen.startButton).toBeVisible(); + await expect(CreateDirectMessageScreen.searchInput).toBeVisible(); + await expect(CreateDirectMessageScreen.sectionUserList).toBeVisible(); + + // # Go back to channel list screen + await CreateDirectMessageScreen.close(); + }); + + it('MM-T4730_2 - should be able to create a direct message', async () => { + // # As admin, create a new user to open direct message with + const {user: newUser} = await User.apiCreateUser(siteOneUrl); + await Team.apiAddUserToTeam(siteOneUrl, newUser.id, testTeam.id); + + // * Verify no direct message channel for the new user appears on channel list screen + const newUserDisplayName = newUser.username; + await expect(ChannelListScreen.getChannelListItemDisplayName(directMessagesCategory, newUserDisplayName)).not.toBeVisible(); + + // # Open create direct message screen and search for the new user + await CreateDirectMessageScreen.open(); + await CreateDirectMessageScreen.searchInput.replaceText(newUser.username); + + // * Verify search returns the new user item + await expect(CreateDirectMessageScreen.getUserItemDisplayName(newUser.id)).toBeVisible(); + + // # Tap on the new user item + await CreateDirectMessageScreen.getUserItem(newUser.id).tap(); + + // * Verify the new user is selected + await expect(CreateDirectMessageScreen.getSelectedUserDisplayName(newUser.id)).toBeVisible(); + + // # Tap on start button + await CreateDirectMessageScreen.startButton.tap(); + + // * Verify on direct message channel screen for the new user + await ChannelScreen.toBeVisible(); + await expect(ChannelScreen.headerTitle).toHaveText(newUserDisplayName); + await expect(ChannelScreen.introDisplayName).toHaveText(newUserDisplayName); + + // # Go back to channel list screen + await ChannelScreen.back(); + await ChannelListScreen.toBeVisible(); + + // * Verify direct message channel for the new user is added to direct message list + await expect(ChannelListScreen.getChannelListItemDisplayName(directMessagesCategory, newUser.id)).toHaveText(newUserDisplayName); + }); + + it('MM-T4730_3 - should be able to create a group message', async () => { + // # As admin, create two new users to open group message with + const {user: firstNewUser} = await User.apiCreateUser(siteOneUrl, {prefix: 'a'}); + await Team.apiAddUserToTeam(siteOneUrl, firstNewUser.id, testTeam.id); + const {user: secondNewUser} = await User.apiCreateUser(siteOneUrl, {prefix: 'b'}); + await Team.apiAddUserToTeam(siteOneUrl, secondNewUser.id, testTeam.id); + + // * Verify no group message channel for the new users appears on channel list screen + const firstNewUserDisplayName = firstNewUser.username; + const secondNewUserDisplayName = secondNewUser.username; + const groupDisplayName = `${firstNewUserDisplayName}, ${secondNewUserDisplayName}`; + await expect(ChannelListScreen.getChannelListItemDisplayName(directMessagesCategory, groupDisplayName)).not.toBeVisible(); + + // # Open create direct message screen, search for the first new user and tap on the first new user item + await CreateDirectMessageScreen.open(); + await CreateDirectMessageScreen.searchInput.replaceText(firstNewUser.username); + await CreateDirectMessageScreen.getUserItem(firstNewUser.id).tap(); + + // * Verify the first new user is selected + await expect(CreateDirectMessageScreen.getSelectedUserDisplayName(firstNewUser.id)).toBeVisible(); + + // # Search for the second new user and tap on the second new user item + await CreateDirectMessageScreen.searchInput.replaceText(secondNewUser.username); + await CreateDirectMessageScreen.getUserItem(secondNewUser.id).tap(); + + // * Verify the second new user is selected + await expect(CreateDirectMessageScreen.getSelectedUserDisplayName(secondNewUser.id)).toBeVisible(); + + // # Tap on start button + await CreateDirectMessageScreen.startButton.tap(); + + // * Verify on group message channel screen for the other two new users + await ChannelScreen.toBeVisible(); + await expect(ChannelScreen.headerTitle).toHaveText(groupDisplayName); + await expect(ChannelScreen.introDisplayName).toHaveText(groupDisplayName); + + // # Go back to channel list screen + await ChannelScreen.back(); + await ChannelListScreen.toBeVisible(); + + // * Verify group message channel for the other two new users is added to direct message list + await expect(ChannelListScreen.getChannelListItemDisplayName(directMessagesCategory, `${firstNewUser.id}__${secondNewUser.id}`)).toHaveText(groupDisplayName); + }); +}); diff --git a/detox/e2e/test/server_login/connect_to_server.e2e.ts b/detox/e2e/test/server_login/connect_to_server.e2e.ts index 099affb473..7e0b8efbf0 100644 --- a/detox/e2e/test/server_login/connect_to_server.e2e.ts +++ b/detox/e2e/test/server_login/connect_to_server.e2e.ts @@ -38,12 +38,12 @@ describe('Server Login - Connect to Server', () => { it('MM-T4676_1 - should match elements on server screen', async () => { // * Verify basic elements on server screen - await expect(headerTitleConnectToServer).toBeVisible(); - await expect(headerWelcome).toBeVisible(); - await expect(headerDescription).toBeVisible(); + await expect(headerWelcome).toHaveText('Welcome'); + await expect(headerTitleConnectToServer).toHaveText('Let’s Connect to a Server'); + await expect(headerDescription).toHaveText('A Server is your team\'s communication hub which is accessed through a unique URL'); await expect(serverUrlInput).toBeVisible(); await expect(serverDisplayNameInput).toBeVisible(); - await expect(displayHelp).toBeVisible(); + await expect(displayHelp).toHaveText('Choose a display name for your server'); await expect(connectButtonDisabled).toBeVisible(); }); diff --git a/detox/e2e/test/server_login/login_by_email.e2e.ts b/detox/e2e/test/server_login/login_by_email.e2e.ts index e81ad36f4c..21323e0989 100644 --- a/detox/e2e/test/server_login/login_by_email.e2e.ts +++ b/detox/e2e/test/server_login/login_by_email.e2e.ts @@ -22,11 +22,13 @@ import {expect} from 'detox'; describe('Server Login - Login by Email', () => { const { backButton, + descriptionEnterCredentials, forgotPasswordButton, passwordInput, passwordInputError, signinButton, signinButtonDisabled, + titleLoginToAccount, usernameInput, } = LoginScreen; const serverOneDisplayName = 'Server 1'; @@ -48,6 +50,8 @@ describe('Server Login - Login by Email', () => { it('MM-T4677_1 - should match elements on login screen', async () => { // * Verify basic elements on login screen await expect(backButton).toBeVisible(); + await expect(titleLoginToAccount).toHaveText('Log In to Your Account'); + await expect(descriptionEnterCredentials).toHaveText('Enter your login details below.'); await expect(usernameInput).toBeVisible(); await expect(passwordInput).toBeVisible(); await expect(forgotPasswordButton).toBeVisible(); diff --git a/detox/e2e/test/server_login/server_list.e2e.ts b/detox/e2e/test/server_login/server_list.e2e.ts index d840c8fa67..82d46dd340 100644 --- a/detox/e2e/test/server_login/server_list.e2e.ts +++ b/detox/e2e/test/server_login/server_list.e2e.ts @@ -48,21 +48,37 @@ describe('Server Login - Server List', () => { await LoginScreen.login(serverOneUser); }); + beforeEach(async () => { + // * Verify on channel list screen + await ChannelListScreen.toBeVisible(); + }); + afterAll(async () => { // # Log out await HomeScreen.logout(); }); - it('MM-T4691_1 - should be able to add and log in to new servers', async () => { + it('MM-T4691_1 - should match elements on server list screen', async () => { + // # Open server list screen + await ServerListScreen.open(); + + // * Verify basic elements on server list screen + await expect(ServerListScreen.serverListTitle).toHaveText('Your servers'); + await expect(ServerListScreen.getServerItemActive(serverOneDisplayName)).toBeVisible(); + await expect(ServerListScreen.addServerButton).toBeVisible(); + + // # Go back to channel list screen + await ServerListScreen.getServerItemActive(serverOneDisplayName).tap(); + }); + + it('MM-T4691_2 - should be able to add and log in to new servers', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen await ServerListScreen.open(); // * Verify first server is active - await ServerListScreen.toBeVisible(); await expect(ServerListScreen.getServerItemActive(serverOneDisplayName)).toBeVisible(); // # Add a second server and log in to the second server @@ -81,7 +97,6 @@ describe('Server Login - Server List', () => { await ServerListScreen.open(); // * Verify second server is active and first server is inactive - await ServerListScreen.toBeVisible(); await expect(ServerListScreen.getServerItemActive(serverTwoDisplayName)).toBeVisible(); await expect(ServerListScreen.getServerItemInactive(serverOneDisplayName)).toBeVisible(); @@ -101,7 +116,6 @@ describe('Server Login - Server List', () => { await ServerListScreen.open(); // * Verify third server is active, and first and second servers are inactive - await ServerListScreen.toBeVisible(); await expect(ServerListScreen.getServerItemActive(serverThreeDisplayName)).toBeVisible(); await expect(ServerListScreen.getServerItemInactive(serverOneDisplayName)).toBeVisible(); await expect(ServerListScreen.getServerItemInactive(serverTwoDisplayName)).toBeVisible(); @@ -110,9 +124,8 @@ describe('Server Login - Server List', () => { await ServerListScreen.getServerItemInactive(serverOneDisplayName).tap(); }); - it('MM-T4691_2 - should be able to switch to another existing server', async () => { + it('MM-T4691_3 - should be able to switch to another existing server', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen and tap on third server @@ -128,9 +141,8 @@ describe('Server Login - Server List', () => { await ServerListScreen.getServerItemInactive(serverOneDisplayName).tap(); }); - it('MM-T4691_3 - should be able to edit server display name of active and inactive servers', async () => { + it('MM-T4691_4 - should be able to edit server display name of active and inactive servers', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen, swipe left on first server and tap on edit option @@ -168,9 +180,8 @@ describe('Server Login - Server List', () => { await ServerListScreen.getServerItemActive(serverOneDisplayName).tap(); }); - it('MM-T4691_4 - should be able to remove a server from the list', async () => { + it('MM-T4691_5 - should be able to remove a server from the list', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen, swipe left on first server and tap on remove option @@ -196,9 +207,8 @@ describe('Server Login - Server List', () => { await LoginScreen.login(serverOneUser); }); - it('MM-T4691_5 - should be able to log out a server from the list', async () => { + it('MM-T4691_6 - should be able to log out a server from the list', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen, swipe left on first server and tap on logout option @@ -224,9 +234,8 @@ describe('Server Login - Server List', () => { await LoginScreen.login(serverOneUser); }); - it('MM-T4691_6 - should not be able to add server for an already existing server', async () => { + it('MM-T4691_7 - should not be able to add server for an already existing server', async () => { // * Verify on channel list screen of the first server - await ChannelListScreen.toBeVisible(); await expect(ChannelListScreen.headerServerDisplayName).toHaveText(serverOneDisplayName); // # Open server list screen, attempt to add a server already logged in and with inactive session @@ -250,6 +259,6 @@ describe('Server Login - Server List', () => { await expect(ServerScreen.serverDisplayNameInputError).toHaveText(sameNameServerError); // # Close server screen to go back to first server - await ServerScreen.closeButton.tap(); + await ServerScreen.close(); }); }); diff --git a/detox/e2e/test/smoke_test/server_login.e2e.ts b/detox/e2e/test/smoke_test/server_login.e2e.ts index 2004676e71..7790cfa68a 100644 --- a/detox/e2e/test/smoke_test/server_login.e2e.ts +++ b/detox/e2e/test/smoke_test/server_login.e2e.ts @@ -26,7 +26,7 @@ import { } from '@support/ui/screen'; import {expect} from 'detox'; -describe('Server Login', () => { +describe('Smoke Test - Server Login', () => { const serverOneDisplayName = 'Server 1'; const serverTwoDisplayName = 'Server 2'; diff --git a/test/test_helper.ts b/test/test_helper.ts index aafeca9f58..864c6dc0a4 100644 --- a/test/test_helper.ts +++ b/test/test_helper.ts @@ -190,10 +190,8 @@ class TestHelper { }; fakeChannel = (teamId: string): Channel => { - const name = this.generateId(); - return { - name, + name: 'channel', team_id: teamId, // @to-do: Make tests more detriministic;