const data = require('../../data');
const { navigateToLogin, login, checkServer, platformTypes, sleep } = require('../../helpers/app');
const reopenAndCheckServer = async server => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true });
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(10000);
await checkServer(server);
};
describe('Change server', () => {
before(async () => {
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
await login(data.users.regular.username, data.users.regular.password);
});
it('should open the dropdown button, have the server add button and create workspace button', async () => {
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
.withTimeout(5000);
await waitFor(element(by.id('rooms-list-header-server-add')))
await waitFor(element(by.id('rooms-list-header-create-workspace-button')))
it('should login to server, add new server, close the app, open the app and show previous logged server', async () => {
await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view')))
.withTimeout(6000);
await element(by.id('new-server-view-input')).replaceText(`${data.alternateServer}`);
await element(by.id('new-server-view-input')).tapReturnKey();
await waitFor(element(by.id('workspace-view')))
await reopenAndCheckServer(data.server);
it('should add server and create new user', async () => {
await element(by.id(`rooms-list-header-server-${data.alternateServer}`)).tap();
.withTimeout(60000);
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view')))
.toExist()
.withTimeout(2000);
// Register new user
await sleep(5000);
await element(by.id('register-view-name')).replaceText(data.registeringUser2.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser2.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser2.email);
await element(by.id('register-view-password')).replaceText(data.registeringUser2.password);
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id(`rooms-list-view-item-${data.groups.private.name}`)))
.toBeNotVisible()
await checkServer(data.alternateServer);
it('should reopen the app and show alternate server', async () => {
await reopenAndCheckServer(data.alternateServer);
it('should change back to main server', async () => {
await element(by.id(`rooms-list-header-server-${data.server}`)).tap();
await checkServer(data.server);
it('should reopen the app and show main server', async () => {