2018-05-23 13:39:18 +00:00
|
|
|
const {
|
|
|
|
device, expect, element, by, waitFor
|
|
|
|
} = require('detox');
|
|
|
|
const data = require('../data');
|
|
|
|
|
2020-05-20 16:33:40 +00:00
|
|
|
async function navigateToWorkspace() {
|
2020-06-15 14:00:46 +00:00
|
|
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
2020-05-20 16:33:40 +00:00
|
|
|
await element(by.id('join-workspace')).tap();
|
|
|
|
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
|
|
|
|
await element(by.id('new-server-view-input')).replaceText(data.server);
|
|
|
|
await element(by.id('new-server-view-button')).tap();
|
|
|
|
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
|
|
|
|
await expect(element(by.id('workspace-view'))).toBeVisible();
|
2018-05-23 13:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function navigateToLogin() {
|
2020-05-20 16:33:40 +00:00
|
|
|
await navigateToWorkspace();
|
|
|
|
await element(by.id('workspace-view-login')).tap();
|
|
|
|
await waitFor(element(by.id('login-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('login-view'))).toBeVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function navigateToRegister() {
|
|
|
|
await navigateToWorkspace();
|
|
|
|
await element(by.id('workspace-view-register')).tap();
|
|
|
|
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await expect(element(by.id('register-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);
|
2020-03-03 20:27:38 +00:00
|
|
|
await sleep(300);
|
2018-05-23 13:39:18 +00:00
|
|
|
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);
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitFor(element(by.id('sidebar-settings'))).toBeVisible().withTimeout(2000);
|
|
|
|
await element(by.id('sidebar-settings')).tap();
|
|
|
|
await waitFor(element(by.id('settings-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await element(by.type('UIScrollView')).atIndex(1).scrollTo('bottom');
|
|
|
|
await element(by.id('settings-logout')).tap();
|
|
|
|
const logoutAlertMessage = 'You will be logged out of this application.';
|
|
|
|
await waitFor(element(by.text(logoutAlertMessage)).atIndex(0)).toExist().withTimeout(10000);
|
|
|
|
await expect(element(by.text(logoutAlertMessage)).atIndex(0)).toExist();
|
|
|
|
await element(by.text('Logout')).tap();
|
|
|
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
2018-08-10 17:26:36 +00:00
|
|
|
await expect(element(by.id('onboarding-view'))).toBeVisible();
|
2018-05-23 13:39:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-20 16:33:40 +00:00
|
|
|
async function createUser() {
|
|
|
|
await navigateToRegister();
|
|
|
|
await element(by.id('register-view-name')).replaceText(data.user);
|
|
|
|
await element(by.id('register-view-username')).replaceText(data.user);
|
|
|
|
await element(by.id('register-view-email')).replaceText(data.email);
|
|
|
|
await element(by.id('register-view-password')).replaceText(data.password);
|
|
|
|
await sleep(300);
|
|
|
|
await element(by.id('register-view-submit')).tap();
|
|
|
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
|
|
|
|
await expect(element(by.id('rooms-list-view'))).toBeVisible();
|
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2020-07-06 20:56:28 +00:00
|
|
|
async function searchRoom(room) {
|
|
|
|
await element(by.id('rooms-list-view-search')).tap();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
module.exports = {
|
2020-05-20 16:33:40 +00:00
|
|
|
navigateToWorkspace,
|
2018-05-23 13:39:18 +00:00
|
|
|
navigateToLogin,
|
2020-05-20 16:33:40 +00:00
|
|
|
navigateToRegister,
|
2018-05-23 13:39:18 +00:00
|
|
|
login,
|
2018-07-10 13:40:32 +00:00
|
|
|
logout,
|
2020-05-20 16:33:40 +00:00
|
|
|
createUser,
|
2018-07-10 13:40:32 +00:00
|
|
|
tapBack,
|
2020-07-06 20:56:28 +00:00
|
|
|
sleep,
|
|
|
|
searchRoom
|
2018-05-23 13:39:18 +00:00
|
|
|
};
|