Fix several tests

This commit is contained in:
Diego Mello 2023-02-20 17:34:51 -03:00
parent e6a3300b6e
commit f2c3ffa6bc
10 changed files with 54 additions and 33 deletions

View File

@ -655,7 +655,6 @@ class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfo
label={I18n.t('Password')}
value={joinCode}
onChangeText={value => this.setState({ joinCode: value })}
onSubmitEditing={this.submit}
secureTextEntry
testID='room-info-edit-view-password'
/>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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