Fix some flaky tests

This commit is contained in:
Diego Mello 2023-02-28 14:00:10 -03:00
parent 391ec65a42
commit 8a83d22d35
7 changed files with 40 additions and 26 deletions

View File

@ -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()

View File

@ -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();

View File

@ -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();

View File

@ -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();
});

View File

@ -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()

View File

@ -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')))

View File

@ -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.')))