Skip to content

Commit

Permalink
Remove unneeded sleeps
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishbowler committed Jul 19, 2020
1 parent 77eb18c commit bc6926f
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 93 deletions.
3 changes: 0 additions & 3 deletions e2e/helpers/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function login(username, password) {
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
await element(by.id('login-view-email')).replaceText(username);
await element(by.id('login-view-password')).replaceText(password);
await sleep(300);
await element(by.id('login-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
}
Expand Down Expand Up @@ -69,7 +68,6 @@ async function starMessage(message){
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Star')).tap();
await sleep(1000);
await waitFor(element(by.id('action-sheet'))).toNotExist().withTimeout(5000);
};

Expand Down Expand Up @@ -102,7 +100,6 @@ async function searchRoom(room) {
await expect(element(by.id('rooms-list-view-search-input'))).toExist();
await waitFor(element(by.id('rooms-list-view-search-input'))).toExist().withTimeout(5000);
await element(by.id('rooms-list-view-search-input')).typeText(room);
await sleep(2000);
}

module.exports = {
Expand Down
4 changes: 0 additions & 4 deletions e2e/tests/assorted/01-changeserver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ describe('Change server', () => {
await sleep(5000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
//await sleep(1000);
await element(by.id('rooms-list-header-server-add')).tap();

// TODO: refactor
Expand All @@ -44,7 +43,6 @@ describe('Change server', () => {
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await sleep(1000);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);

Expand All @@ -56,10 +54,8 @@ describe('Change server', () => {
});

it('should change back', async() => {
await sleep(5000);
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown'))).toBeVisible().withTimeout(5000);
await sleep(1000);
await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await checkServer(data.server);
Expand Down
10 changes: 0 additions & 10 deletions e2e/tests/assorted/02-broadcast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@ describe('Broadcast room', () => {
await waitFor(element(by.id(`select-users-view-item-${ otheruser.username }`))).toBeVisible().withTimeout(60000);
await element(by.id(`select-users-view-item-${ otheruser.username }`)).tap();
await waitFor(element(by.id(`selected-user-${ otheruser.username }`))).toBeVisible().withTimeout(5000);
await sleep(1000);
await element(by.id('selected-users-view-submit')).tap();
await sleep(1000);
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);
await element(by.id('create-channel-name')).replaceText(`broadcast${ data.random }`);
await sleep(2000);
await element(by.id('create-channel-broadcast')).longPress(); //https://github.com/facebook/react-native/issues/28032
await sleep(500);
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(1000);
await element(by.id('room-view-header-actions')).tap();
await sleep(1000);
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
await element(by.id('room-actions-info')).tap();
await waitFor(element(by.id('room-info-view'))).toBeVisible().withTimeout(2000);
Expand All @@ -60,21 +54,18 @@ describe('Broadcast room', () => {
await navigateToLogin();
await element(by.id('login-view-email')).replaceText(otheruser.username);
await element(by.id('login-view-password')).replaceText(otheruser.password);
await sleep(1000);
await element(by.id('login-view-submit')).tap();
//await waitFor(element(by.id('two-factor'))).toBeVisible().withTimeout(5000);
//await expect(element(by.id('two-factor'))).toBeVisible();
//const code = GA.gen(data.alternateUserTOTPSecret);
//await element(by.id('two-factor-input')).replaceText(code);
//await sleep(1000);
//await element(by.id('two-factor-send')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
await searchRoom(`broadcast${ data.random }`);
await waitFor(element(by.id(`rooms-list-view-item-broadcast${ data.random }`))).toExist().withTimeout(60000);
await element(by.id(`rooms-list-view-item-broadcast${ data.random }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
await waitFor(element(by.id(`room-view-title-broadcast${ data.random }`))).toBeVisible().withTimeout(60000);
await sleep(1000);
});

it('should not have messagebox', async() => {
Expand All @@ -95,7 +86,6 @@ describe('Broadcast room', () => {

it('should tap on reply button and navigate to direct room', async() => {
await element(by.id('message-broadcast-reply')).tap();
await sleep(1000);
await waitFor(element(by.id(`room-view-title-${ testuser.username }`))).toBeVisible().withTimeout(5000);
});

Expand Down
5 changes: 1 addition & 4 deletions e2e/tests/assorted/03-profile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function waitForToast() {
// await expect(element(by.id('toast'))).toBeVisible();
// await waitFor(element(by.id('toast'))).toBeNotVisible().withTimeout(10000);
// await expect(element(by.id('toast'))).toBeNotVisible();
await sleep(5000);
await sleep(1);
}

describe('Profile screen', () => {
Expand Down Expand Up @@ -79,9 +79,7 @@ describe('Profile screen', () => {
await element(by.type('UIScrollView')).atIndex(1).swipe('down');
await element(by.id('profile-view-name')).replaceText(`${ profileChangeUser.username }new`);
await element(by.id('profile-view-username')).replaceText(`${ profileChangeUser.username }new`);
await sleep(1000);
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
await sleep(1000);
await element(by.id('profile-view-submit')).tap();
await waitForToast();
});
Expand All @@ -98,7 +96,6 @@ describe('Profile screen', () => {

it('should reset avatar', async() => {
await element(by.type('UIScrollView')).atIndex(1).swipe('up');
await sleep(1000);
await element(by.id('profile-view-reset-avatar')).tap();
await waitForToast();
});
Expand Down
4 changes: 0 additions & 4 deletions e2e/tests/assorted/05-joinpublicroom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ const testuser = data.users.regular
const room = data.channels.detoxpublic.name;

async function navigateToRoom() {
await sleep(2000);
await searchRoom(room);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0)).toBeVisible().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ room }`)).atIndex(0).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
}

async function navigateToRoomActions() {
await sleep(2000);
await element(by.id('room-view-header-actions')).tap();
await sleep(2000);
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
}

Expand Down Expand Up @@ -170,7 +167,6 @@ describe('Join public room', () => {
await element(by.text('Yes, leave it!')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
// await element(by.id('rooms-list-view-search')).typeText('');
await sleep(2000);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeNotVisible().withTimeout(60000);
});
});
Expand Down
5 changes: 1 addition & 4 deletions e2e/tests/assorted/06-status.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const data = require('../../data');
const testuser = data.users.regular

async function waitForToast() {
await sleep(5000);
await sleep(1);
}

describe('Status screen', () => {
Expand Down Expand Up @@ -36,15 +36,12 @@ describe('Status screen', () => {

describe('Usage', async () => {
it('should change status', async () => {
await sleep(1000);
await element(by.id('status-view-busy')).tap();
await sleep(1000);
await expect(element(by.id('status-view-current-busy'))).toExist();
});

it('should change status text', async () => {
await element(by.id('status-view-input')).replaceText('status-text-new');
await sleep(1000);
await element(by.id('status-view-submit')).tap();
await waitForToast();
await waitFor(element(by.label('status-text-new').withAncestor(by.id('sidebar-custom-status')))).toBeVisible().withTimeout(2000);
Expand Down
3 changes: 0 additions & 3 deletions e2e/tests/onboarding/04-createuser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('Create user screen', () => {
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.users.existing.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await sleep(300);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.text('Email already exists. [403]')).atIndex(0)).toExist().withTimeout(10000);
await element(by.text('OK')).tap();
Expand All @@ -64,7 +63,6 @@ describe('Create user screen', () => {
await element(by.id('register-view-username')).replaceText(data.users.existing.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await sleep(300);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.text('Username is already in use')).atIndex(0)).toExist().withTimeout(10000);
await element(by.text('OK')).tap();
Expand All @@ -75,7 +73,6 @@ describe('Create user screen', () => {
await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
await sleep(300);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
});
Expand Down
2 changes: 0 additions & 2 deletions e2e/tests/onboarding/05-login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ describe('Login screen', () => {
it('should insert wrong password and get error', async() => {
await element(by.id('login-view-email')).replaceText(data.users.regular.username);
await element(by.id('login-view-password')).replaceText('NotMyActualPassword');
await sleep(300);
await element(by.id('login-view-submit')).tap();
await waitFor(element(by.text('Your credentials were rejected! Please try again.'))).toBeVisible().withTimeout(10000);
await element(by.text('OK')).tap();
});

it('should login with success', async() => {
await element(by.id('login-view-password')).replaceText(data.users.regular.password);
await sleep(300);
await element(by.id('login-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
});
Expand Down
1 change: 0 additions & 1 deletion e2e/tests/onboarding/06-roomslist.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('Rooms list screen', () => {
await waitFor(element(by.id('room-view-title-rocket.cat'))).toBeVisible().withTimeout(60000);
await tapBack();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
await sleep(2000);
await waitFor(element(by.id('rooms-list-view-item-rocket.cat'))).toExist().withTimeout(60000);
});

Expand Down
11 changes: 0 additions & 11 deletions e2e/tests/room/01-createroom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('Create room screen', () => {

describe('Usage', async() => {
it('should back to rooms list', async() => {
await sleep(1000);
await element(by.id('new-message-view-close')).tap();
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
await element(by.id('rooms-list-view-create-channel')).tap();
Expand All @@ -46,7 +45,6 @@ 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().withTimeout(2000);
await sleep(1000);
await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(2000);
});
Expand Down Expand Up @@ -101,7 +99,6 @@ describe('Create room screen', () => {
const room = `public${ data.random }`;
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-type')).tap();
await sleep(1000);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await expect(element(by.id('room-view'))).toExist();
Expand All @@ -116,19 +113,15 @@ describe('Create room screen', () => {
it('should create private room', async() => {
const room = `private${ data.random }`;
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
await sleep(1000);
await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(2000);
await sleep(1000);
await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(2000);
await sleep(1000);
await element(by.id('select-users-view-item-rocket.cat')).tap();
await waitFor(element(by.id('selected-user-rocket.cat'))).toExist().withTimeout(5000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);
await element(by.id('create-channel-name')).replaceText(room);
await sleep(1000);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await expect(element(by.id('room-view'))).toExist();
Expand All @@ -144,17 +137,13 @@ describe('Create room screen', () => {
const room = `empty${ data.random }`;
await waitFor(element(by.id('rooms-list-view'))).toExist().withTimeout(2000);
// await device.launchApp({ newInstance: true });
await sleep(1000);
await element(by.id('rooms-list-view-create-channel')).tap();
await waitFor(element(by.id('new-message-view'))).toExist().withTimeout(2000);
await sleep(1000);
await element(by.id('new-message-view-create-channel')).tap();
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(2000);
await sleep(1000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);
await element(by.id('create-channel-name')).replaceText(room);
await sleep(1000);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await expect(element(by.id('room-view'))).toExist();
Expand Down
Loading

0 comments on commit bc6926f

Please sign in to comment.