From f2c3ffa6bc8b4f68fa3a0df54bedb4fe86e1bdaf Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 20 Feb 2023 17:34:51 -0300 Subject: [PATCH] Fix several tests --- app/views/RoomInfoEditView/index.tsx | 1 - e2e/tests/assorted/01-e2eencryption.spec.ts | 1 + e2e/tests/assorted/02-broadcast.spec.ts | 23 +++++++++------ e2e/tests/assorted/03-profile.spec.ts | 2 +- e2e/tests/assorted/06-status.spec.ts | 1 + .../assorted/14-in-app-notification.spec.ts | 2 +- e2e/tests/onboarding/04-createuser.spec.ts | 5 +++- e2e/tests/room/01-createroom.spec.ts | 13 ++++----- e2e/tests/room/08-roominfo.spec.ts | 10 ++++++- e2e/tests/team/03-moveconvert.spec.ts | 29 +++++++++++-------- 10 files changed, 54 insertions(+), 33 deletions(-) diff --git a/app/views/RoomInfoEditView/index.tsx b/app/views/RoomInfoEditView/index.tsx index a55bc2a3a..48f023e44 100644 --- a/app/views/RoomInfoEditView/index.tsx +++ b/app/views/RoomInfoEditView/index.tsx @@ -655,7 +655,6 @@ class RoomInfoEditView extends React.Component this.setState({ joinCode: value })} - onSubmitEditing={this.submit} secureTextEntry testID='room-info-edit-view-password' /> diff --git a/e2e/tests/assorted/01-e2eencryption.spec.ts b/e2e/tests/assorted/01-e2eencryption.spec.ts index 6b12984b5..8d96ef641 100644 --- a/e2e/tests/assorted/01-e2eencryption.spec.ts +++ b/e2e/tests/assorted/01-e2eencryption.spec.ts @@ -134,6 +134,7 @@ describe('E2E Encryption', () => { .toExist() .withTimeout(5000); await element(by.id('create-channel-name')).replaceText(room); + await element(by.id('create-channel-name')).tapReturnKey(); await element(by.id('create-channel-encrypted')).longPress(); await element(by.id('create-channel-submit')).tap(); await waitFor(element(by.id('room-view'))) diff --git a/e2e/tests/assorted/02-broadcast.spec.ts b/e2e/tests/assorted/02-broadcast.spec.ts index c9ec2da6d..081318691 100644 --- a/e2e/tests/assorted/02-broadcast.spec.ts +++ b/e2e/tests/assorted/02-broadcast.spec.ts @@ -2,7 +2,17 @@ // const GA = OTP.googleAuthenticator; import { expect } from 'detox'; -import { navigateToLogin, login, mockMessage, tapBack, searchRoom, platformTypes, TTextMatcher, sleep } from '../../helpers/app'; +import { + navigateToLogin, + login, + mockMessage, + tapBack, + searchRoom, + platformTypes, + TTextMatcher, + sleep, + checkRoomTitle +} from '../../helpers/app'; import data from '../../data'; const testuser = data.users.regular; @@ -42,15 +52,10 @@ describe('Broadcast room', () => { .toExist() .withTimeout(5000); await element(by.id('create-channel-name')).replaceText(`broadcast${data.random}`); - await element(by.id('create-channel-broadcast')).longPress(); // https://github.com/facebook/react-native/issues/28032 + await element(by.id('create-channel-name')).tapReturnKey(); + await element(by.id('create-channel-broadcast')).tap(); await element(by.id('create-channel-submit')).tap(); - await waitFor(element(by.id('room-view'))) - .toBeVisible() - .withTimeout(60000); - await waitFor(element(by.id(`room-view-title-broadcast${data.random}`))) - .toBeVisible() - .withTimeout(60000); - await sleep(500); + await checkRoomTitle(`broadcast${data.random}`); await element(by.id('room-header')).tap(); await waitFor(element(by.id('room-actions-view'))) .toBeVisible() diff --git a/e2e/tests/assorted/03-profile.spec.ts b/e2e/tests/assorted/03-profile.spec.ts index 173ad8dfe..113ff3205 100644 --- a/e2e/tests/assorted/03-profile.spec.ts +++ b/e2e/tests/assorted/03-profile.spec.ts @@ -99,7 +99,7 @@ describe('Profile screen', () => { it('should change name and username', async () => { await element(by.id('profile-view-name')).replaceText(`${profileChangeUser.username}new`); await element(by.id('profile-view-username')).replaceText(`${profileChangeUser.username}new`); - await element(by.type(scrollViewType)).atIndex(1).swipe('up'); + await element(by.id('profile-view-list')).swipe('down'); await element(by.id('profile-view-submit')).tap(); await waitForToast(); }); diff --git a/e2e/tests/assorted/06-status.spec.ts b/e2e/tests/assorted/06-status.spec.ts index 57fb16c03..6e911eb45 100644 --- a/e2e/tests/assorted/06-status.spec.ts +++ b/e2e/tests/assorted/06-status.spec.ts @@ -55,6 +55,7 @@ describe('Status screen', () => { // TODO: flaky it('should change status text', async () => { await element(by.id('status-view-input')).replaceText('status-text-new'); + await element(by.id('status-view-online')).tap(); // necessary to receive in-app notifications later await element(by.id('status-view-submit')).tap(); await sleep(3000); // Wait until the loading hide await waitFor(element(by.label('status-text-new'))) diff --git a/e2e/tests/assorted/14-in-app-notification.spec.ts b/e2e/tests/assorted/14-in-app-notification.spec.ts index 84e95f74f..a55592e04 100644 --- a/e2e/tests/assorted/14-in-app-notification.spec.ts +++ b/e2e/tests/assorted/14-in-app-notification.spec.ts @@ -22,7 +22,7 @@ describe('InApp Notification', () => { it('should tap on InApp Notification', async () => { await sendMessage(data.users.alternate, dmCreatedRid, text); await waitFor(element(by.id(`in-app-notification-${text}`))) - .toExist() + .toBeVisible() .withTimeout(2000); await waitForInAppNotificationAnimation(); await element(by.id(`in-app-notification-${text}`)).tap(); diff --git a/e2e/tests/onboarding/04-createuser.spec.ts b/e2e/tests/onboarding/04-createuser.spec.ts index 70d4ae371..1852ba758 100644 --- a/e2e/tests/onboarding/04-createuser.spec.ts +++ b/e2e/tests/onboarding/04-createuser.spec.ts @@ -10,10 +10,13 @@ describe('Create user screen', () => { describe('Usage', () => { it('should register', async () => { await element(by.id('register-view-name')).replaceText(data.registeringUser.username); + await element(by.id('register-view-name')).tapReturnKey(); await element(by.id('register-view-username')).replaceText(data.registeringUser.username); + await element(by.id('register-view-username')).tapReturnKey(); await element(by.id('register-view-email')).replaceText(data.registeringUser.email); + await element(by.id('register-view-email')).tapReturnKey(); await element(by.id('register-view-password')).replaceText(data.registeringUser.password); - await element(by.id('register-view-submit')).tap(); + await element(by.id('login-view-password')).tapReturnKey(); await waitFor(element(by.id('rooms-list-view'))) .toBeVisible() .withTimeout(60000); diff --git a/e2e/tests/room/01-createroom.spec.ts b/e2e/tests/room/01-createroom.spec.ts index 8ecc4ee4c..e11dabfdb 100644 --- a/e2e/tests/room/01-createroom.spec.ts +++ b/e2e/tests/room/01-createroom.spec.ts @@ -1,7 +1,7 @@ import { expect } from 'detox'; import data from '../../data'; -import { tapBack, navigateToLogin, login, tryTapping, platformTypes, TTextMatcher } from '../../helpers/app'; +import { tapBack, navigateToLogin, login, tryTapping, platformTypes, TTextMatcher, tapAndWaitFor } from '../../helpers/app'; describe('Create room screen', () => { let alertButtonType: string; @@ -46,11 +46,7 @@ describe('Create room screen', () => { .toBeVisible() .withTimeout(5000); - await tryTapping(element(by.id('rooms-list-view-create-channel')), 3000); - // await element(by.id('rooms-list-view-create-channel')).tap(); - await waitFor(element(by.id('new-message-view'))) - .toExist() - .withTimeout(5000); + await tapAndWaitFor(element(by.id('rooms-list-view-create-channel')), element(by.id('new-message-view')), 2000); }); it('should search user and navigate', async () => { @@ -130,6 +126,7 @@ describe('Create room screen', () => { describe('Usage', () => { it('should get invalid room', async () => { await element(by.id('create-channel-name')).replaceText('general'); + await element(by.id('create-channel-name')).tapReturnKey(); await waitFor(element(by.id('create-channel-submit'))) .toExist() .withTimeout(2000); @@ -143,8 +140,8 @@ describe('Create room screen', () => { it('should create public room', async () => { const room = `public${data.random}`; - await element(by.id('create-channel-name')).replaceText(''); await element(by.id('create-channel-name')).replaceText(room); + await element(by.id('create-channel-name')).tapReturnKey(); await element(by.id('create-channel-type')).tap(); await waitFor(element(by.id('create-channel-submit'))) .toExist() @@ -190,6 +187,7 @@ describe('Create room screen', () => { .toExist() .withTimeout(5000); await element(by.id('create-channel-name')).replaceText(room); + await element(by.id('create-channel-name')).tapReturnKey(); await waitFor(element(by.id('create-channel-submit'))) .toExist() .withTimeout(2000); @@ -231,6 +229,7 @@ describe('Create room screen', () => { .toExist() .withTimeout(10000); await element(by.id('create-channel-name')).replaceText(room); + await element(by.id('create-channel-name')).tapReturnKey(); await waitFor(element(by.id('create-channel-submit'))) .toExist() .withTimeout(2000); diff --git a/e2e/tests/room/08-roominfo.spec.ts b/e2e/tests/room/08-roominfo.spec.ts index 90d5651de..574bfd6ba 100644 --- a/e2e/tests/room/08-roominfo.spec.ts +++ b/e2e/tests/room/08-roominfo.spec.ts @@ -163,8 +163,12 @@ describe('Room info screen', () => { await element(by.id('room-info-edit-view-name')).replaceText('abc'); await element(by.id('room-info-edit-view-description')).replaceText('abc'); await element(by.id('room-info-edit-view-topic')).replaceText('abc'); + await element(by.id('room-info-edit-view-topic')).tapReturnKey(); await element(by.id('room-info-edit-view-announcement')).replaceText('abc'); + await element(by.id('room-info-edit-view-announcement')).tapReturnKey(); await element(by.id('room-info-edit-view-password')).replaceText('abc'); + await element(by.id('room-info-edit-view-password')).tapReturnKey(); + await swipe('down'); // dismiss keyboard await element(by.id('room-info-edit-view-t')).tap(); await swipe('up'); await element(by.id('room-info-edit-view-ro')).tap(); @@ -184,6 +188,7 @@ describe('Room info screen', () => { it('should change room name', async () => { await element(by.id('room-info-edit-view-name')).replaceText(`${privateRoomName}new`); + await swipe('down'); // dismiss keyboard await swipe('up'); await element(by.id('room-info-edit-view-submit')).tap(); await waitForToast(); @@ -202,10 +207,13 @@ describe('Room info screen', () => { }); it('should change room description, topic, announcement', async () => { - await sleep(2000); // wait for changes to be applied from socket + await sleep(3000); // wait for changes to be applied from socket await element(by.id('room-info-edit-view-description')).replaceText('new description'); await element(by.id('room-info-edit-view-topic')).replaceText('new topic'); await element(by.id('room-info-edit-view-announcement')).replaceText('new announcement'); + await element(by.id('room-info-edit-view-announcement')).tapReturnKey(); + await element(by.id('room-info-edit-view-password')).tapReturnKey(); + await swipe('down'); // dismiss keyboard await swipe('up'); await element(by.id('room-info-edit-view-submit')).tap(); await waitForToast(); diff --git a/e2e/tests/team/03-moveconvert.spec.ts b/e2e/tests/team/03-moveconvert.spec.ts index b3cc33d92..704b59a44 100644 --- a/e2e/tests/team/03-moveconvert.spec.ts +++ b/e2e/tests/team/03-moveconvert.spec.ts @@ -1,5 +1,14 @@ import data from '../../data'; -import { navigateToLogin, login, tapBack, searchRoom, platformTypes, TTextMatcher } from '../../helpers/app'; +import { + navigateToLogin, + login, + tapBack, + searchRoom, + platformTypes, + TTextMatcher, + tapAndWaitFor, + sleep +} from '../../helpers/app'; const toBeConverted = `to-be-converted-${data.random}`; const toBeMoved = `to-be-moved-${data.random}`; @@ -21,6 +30,7 @@ const createChannel = async (room: string) => { .toExist() .withTimeout(10000); await element(by.id('create-channel-name')).replaceText(room); + await element(by.id('create-channel-name')).tapReturnKey(); await waitFor(element(by.id('create-channel-submit'))) .toExist() .withTimeout(10000); @@ -107,21 +117,16 @@ describe('Move/Convert Team', () => { await navigateToRoomActions(toBeMoved); await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await waitFor(element(by.id('room-actions-move-to-team'))) - .toExist() + .toBeVisible() .withTimeout(2000); await element(by.id('room-actions-move-to-team')).tap(); - await waitFor(element(by[textMatcher]('Move to Team')).atIndex(0)) - .toExist() - .withTimeout(2000); + await sleep(300); // wait for animation await waitFor(element(by.id('select-list-view-submit'))) - .toExist() + .toBeVisible() .withTimeout(2000); await element(by.id('select-list-view-submit')).tap(); - await waitFor(element(by[textMatcher]('Select Team'))) - .toExist() - .withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${toBeConverted}`))) - .toExist() + .toBeVisible() .withTimeout(2000); await element(by.id(`select-list-view-item-${toBeConverted}`)).tap(); await element(by.id('select-list-view-submit')).atIndex(0).tap(); @@ -132,11 +137,11 @@ describe('Move/Convert Team', () => { ) ) ) - .toExist() + .toBeVisible() .withTimeout(2000); await element(by[textMatcher]('Yes, move it!').and(by.type(alertButtonType))).tap(); await waitFor(element(by.id('room-view-header-team-channels'))) - .toExist() + .toBeVisible() .withTimeout(10000); });