2018-05-23 13:39:18 +00:00
|
|
|
const {
|
|
|
|
device, expect, element, by, waitFor
|
|
|
|
} = require('detox');
|
|
|
|
const data = require('../data');
|
|
|
|
|
|
|
|
async function addServer() {
|
2018-08-10 17:26:36 +00:00
|
|
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await element(by.id('connect-server-button')).tap();
|
|
|
|
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
|
|
|
|
await expect(element(by.id('new-server-view'))).toBeVisible();
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('new-server-view-input')).replaceText(data.server);
|
|
|
|
await element(by.id('new-server-view-button')).tap();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function navigateToLogin() {
|
2018-08-10 17:26:36 +00:00
|
|
|
await addServer();
|
2018-11-14 21:42:03 +00:00
|
|
|
try {
|
|
|
|
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('login-view'))).toBeVisible();
|
|
|
|
} catch (error) {
|
|
|
|
await waitFor(element(by.id('welcome-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('welcome-view'))).toBeVisible();
|
|
|
|
await element(by.id('welcome-view-login')).tap();
|
|
|
|
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('login-view'))).toBeVisible();
|
|
|
|
}
|
2018-05-23 13:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function login() {
|
|
|
|
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await element(by.id('login-view-email')).replaceText(data.user);
|
|
|
|
await element(by.id('login-view-password')).replaceText(data.password);
|
|
|
|
await element(by.id('login-view-submit')).tap();
|
|
|
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function logout() {
|
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
2019-01-31 16:08:38 +00:00
|
|
|
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
2018-06-05 01:17:02 +00:00
|
|
|
await waitFor(element(by.id('sidebar-logout'))).toBeVisible().withTimeout(2000);
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('sidebar-logout')).tap();
|
2018-08-10 17:26:36 +00:00
|
|
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('onboarding-view'))).toBeVisible();
|
2018-05-23 13:39:18 +00:00
|
|
|
}
|
|
|
|
|
2018-10-23 21:39:48 +00:00
|
|
|
async function tapBack() {
|
2019-03-12 16:23:06 +00:00
|
|
|
await element(by.id('header-back')).atIndex(0).tap();
|
2018-07-10 13:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function sleep(ms) {
|
|
|
|
return new Promise(res => setTimeout(res, ms));
|
|
|
|
}
|
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
module.exports = {
|
|
|
|
addServer,
|
|
|
|
navigateToLogin,
|
|
|
|
login,
|
2018-07-10 13:40:32 +00:00
|
|
|
logout,
|
|
|
|
tapBack,
|
|
|
|
sleep
|
2018-05-23 13:39:18 +00:00
|
|
|
};
|