From a819f63d99aedfe180ff414c5360bf60d79c7cae Mon Sep 17 00:00:00 2001 From: Saturnino Abril Date: Tue, 3 Nov 2020 18:11:49 +0800 Subject: [PATCH] MM-30076 Detox/E2E: Update UI test structure for reusability (#4931) * update UI test structure for reusability * fix Android tests * improve autocomplete test * minor cleanup --- .../autocomplete/at_mention/at_mention.js | 2 +- app/components/autocomplete/autocomplete.js | 1 + .../channel_mention/channel_mention.js | 2 +- .../emoji_suggestion.test.js.snap | 2 +- .../emoji_suggestion/emoji_suggestion.js | 2 +- .../slash_suggestion/slash_suggestion.js | 2 +- .../edit_channel_info.test.js.snap | 1 - .../edit_channel_info/edit_channel_info.js | 4 +- .../__snapshots__/error_text.test.js.snap | 2 +- app/components/error_text/error_text.js | 4 +- .../__snapshots__/index.test.js.snap | 2 +- app/components/pasteable_text_input/index.js | 2 +- .../__snapshots__/post_draft.test.js.snap | 4 +- app/components/post_draft/post_draft.test.js | 10 +- .../__snapshots__/send.test.js.snap | 6 +- .../post_draft/send_action/index.js | 4 +- .../reaction_picker.test.js.snap | 4 +- .../reaction_picker/reaction_picker.js | 2 +- app/components/search_bar/index.js | 1 - .../main/channels_list/channels_list.js | 2 +- .../sidebars/main/main_sidebar_base.js | 2 +- app/screens/add_reaction/index.js | 7 +- app/screens/channel/channel.android.js | 2 +- app/screens/channel/channel.ios.js | 2 +- .../__snapshots__/channel_info.test.js.snap | 1 + app/screens/channel_info/channel_info.js | 5 +- app/screens/create_channel/create_channel.js | 1 + app/screens/edit_channel/edit_channel.js | 1 + .../__snapshots__/edit_post.test.js.snap | 1 + app/screens/edit_post/edit_post.js | 5 +- app/screens/login/login.js | 8 +- .../__snapshots__/more_channels.test.js.snap | 1 + app/screens/more_channels/more_channels.js | 7 +- app/screens/more_dms/more_dms.js | 2 +- .../__snapshots__/post_options.test.js.snap | 3 + app/screens/post_options/post_options.js | 5 +- app/screens/search/search.js | 5 +- app/screens/select_server/select_server.js | 8 +- .../select_server/select_server.test.js | 14 +- detox/.babelrc | 1 + .../e2e/support/ui/component/autocomplete.js | 37 +++++ .../support/ui/component/channel_sidebar.js | 35 +++++ detox/e2e/support/ui/component/index.js | 12 ++ .../e2e/support/ui/component/post_options.js | 18 +++ detox/e2e/support/ui/screen.js | 62 -------- detox/e2e/support/ui/screen/add_reaction.js | 36 +++++ detox/e2e/support/ui/screen/channel.js | 52 ++++++ detox/e2e/support/ui/screen/channel_info.js | 38 +++++ detox/e2e/support/ui/screen/create_channel.js | 44 ++++++ .../e2e/support/ui/screen/direct_channels.js | 35 +++++ detox/e2e/support/ui/screen/edit_channel.js | 38 +++++ detox/e2e/support/ui/screen/edit_post.js | 42 +++++ detox/e2e/support/ui/screen/index.js | 30 ++++ detox/e2e/support/ui/screen/login.js | 55 +++++++ detox/e2e/support/ui/screen/more_channels.js | 31 ++++ detox/e2e/support/ui/screen/notification.js | 25 +++ detox/e2e/support/ui/screen/search.js | 44 ++++++ detox/e2e/support/ui/screen/select_server.js | 42 +++++ detox/e2e/test/autocomplete/at_mention.e2e.js | 83 +++++----- .../e2e/test/autocomplete/edit_channel.e2e.js | 27 ++-- detox/e2e/test/autocomplete/edit_post.e2e.js | 31 ++-- detox/e2e/test/autocomplete/post_draft.e2e.js | 48 +++--- detox/e2e/test/autocomplete/search.e2e.js | 39 +++-- detox/e2e/test/channel_info/header.e2e.js | 33 ++-- .../channels/create_public_channel.e2e.js | 54 ++++--- .../in_app_notification/notification.e2e.js | 35 +++-- .../test/main_sidebar/select_channel.e2e.js | 26 +-- .../e2e/test/messaging/message_posting.e2e.js | 28 ++-- .../tap_send_button_repeatedly.e2e.js | 11 +- detox/e2e/test/on_boarding/login.e2e.js | 148 +++++++++--------- detox/e2e/test/smoke_test/channels.e2e.js | 44 +++--- detox/e2e/test/smoke_test/login_email.e2e.js | 33 ++-- detox/e2e/test/smoke_test/login_ldap.e2e.js | 33 ++-- detox/package.json | 1 + 74 files changed, 1056 insertions(+), 434 deletions(-) create mode 100644 detox/e2e/support/ui/component/autocomplete.js create mode 100644 detox/e2e/support/ui/component/channel_sidebar.js create mode 100644 detox/e2e/support/ui/component/index.js create mode 100644 detox/e2e/support/ui/component/post_options.js delete mode 100644 detox/e2e/support/ui/screen.js create mode 100644 detox/e2e/support/ui/screen/add_reaction.js create mode 100644 detox/e2e/support/ui/screen/channel.js create mode 100644 detox/e2e/support/ui/screen/channel_info.js create mode 100644 detox/e2e/support/ui/screen/create_channel.js create mode 100644 detox/e2e/support/ui/screen/direct_channels.js create mode 100644 detox/e2e/support/ui/screen/edit_channel.js create mode 100644 detox/e2e/support/ui/screen/edit_post.js create mode 100644 detox/e2e/support/ui/screen/index.js create mode 100644 detox/e2e/support/ui/screen/login.js create mode 100644 detox/e2e/support/ui/screen/more_channels.js create mode 100644 detox/e2e/support/ui/screen/notification.js create mode 100644 detox/e2e/support/ui/screen/search.js create mode 100644 detox/e2e/support/ui/screen/select_server.js diff --git a/app/components/autocomplete/at_mention/at_mention.js b/app/components/autocomplete/at_mention/at_mention.js index 7e045f59f..6a47fc173 100644 --- a/app/components/autocomplete/at_mention/at_mention.js +++ b/app/components/autocomplete/at_mention/at_mention.js @@ -266,7 +266,7 @@ export default class AtMention extends PureComponent { return ( diff --git a/app/components/autocomplete/channel_mention/channel_mention.js b/app/components/autocomplete/channel_mention/channel_mention.js index 20b79467d..3a6610d96 100644 --- a/app/components/autocomplete/channel_mention/channel_mention.js +++ b/app/components/autocomplete/channel_mention/channel_mention.js @@ -220,7 +220,7 @@ export default class ChannelMention extends PureComponent { return ( diff --git a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js index 8c25b2d09..48f9e7ac7 100644 --- a/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js +++ b/app/components/autocomplete/emoji_suggestion/emoji_suggestion.js @@ -226,7 +226,7 @@ export default class EmojiSuggestion extends PureComponent { return ( Username must begin with a letter and contain between 3 and 22 characters including numbers, lowercase letters, and the symbols diff --git a/app/components/error_text/error_text.js b/app/components/error_text/error_text.js index 6da48bd6a..72f88c408 100644 --- a/app/components/error_text/error_text.js +++ b/app/components/error_text/error_text.js @@ -29,7 +29,7 @@ export default class ErrorText extends PureComponent { if (intl) { return ( {error.message || error} diff --git a/app/components/pasteable_text_input/__snapshots__/index.test.js.snap b/app/components/pasteable_text_input/__snapshots__/index.test.js.snap index 39a292f1c..8e1dbe0ea 100644 --- a/app/components/pasteable_text_input/__snapshots__/index.test.js.snap +++ b/app/components/pasteable_text_input/__snapshots__/index.test.js.snap @@ -5,7 +5,7 @@ exports[`PasteableTextInput should render pasteable text input 1`] = ` allowFontScaling={true} onPaste={[Function]} rejectResponderTermination={true} - testID="post_input" + testID="post.input" underlineColorAndroid="transparent" > My Text diff --git a/app/components/pasteable_text_input/index.js b/app/components/pasteable_text_input/index.js index b8ac6e917..239a90178 100644 --- a/app/components/pasteable_text_input/index.js +++ b/app/components/pasteable_text_input/index.js @@ -57,7 +57,7 @@ export class PasteableTextInput extends React.PureComponent { return ( @@ -531,7 +531,7 @@ exports[`PostDraft Should render the DraftInput 1`] = ` "paddingRight": 8, } } - testID="disabled_send_button" + testID="disabled_send.button" > { ); expect(toJSON()).toMatchSnapshot(); - expect(getByTestId('post_input')).toBeTruthy(); + expect(getByTestId('post.input')).toBeTruthy(); expect(queryByText('Close Channel')).toBeNull(); }); @@ -79,7 +79,7 @@ describe('PostDraft', () => { expect(toJSON()).toMatchSnapshot(); // Should not render text input - expect(queryByTestId('post_input')).toBeNull(); + expect(queryByTestId('post.input')).toBeNull(); // Should match text description expect(getByText('You are viewing an ')).toBeTruthy(); @@ -100,7 +100,7 @@ describe('PostDraft', () => { expect(toJSON()).toMatchSnapshot(); // Should not render text input - expect(queryByTestId('post_input')).toBeNull(); + expect(queryByTestId('post.input')).toBeNull(); // Should match text description expect(getByText('You are viewing an ')).toBeTruthy(); @@ -121,7 +121,7 @@ describe('PostDraft', () => { expect(toJSON()).toMatchSnapshot(); // Should not render text input - expect(queryByTestId('post_input')).toBeNull(); + expect(queryByTestId('post.input')).toBeNull(); // Should match text description expect(getByText('This channel is read-only.')).toBeTruthy(); @@ -140,7 +140,7 @@ describe('PostDraft', () => { expect(toJSON()).toMatchSnapshot(); // Should not render text input - expect(queryByTestId('post_input')).toBeNull(); + expect(queryByTestId('post.input')).toBeNull(); // Should match text description expect(getByText('This channel is read-only.')).toBeTruthy(); diff --git a/app/components/post_draft/send_action/__snapshots__/send.test.js.snap b/app/components/post_draft/send_action/__snapshots__/send.test.js.snap index 6705bb28e..5b787c37e 100644 --- a/app/components/post_draft/send_action/__snapshots__/send.test.js.snap +++ b/app/components/post_draft/send_action/__snapshots__/send.test.js.snap @@ -8,7 +8,7 @@ exports[`SendAction should change theme backgroundColor to 0.3 opacity 1`] = ` "paddingRight": 8, } } - testID="disabled_send_button" + testID="disabled_send.button" > @@ -32,7 +32,7 @@ function SendButton(props) { return ( {title} diff --git a/app/components/sidebars/main/main_sidebar_base.js b/app/components/sidebars/main/main_sidebar_base.js index 01914d9e3..dbc04078b 100644 --- a/app/components/sidebars/main/main_sidebar_base.js +++ b/app/components/sidebars/main/main_sidebar_base.js @@ -256,7 +256,7 @@ export default class MainSidebarBase extends Component { showTeams={showTeams} drawerOpened={this.state.drawerOpened} drawerWidth={drawerWidth - offset} - testID='main_sidebar' + testID='main.sidebar' > {lists} diff --git a/app/screens/add_reaction/index.js b/app/screens/add_reaction/index.js index e0a62ec02..1da5bd71e 100644 --- a/app/screens/add_reaction/index.js +++ b/app/screens/add_reaction/index.js @@ -27,7 +27,7 @@ export default class AddReaction extends PureComponent { leftButton = { id: 'close-add-reaction', - testID: 'screen.add_reaction.close', + testID: 'close.add_reaction.button', }; constructor(props) { @@ -60,7 +60,10 @@ export default class AddReaction extends PureComponent { render() { return ( - + ); diff --git a/app/screens/channel/channel.android.js b/app/screens/channel/channel.android.js index f6a8d56f1..a6e86243c 100644 --- a/app/screens/channel/channel.android.js +++ b/app/screens/channel/channel.android.js @@ -67,7 +67,7 @@ export default class ChannelAndroid extends ChannelBase { component = ( diff --git a/app/screens/channel/channel.ios.js b/app/screens/channel/channel.ios.js index 40089f8a7..3e9a3a15f 100644 --- a/app/screens/channel/channel.ios.js +++ b/app/screens/channel/channel.ios.js @@ -107,7 +107,7 @@ export default class ChannelIOS extends ChannelBase { return ( 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 d71c797e5..c018b780e 100644 --- a/app/screens/channel_info/__snapshots__/channel_info.test.js.snap +++ b/app/screens/channel_info/__snapshots__/channel_info.test.js.snap @@ -7,6 +7,7 @@ exports[`channelInfo should match snapshot 1`] = ` "flex": 1, } } + testID="channel_info.screen" > + - + {displayError} diff --git a/app/screens/login/login.js b/app/screens/login/login.js index c1538984b..76be25c63 100644 --- a/app/screens/login/login.js +++ b/app/screens/login/login.js @@ -339,7 +339,7 @@ export default class Login extends PureComponent { proceed = (