From 2ebfa0230e1f6482a0186d119d2af56c9bb0d4a9 Mon Sep 17 00:00:00 2001 From: Joseph Baylon Date: Thu, 2 Feb 2023 20:08:15 -0800 Subject: [PATCH] Fix messaging e2e for android --- detox/e2e/support/ui/screen/emoji_picker.ts | 9 +++++++-- detox/e2e/support/ui/screen/post_options.ts | 9 +++++++-- detox/e2e/support/ui/screen/reactions.ts | 9 +++++++-- detox/e2e/support/ui/screen/server_list.ts | 9 +++++++-- detox/e2e/support/ui/screen/thread_options.ts | 9 +++++++-- detox/e2e/support/ui/screen/user_profile.ts | 9 +++++++-- detox/e2e/test/messaging/message_draft.e2e.ts | 2 +- detox/e2e/test/messaging/message_post.e2e.ts | 5 ++++- detox/e2e/test/messaging/pin_and_unpin_message.e2e.ts | 3 +++ detox/e2e/test/messaging/save_and_unsave_message.e2e.ts | 3 +++ 10 files changed, 53 insertions(+), 14 deletions(-) diff --git a/detox/e2e/support/ui/screen/emoji_picker.ts b/detox/e2e/support/ui/screen/emoji_picker.ts index 115858044c..c2772317f9 100644 --- a/detox/e2e/support/ui/screen/emoji_picker.ts +++ b/detox/e2e/support/ui/screen/emoji_picker.ts @@ -3,7 +3,7 @@ import {SearchBar} from '@support/ui/component'; import {PostOptionsScreen} from '@support/ui/screen'; -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class EmojiPickerScreen { @@ -42,7 +42,12 @@ class EmojiPickerScreen { }; close = async () => { - await this.emojiPickerScreen.swipe('down'); + if (isIos()) { + await this.emojiPickerScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.emojiPickerScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/support/ui/screen/post_options.ts b/detox/e2e/support/ui/screen/post_options.ts index 3c9e9549f0..6f6f04db8c 100644 --- a/detox/e2e/support/ui/screen/post_options.ts +++ b/detox/e2e/support/ui/screen/post_options.ts @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {Alert} from '@support/ui/component'; -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class PostOptionsScreen { @@ -50,7 +50,12 @@ class PostOptionsScreen { }; close = async () => { - await this.postOptionsScreen.swipe('down'); + if (isIos()) { + await this.postOptionsScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.postOptionsScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/support/ui/screen/reactions.ts b/detox/e2e/support/ui/screen/reactions.ts index a372878650..59ef798239 100644 --- a/detox/e2e/support/ui/screen/reactions.ts +++ b/detox/e2e/support/ui/screen/reactions.ts @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {ProfilePicture} from '@support/ui/component'; -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class ReactionsScreen { @@ -22,7 +22,12 @@ class ReactionsScreen { }; close = async () => { - await this.reactionsScreen.swipe('down'); + if (isIos()) { + await this.reactionsScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.reactionsScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/support/ui/screen/server_list.ts b/detox/e2e/support/ui/screen/server_list.ts index 48192eb6e1..13abd97432 100644 --- a/detox/e2e/support/ui/screen/server_list.ts +++ b/detox/e2e/support/ui/screen/server_list.ts @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {ChannelListScreen} from '@support/ui/screen'; -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class ServerListScreen { @@ -66,7 +66,12 @@ class ServerListScreen { }; close = async () => { - await this.serverListScreen.swipe('down'); + if (isIos()) { + await this.serverListScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.serverListScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/support/ui/screen/thread_options.ts b/detox/e2e/support/ui/screen/thread_options.ts index 0e3f614642..0c6375a345 100644 --- a/detox/e2e/support/ui/screen/thread_options.ts +++ b/detox/e2e/support/ui/screen/thread_options.ts @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class ThreadOptionsScreen { @@ -36,7 +36,12 @@ class ThreadOptionsScreen { }; close = async () => { - await this.threadOptionsScreen.swipe('down'); + if (isIos()) { + await this.threadOptionsScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.threadOptionsScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/support/ui/screen/user_profile.ts b/detox/e2e/support/ui/screen/user_profile.ts index 1c0a02090d..93acb41f03 100644 --- a/detox/e2e/support/ui/screen/user_profile.ts +++ b/detox/e2e/support/ui/screen/user_profile.ts @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import {ProfilePicture} from '@support/ui/component'; -import {timeouts, wait} from '@support/utils'; +import {isIos, timeouts, wait} from '@support/utils'; import {expect} from 'detox'; class UserProfileScreen { @@ -47,7 +47,12 @@ class UserProfileScreen { }; close = async () => { - await this.userProfileScreen.swipe('down'); + if (isIos()) { + await this.userProfileScreen.swipe('down'); + } else { + await device.pressBack(); + } + await wait(timeouts.ONE_SEC); await expect(this.userProfileScreen).not.toBeVisible(); await wait(timeouts.ONE_SEC); }; diff --git a/detox/e2e/test/messaging/message_draft.e2e.ts b/detox/e2e/test/messaging/message_draft.e2e.ts index 8263cfcae9..6ee9b4a063 100644 --- a/detox/e2e/test/messaging/message_draft.e2e.ts +++ b/detox/e2e/test/messaging/message_draft.e2e.ts @@ -144,7 +144,7 @@ describe('Messaging - Message Draft', () => { await ChannelScreen.back(); }); - it('MM-T4781_4 - should be able to create a message draft from reply thread', async () => { + it('MM-T4781_4 - should be able to create a message draft from reply thread -- KNOWN ISSUE: MM-50298', async () => { // # Open a channel screen, post a message, and tap on the post to open reply thread const message = `Message ${getRandomId()}`; await ChannelScreen.open(channelsCategory, testChannel.name); diff --git a/detox/e2e/test/messaging/message_post.e2e.ts b/detox/e2e/test/messaging/message_post.e2e.ts index 391b130a72..bdb32a9d54 100644 --- a/detox/e2e/test/messaging/message_post.e2e.ts +++ b/detox/e2e/test/messaging/message_post.e2e.ts @@ -22,7 +22,7 @@ import { LoginScreen, ServerScreen, } from '@support/ui/screen'; -import {getRandomId} from '@support/utils'; +import {getRandomId, isAndroid} from '@support/utils'; import {expect} from 'detox'; describe('Messaging - Message Post', () => { @@ -87,6 +87,9 @@ describe('Messaging - Message Post', () => { await ChannelScreen.postMessage('short message'); // * Verify long message is posted and displays show more button (chevron down button) + if (isAndroid()) { + await device.pressBack(); + } const {postListPostItem, postListPostItemShowLessButton, postListPostItemShowMoreButton} = ChannelScreen.getPostListPostItem(post.id, longMessage); await expect(postListPostItem).toBeVisible(); await expect(postListPostItemShowMoreButton).toBeVisible(); diff --git a/detox/e2e/test/messaging/pin_and_unpin_message.e2e.ts b/detox/e2e/test/messaging/pin_and_unpin_message.e2e.ts index 05bbca7324..93d29a6bbd 100644 --- a/detox/e2e/test/messaging/pin_and_unpin_message.e2e.ts +++ b/detox/e2e/test/messaging/pin_and_unpin_message.e2e.ts @@ -68,6 +68,7 @@ describe('Messaging - Pin and Unpin Message', () => { await PostOptionsScreen.pinPostOption.tap(); // * Verify pinned text is displayed on the post pre-header + await wait(timeouts.ONE_SEC); const {postListPostItemPreHeaderText} = ChannelScreen.getPostListPostItem(post.id, message); await expect(postListPostItemPreHeaderText).toHaveText(pinnedText); @@ -76,6 +77,7 @@ describe('Messaging - Pin and Unpin Message', () => { await PostOptionsScreen.unpinPostOption.tap(); // * Verify pinned text is not displayed on the post pre-header + await wait(timeouts.ONE_SEC); await expect(postListPostItemPreHeaderText).not.toBeVisible(); // # Go back to channel list screen @@ -103,6 +105,7 @@ describe('Messaging - Pin and Unpin Message', () => { await PostOptionsScreen.unpinPostOption.tap(); // * Verify pinned text is not displayed on the post pre-header + await wait(timeouts.ONE_SEC); await expect(postListPostItemPreHeaderText).not.toBeVisible(); // # Go back to channel list screen diff --git a/detox/e2e/test/messaging/save_and_unsave_message.e2e.ts b/detox/e2e/test/messaging/save_and_unsave_message.e2e.ts index eeb5d9e1d5..788084cdd2 100644 --- a/detox/e2e/test/messaging/save_and_unsave_message.e2e.ts +++ b/detox/e2e/test/messaging/save_and_unsave_message.e2e.ts @@ -68,6 +68,7 @@ describe('Messaging - Save and Unsave Message', () => { await PostOptionsScreen.savePostOption.tap(); // * Verify saved text is displayed on the post pre-header + await wait(timeouts.ONE_SEC); const {postListPostItemPreHeaderText} = ChannelScreen.getPostListPostItem(post.id, message); await expect(postListPostItemPreHeaderText).toHaveText(savedText); @@ -76,6 +77,7 @@ describe('Messaging - Save and Unsave Message', () => { await PostOptionsScreen.unsavePostOption.tap(); // * Verify saved text is not displayed on the post pre-header + await wait(timeouts.ONE_SEC); await expect(postListPostItemPreHeaderText).not.toBeVisible(); // # Go back to channel list screen @@ -94,6 +96,7 @@ describe('Messaging - Save and Unsave Message', () => { await PostOptionsScreen.savePostOption.tap(); // * Verify saved text is displayed on the post pre-header + await wait(timeouts.ONE_SEC); const {postListPostItemPreHeaderText} = ThreadScreen.getPostListPostItem(post.id, message); await expect(postListPostItemPreHeaderText).toHaveText(savedText);