Rocket.Chat.ReactNative/e2e/tests/assorted/07-changeserver.spec.ts

103 lines
3.8 KiB
TypeScript
Raw Normal View History

2023-01-25 19:03:02 +00:00
import data from '../../data';
2023-02-22 13:36:51 +00:00
import { navigateToLogin, login, checkServer, expectValidRegisterOrRetry } from '../../helpers/app';
2023-02-22 17:46:16 +00:00
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
2023-01-25 19:03:02 +00:00
const reopenAndCheckServer = async (server: string) => {
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', () => {
2023-02-22 17:46:16 +00:00
let user: ITestUser;
2023-02-22 16:58:21 +00:00
let room: string;
2023-02-22 13:36:51 +00:00
2023-01-25 19:03:02 +00:00
beforeAll(async () => {
2023-02-22 13:36:51 +00:00
user = await createRandomUser();
2023-02-22 17:46:16 +00:00
({ name: room } = await createRandomRoom(user));
2023-01-25 19:03:02 +00:00
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
2023-02-22 13:36:51 +00:00
await login(user.username, user.password);
2023-01-25 19:03:02 +00:00
});
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')))
.toBeVisible()
.withTimeout(5000);
await waitFor(element(by.id('rooms-list-header-server-add')))
.toBeVisible()
.withTimeout(5000);
await waitFor(element(by.id('rooms-list-header-create-workspace-button')))
.toBeVisible()
.withTimeout(5000);
});
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')))
.toBeVisible()
.withTimeout(6000);
2023-02-22 13:36:51 +00:00
await element(by.id('new-server-view-input')).replaceText(data.alternateServer);
2023-01-25 19:03:02 +00:00
await element(by.id('new-server-view-input')).tapReturnKey();
await waitFor(element(by.id('workspace-view')))
.toBeVisible()
.withTimeout(10000);
await reopenAndCheckServer(data.server);
});
it('should add server and create new user', async () => {
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 element(by.id(`rooms-list-header-server-${data.alternateServer}`)).tap();
await waitFor(element(by.id('workspace-view')))
.toBeVisible()
.withTimeout(60000);
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view')))
.toExist()
.withTimeout(2000);
// Register new user
2023-02-22 13:36:51 +00:00
const randomUser = data.randomUser();
await element(by.id('register-view-name')).replaceText(randomUser.name);
await element(by.id('register-view-username')).replaceText(randomUser.username);
await element(by.id('register-view-email')).replaceText(randomUser.email);
await element(by.id('register-view-password')).replaceText(randomUser.password);
2023-02-21 20:38:23 +00:00
await element(by.id('register-view-password')).tapReturnKey();
await expectValidRegisterOrRetry(device.getPlatform());
2023-01-25 19:03:02 +00:00
2023-02-22 16:58:21 +00:00
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
2023-01-25 19:03:02 +00:00
.toBeNotVisible()
.withTimeout(60000);
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-dropdown-button')).tap();
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
.toBeVisible()
.withTimeout(5000);
await element(by.id(`rooms-list-header-server-${data.server}`)).tap();
await waitFor(element(by.id('rooms-list-view')))
.toBeVisible()
.withTimeout(10000);
2023-02-22 16:58:21 +00:00
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
2023-01-25 19:03:02 +00:00
.toBeVisible()
.withTimeout(60000);
await checkServer(data.server);
});
it('should reopen the app and show main server', async () => {
await reopenAndCheckServer(data.server);
});
});