2018-05-23 13:39:18 +00:00
|
|
|
const {
|
|
|
|
device, expect, element, by, waitFor
|
|
|
|
} = require('detox');
|
2020-05-20 16:33:40 +00:00
|
|
|
const data = require('../../data');
|
|
|
|
const { sleep, createUser } = require('../../helpers/app');
|
|
|
|
|
|
|
|
const checkServer = async(server) => {
|
|
|
|
const label = `Connected to ${ server }`;
|
|
|
|
await element(by.id('rooms-list-view-sidebar')).tap();
|
|
|
|
await waitFor(element(by.id('sidebar-view'))).toBeVisible().withTimeout(2000);
|
|
|
|
await waitFor(element(by.label(label))).toBeVisible().withTimeout(60000);
|
|
|
|
await expect(element(by.label(label))).toBeVisible();
|
2020-06-15 14:00:46 +00:00
|
|
|
await element(by.id('sidebar-close-drawer')).tap();
|
2020-05-20 16:33:40 +00:00
|
|
|
}
|
2019-09-16 20:26:32 +00:00
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
describe('Change server', () => {
|
|
|
|
before(async() => {
|
2020-05-20 16:33:40 +00:00
|
|
|
await createUser();
|
2018-08-10 17:26:36 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
|
2020-05-20 16:33:40 +00:00
|
|
|
it('should be logged in main server', async() => {
|
|
|
|
await checkServer(data.server);
|
|
|
|
})
|
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
it('should add server and create new user', async() => {
|
2020-03-03 20:27:38 +00:00
|
|
|
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 expect(element(by.id('rooms-list-header-server-dropdown'))).toExist();
|
|
|
|
await sleep(1000);
|
2018-08-31 16:46:33 +00:00
|
|
|
await element(by.id('rooms-list-header-server-add')).tap();
|
2020-05-20 16:33:40 +00:00
|
|
|
|
|
|
|
// TODO: refactor
|
2018-08-10 17:26:36 +00:00
|
|
|
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('new-server-view-input')).replaceText(data.alternateServer);
|
|
|
|
await element(by.id('new-server-view-button')).tap();
|
2020-05-20 16:33:40 +00:00
|
|
|
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
|
|
|
|
await expect(element(by.id('workspace-view'))).toBeVisible();
|
|
|
|
await element(by.id('workspace-view-register')).tap();
|
2018-05-23 13:39:18 +00:00
|
|
|
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
|
2018-11-14 21:42:03 +00:00
|
|
|
await expect(element(by.id('register-view'))).toBeVisible();
|
2018-05-23 13:39:18 +00:00
|
|
|
// Register new user
|
|
|
|
await element(by.id('register-view-name')).replaceText(data.user);
|
2018-11-14 21:42:03 +00:00
|
|
|
await element(by.id('register-view-username')).replaceText(data.user);
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('register-view-email')).replaceText(data.email);
|
|
|
|
await element(by.id('register-view-password')).replaceText(data.password);
|
2020-03-03 20:27:38 +00:00
|
|
|
await sleep(1000);
|
2018-05-23 13:39:18 +00:00
|
|
|
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();
|
2020-05-20 16:33:40 +00:00
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
// For a sanity test, to make sure roomslist is showing correct rooms
|
|
|
|
// app CANNOT show public room created on previous tests
|
2020-05-20 16:33:40 +00:00
|
|
|
// await waitFor(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeNotVisible().withTimeout(60000);
|
|
|
|
// await expect(element(by.id(`rooms-list-view-item-public${ data.random }`))).toBeNotVisible();
|
|
|
|
await checkServer(data.alternateServer);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
|
2020-05-20 16:33:40 +00:00
|
|
|
it('should change back', async() => {
|
2020-03-03 20:27:38 +00:00
|
|
|
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 expect(element(by.id('rooms-list-header-server-dropdown'))).toExist();
|
|
|
|
await sleep(1000);
|
2018-08-31 16:46:33 +00:00
|
|
|
await element(by.id(`rooms-list-header-server-${ data.server }`)).tap();
|
2018-05-23 13:39:18 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);
|
2020-05-20 16:33:40 +00:00
|
|
|
await checkServer(data.server);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
});
|