From 8a83d22d35a9551d2e05e78f1ba6a2fee99149af Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 28 Feb 2023 14:00:10 -0300 Subject: [PATCH] Fix some flaky tests --- e2e/helpers/app.ts | 2 +- e2e/tests/assorted/01-e2eencryption.spec.ts | 3 ++ e2e/tests/assorted/02-broadcast.spec.ts | 3 ++ e2e/tests/assorted/05-joinpublicroom.spec.ts | 30 ++++++++------------ e2e/tests/room/01-createroom.spec.ts | 16 ++++++++--- e2e/tests/room/04-discussion.spec.ts | 5 +++- e2e/tests/team/03-moveconvert.spec.ts | 7 +++-- 7 files changed, 40 insertions(+), 26 deletions(-) diff --git a/e2e/helpers/app.ts b/e2e/helpers/app.ts index 4057ff0b2..a4cb77f1a 100644 --- a/e2e/helpers/app.ts +++ b/e2e/helpers/app.ts @@ -143,7 +143,7 @@ async function searchRoom(room: string) { .toBeVisible() .withTimeout(30000); await tapAndWaitFor(element(by.id('rooms-list-view-search')), element(by.id('rooms-list-view-search-input')), 5000); - await element(by.id('rooms-list-view-search-input')).replaceText(room); + await element(by.id('rooms-list-view-search-input')).typeText(room); await sleep(300); await waitFor(element(by.id(`rooms-list-view-item-${room}`))) .toBeVisible() diff --git a/e2e/tests/assorted/01-e2eencryption.spec.ts b/e2e/tests/assorted/01-e2eencryption.spec.ts index 91edb3f20..4de7dffe1 100644 --- a/e2e/tests/assorted/01-e2eencryption.spec.ts +++ b/e2e/tests/assorted/01-e2eencryption.spec.ts @@ -122,6 +122,9 @@ describe('E2E Encryption', () => { it('should create encrypted room', async () => { await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) + .toBeVisible() + .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) .toBeVisible() .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); diff --git a/e2e/tests/assorted/02-broadcast.spec.ts b/e2e/tests/assorted/02-broadcast.spec.ts index 2ab3f9368..c1e7a8e57 100644 --- a/e2e/tests/assorted/02-broadcast.spec.ts +++ b/e2e/tests/assorted/02-broadcast.spec.ts @@ -38,6 +38,9 @@ describe('Broadcast room', () => { .withTimeout(2000); await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) + .toBeVisible() + .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) .toBeVisible() .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); diff --git a/e2e/tests/assorted/05-joinpublicroom.spec.ts b/e2e/tests/assorted/05-joinpublicroom.spec.ts index 09b44d032..a9d8c3add 100644 --- a/e2e/tests/assorted/05-joinpublicroom.spec.ts +++ b/e2e/tests/assorted/05-joinpublicroom.spec.ts @@ -1,20 +1,20 @@ import { device, waitFor, element, by, expect } from 'detox'; import data from '../../data'; -import { navigateToLogin, login, tapBack, searchRoom, platformTypes, TTextMatcher, mockRandomMessage } from '../../helpers/app'; +import { + navigateToLogin, + login, + tapBack, + platformTypes, + TTextMatcher, + mockRandomMessage, + navigateToRoom +} from '../../helpers/app'; import { createRandomUser, ITestUser } from '../../helpers/data_setup'; import random from '../../helpers/random'; const room = data.channels.detoxpublic.name; -async function navigateToRoom() { - await searchRoom(room); - await element(by.id(`rooms-list-view-item-${room}`)).tap(); - await waitFor(element(by.id('room-view')).atIndex(0)) - .toExist() - .withTimeout(5000); -} - async function navigateToRoomActions() { await element(by.id(`room-view-title-${room}`)).tap(); await waitFor(element(by.id('room-actions-view'))) @@ -33,7 +33,7 @@ describe('Join public room', () => { ({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]); await navigateToLogin(); await login(user.username, user.password); - await navigateToRoom(); + await navigateToRoom(room); }); describe('Render', () => { @@ -130,16 +130,10 @@ describe('Join public room', () => { .not.toBeVisible() .withTimeout(2000); await tapBack(); - await waitFor(element(by.id(`rooms-list-view-item-${room}`))) - .toBeVisible() - .withTimeout(2000); - await element(by.id(`rooms-list-view-item-${room}`)).tap(); - await waitFor(element(by.id('room-view'))) - .toBeVisible() - .withTimeout(5000); + await navigateToRoom(room); await waitFor(element(by.id('messagebox'))) .toBeVisible() - .withTimeout(60000); + .withTimeout(10000); await expect(element(by.id('messagebox'))).toBeVisible(); await expect(element(by.id('room-view-join'))).toBeNotVisible(); }); diff --git a/e2e/tests/room/01-createroom.spec.ts b/e2e/tests/room/01-createroom.spec.ts index 455fa56b0..d2df8eff1 100644 --- a/e2e/tests/room/01-createroom.spec.ts +++ b/e2e/tests/room/01-createroom.spec.ts @@ -72,8 +72,11 @@ describe('Create room screen', () => { it('should navigate to select users', async () => { await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) - .toExist() + .toBeVisible() .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) + .toBeVisible() + .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); await waitFor(element(by.id('select-users-view'))) .toExist() @@ -174,8 +177,11 @@ describe('Create room screen', () => { .withTimeout(5000); await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) - .toExist() + .toBeVisible() .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) + .toBeVisible() + .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); await waitFor(element(by.id('select-users-view'))) .toExist() @@ -217,11 +223,13 @@ describe('Create room screen', () => { await waitFor(element(by.id('rooms-list-view'))) .toExist() .withTimeout(10000); - // await device.launchApp({ newInstance: true }); await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) - .toExist() + .toBeVisible() .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) + .toBeVisible() + .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); await waitFor(element(by.id('select-users-view'))) .toExist() diff --git a/e2e/tests/room/04-discussion.spec.ts b/e2e/tests/room/04-discussion.spec.ts index 4675d2c5d..53518b62f 100644 --- a/e2e/tests/room/04-discussion.spec.ts +++ b/e2e/tests/room/04-discussion.spec.ts @@ -34,7 +34,10 @@ describe('Discussion', () => { .withTimeout(2000); await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) - .toExist() + .toBeVisible() + .withTimeout(2000); + await waitFor(element(by[textMatcher]('Discussion'))) + .toBeVisible() .withTimeout(2000); await element(by[textMatcher]('Discussion')).atIndex(0).tap(); await waitFor(element(by.id('create-discussion-view'))) diff --git a/e2e/tests/team/03-moveconvert.spec.ts b/e2e/tests/team/03-moveconvert.spec.ts index 7adf12eda..8e4ddfeef 100644 --- a/e2e/tests/team/03-moveconvert.spec.ts +++ b/e2e/tests/team/03-moveconvert.spec.ts @@ -13,8 +13,11 @@ const createChannel = async (room: string) => { .withTimeout(5000); await element(by.id('rooms-list-view-create-channel')).tap(); await waitFor(element(by.id('new-message-view'))) - .toExist() + .toBeVisible() .withTimeout(5000); + await waitFor(element(by.id('new-message-view-create-channel'))) + .toBeVisible() + .withTimeout(2000); await element(by.id('new-message-view-create-channel')).tap(); await waitFor(element(by.id('select-users-view'))) .toExist() @@ -73,7 +76,7 @@ describe('Move/Convert Team', () => { await navigateToRoomActions(toBeConverted); await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await waitFor(element(by.id('room-actions-convert-to-team'))) - .toExist() + .toBeVisible() .withTimeout(2000); await element(by.id('room-actions-convert-to-team')).tap(); await waitFor(element(by[textMatcher]('You are converting this Channel to a Team. All Members will be kept.')))