Skip to content

Commit

Permalink
E2E: Mobile Drafts tests cases (#8469)
Browse files Browse the repository at this point in the history
  • Loading branch information
yasserfaraazkhan authored Jan 21, 2025
1 parent 44bce6c commit 2830d06
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 5 deletions.
7 changes: 6 additions & 1 deletion app/components/drafts_buttton/drafts_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ const DraftsButton: React.FC<DraftListProps> = ({
color={theme.sidebarText}
style={customStyles.opacity}
/>
<Text style={customStyles.count}>{draftsCount}</Text>
<Text
testID='channel_list.drafts.count'
style={customStyles.count}
>
{draftsCount}
</Text>
</View>
</View>
</TouchableOpacity>
Expand Down
2 changes: 1 addition & 1 deletion app/components/option_item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const OptionItem = ({
value={selected}
trackColor={trackColor}
thumbColor={thumbColor}
testID={`${testID}.toggled.${selected}`}
testID={`${testID}.toggled.${selected}.${value}`}
/>
);
} else if (type === OptionType.ARROW) {
Expand Down
4 changes: 4 additions & 0 deletions app/components/post_draft/draft_input/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ export default function DraftInputHeader({
{postPriority.requested_ack && (
<>
<CompassIcon
testID='drafts.requested_ack.icon'
color={theme.onlineIndicator}
name='check-circle-outline'
size={14}
/>
{!postPriority.priority && (
<FormattedText
testID='requested_ack.title'
id='requested_ack.title'
defaultMessage='Request Acknowledgements'
style={{color: theme.onlineIndicator}}
Expand All @@ -66,12 +68,14 @@ export default function DraftInputHeader({
{postPriority.persistent_notifications && (
<>
<CompassIcon
testID='drafts.persistent_notifications.icon'
color={PostPriorityColors.URGENT}
name='bell-ring-outline'
size={14}
/>
{noMentionsError && (
<FormattedText
testID='drafts.persistent_notifications.error.no_mentions.title'
id='persistent_notifications.error.no_mentions.title'
defaultMessage='Recipients must be @mentioned'
style={style.error}
Expand Down
5 changes: 4 additions & 1 deletion app/components/post_priority/post_priority_label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const PostPriorityLabel = ({label}: Props) => {
labelText = intl.formatMessage({id: 'post_priority.label.important', defaultMessage: 'IMPORTANT'});
}
return (
<View style={containerStyle}>
<View
testID={`${label}_post_priority_label`}
style={containerStyle}
>
<CompassIcon
name={iconName}
style={style.icon}
Expand Down
2 changes: 2 additions & 0 deletions app/screens/post_priority_picker/post_priority_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const PostPriorityPicker = ({
type='toggle'
selected={data.requested_ack}
descriptionNumberOfLines={2}
value='requested_ack'
/>
</View>
{displayPersistentNotifications && (
Expand All @@ -211,6 +212,7 @@ const PostPriorityPicker = ({
type='toggle'
selected={data.persistent_notifications}
descriptionNumberOfLines={2}
value='persistent_notifications'
/>
</View>
)}
Expand Down
1 change: 1 addition & 0 deletions detox/e2e/support/ui/component/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Alert {
removeButton3 = isAndroid() ? element(by.text('REMOVE')) : element(by.label('Remove')).atIndex(3);
yesButton = isAndroid() ? element(by.text('YES')) : element(by.label('Yes')).atIndex(0);
yesButton2 = isAndroid() ? element(by.text('YES')) : element(by.label('Yes')).atIndex(1);
sendButton = isAndroid() ? element(by.text('SEND')) : element(by.label('Send')).atIndex(1);
}

const alert = new Alert();
Expand Down
39 changes: 37 additions & 2 deletions detox/e2e/support/ui/screen/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,18 @@ class ChannelScreen {
introUnfavoriteAction: 'channel_post_list.intro_options.unfavorite.action',
introChannelInfoAction: 'channel_post_list.intro_options.channel_info.action',
toastMessage: 'toast.message',
};

postPriorityPicker: 'channel.post_draft.quick_actions.post_priority_action',
postPriorityImportantMessage: 'post_priority_picker_item.important',
postPriorityUrgentMessage: 'post_priority_picker_item.urgent',
postPriorityRequestAck: 'post_priority_picker_item.requested_ack.toggled.false.requested_ack',
postPriorityPersistentNotification: 'post_priority_picker_item.persistent_notifications.toggled.undefined.persistent_notifications',
};

postPriorityPersistentNotification = element(by.id(this.testID.postPriorityPersistentNotification));
postPriorityUrgentMessage = element(by.id(this.testID.postPriorityUrgentMessage));
postPriorityRequestAck = element(by.id(this.testID.postPriorityRequestAck));
postPriorityImportantMessage = element(by.id(this.testID.postPriorityImportantMessage));
postPriorityPicker = element(by.id(this.testID.postPriorityPicker));
archievedCloseChannelButton = element(by.id(this.testID.archievedCloseChannelButton));
channelScreen = element(by.id(this.testID.channelScreen));
channelQuickActionsButton = element(by.id(this.testID.channelQuickActionsButton));
Expand All @@ -63,6 +73,7 @@ class ChannelScreen {
introUnfavoriteAction = element(by.id(this.testID.introUnfavoriteAction));
introChannelInfoAction = element(by.id(this.testID.introChannelInfoAction));
toastMessage = element(by.id(this.testID.toastMessage));
applyPostPriority = element(by.text('Apply'));

// convenience props
backButton = NavigationHeader.backButton;
Expand Down Expand Up @@ -196,6 +207,30 @@ class ChannelScreen {
this.getPostMessageAtIndex(index),
).toHaveText(postMessage);
};

openPostPriorityPicker = async () => {
await this.postPriorityPicker.tap();
};

clickPostPriorityImportantMessage = async () => {
await this.postPriorityImportantMessage.tap();
};

clickPostPriorityUrgentMessage = async () => {
await this.postPriorityUrgentMessage.tap();
};

toggleRequestAckPostpriority = async () => {
await this.postPriorityRequestAck.tap();
};

togglePersistentNotificationPostpriority = async () => {
await this.postPriorityPersistentNotification.tap();
};

applyPostPrioritySettings = async () => {
await this.applyPostPriority.tap();
};
}

const channelScreen = new ChannelScreen();
Expand Down
19 changes: 19 additions & 0 deletions detox/e2e/support/ui/screen/channel_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class ChannelListScreen {
testID = {
categoryHeaderPrefix: 'channel_list.category_header.',
categoryPrefix: 'channel_list.category.',
draftChannelInfo: 'draft_post.channel_info',
draftbuttonListScreen: 'channel_list.drafts.button',
draftCountListScreen: 'channel_list.drafts.count',
teamItemPrefix: 'team_sidebar.team_list.team_item.',
channelListScreen: 'channel_list.screen',
serverIcon: 'channel_list.servers.server_icon',
Expand Down Expand Up @@ -83,6 +86,22 @@ class ChannelListScreen {

return this.toBeVisible();
};

draftsButton = {
toBeVisible: async () => {
await waitFor(element(by.id(this.testID.draftbuttonListScreen))).toBeVisible().withTimeout(timeouts.ONE_SEC);
},
toNotBeVisible: async () => {
await waitFor(element(by.id(this.testID.draftbuttonListScreen))).not.toBeVisible().withTimeout(timeouts.ONE_SEC);
},
tap: async () => {
await element(by.id(this.testID.draftbuttonListScreen)).tap();
},
};

getDraftChannelInfo = () => {
return element(by.id(this.testID.draftChannelInfo));
};
}

const channelListScreen = new ChannelListScreen();
Expand Down
90 changes: 90 additions & 0 deletions detox/e2e/support/ui/screen/draft_screen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import {Alert, NavigationHeader} from '@support/ui/component';
import {timeouts, wait} from '@support/utils';
import {expect} from 'detox';

class DraftScreen {
testID = {
editDraft: 'edit_draft',
deleteDraft: 'delete_draft',
draftMessageContent: 'draft_message',
draftScreen: 'global_drafts_list',
draftTooltipCloseButton: 'draft.tooltip.close.button',
draftPost: 'draft_post',
draftSendButton: 'send_draft_button',
draftEmptyTitle: 'drafts.empty.title',
requestACKIcon: 'drafts.requested_ack.icon',
persistentNotificationIcon: 'drafts.persistent_notifications.icon',
};

persistentNotificationIcon = element(by.id(this.testID.persistentNotificationIcon));
requestACKIcon = element(by.id(this.testID.requestACKIcon));
editDraft = element(by.id(this.testID.editDraft));
backButton = NavigationHeader.backButton;
draftScreen = element(by.id(this.testID.draftScreen));
draftPost = element(by.id(this.testID.draftPost));
draftSendButton = element(by.id(this.testID.draftSendButton));
draftEmptyTitle = element(by.id(this.testID.draftEmptyTitle));
deleteDraftSwipeAction = element(by.text('Delete draft'));
draftMessageContent = element(by.id(this.testID.draftMessageContent));
deleteDraft = element(by.id(this.testID.deleteDraft));

draftTooltipCloseButton = {
tap: async () => {
await element(by.id(this.testID.draftTooltipCloseButton)).tap();
},
};

openDraftPostActions = async () => {
await this.draftPost.longPress();
};

swipeDraftPostLeft = async () => {
await this.draftPost.swipe('left');
};

deleteDraftPost = async (deleteAction: any) => {
await expect(deleteAction).toBeVisible();
await deleteAction.tap();
await waitFor(Alert.deleteButton).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.deleteButton.tap();
};

deleteDraftPostFromSwipeActions = async () => {
await this.deleteDraftPost(this.deleteDraftSwipeAction);
};

deleteDraftPostFromDraftActions = async () => {
await this.deleteDraftPost(this.deleteDraft);
};

sendDraft = async () => {
await this.draftSendButton.tap();
await waitFor(Alert.sendButton).toExist().withTimeout(timeouts.TEN_SEC);
await Alert.sendButton.tap();
};

editDraftPost = async () => {
await this.editDraft.tap();
};

draftEmptyScreen = async () => {
return this.draftEmptyTitle;
};

back = async () => {
await wait(timeouts.ONE_SEC);
await this.backButton.tap();
expect(this.draftScreen).not.toBeVisible();
};

getDraftMessageContentText = async () => {
await expect(this.draftMessageContent).toBeVisible();
return this.draftMessageContent;
};
}

const draftScreen = new DraftScreen();
export default draftScreen;
2 changes: 2 additions & 0 deletions detox/e2e/support/ui/screen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CreateDirectMessageScreen from './create_direct_message';
import CreateOrEditChannelScreen from './create_or_edit_channel';
import CustomStatusScreen from './custom_status';
import DisplaySettingsScreen from './display_settings';
import DraftScreen from './draft_screen';
import EditPostScreen from './edit_post';
import EditProfileScreen from './edit_profile';
import EditServerScreen from './edit_server';
Expand Down Expand Up @@ -93,4 +94,5 @@ export {
ThreadOptionsScreen,
TimezoneDisplaySettingsScreen,
UserProfileScreen,
DraftScreen,
};
Loading

0 comments on commit 2830d06

Please sign in to comment.