2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by } from 'detox';
|
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
import data from '../../data';
|
2023-03-07 12:28:51 +00:00
|
|
|
import {
|
|
|
|
sleep,
|
|
|
|
navigateToLogin,
|
|
|
|
login,
|
|
|
|
checkServer,
|
|
|
|
platformTypes,
|
|
|
|
TTextMatcher,
|
|
|
|
expectValidRegisterOrRetry
|
|
|
|
} from '../../helpers/app';
|
2023-06-27 12:57:52 +00:00
|
|
|
import { createRandomUser, deleteCreatedUsers, IDeleteCreateUser, ITestUser } from '../../helpers/data_setup';
|
2021-03-18 17:02:58 +00:00
|
|
|
|
|
|
|
describe('Delete server', () => {
|
2022-09-12 14:51:33 +00:00
|
|
|
let alertButtonType: string;
|
|
|
|
let textMatcher: TTextMatcher;
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
2023-06-27 12:57:52 +00:00
|
|
|
const deleteUsersAfterAll: IDeleteCreateUser[] = [];
|
2023-03-07 12:28:51 +00:00
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
2021-03-18 17:02:58 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
2021-03-18 17:02:58 +00:00
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
2021-03-18 17:02:58 +00:00
|
|
|
});
|
|
|
|
|
2023-06-27 12:57:52 +00:00
|
|
|
afterAll(async () => {
|
|
|
|
await deleteCreatedUsers(deleteUsersAfterAll);
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should be logged in main server', async () => {
|
2021-03-18 17:02:58 +00:00
|
|
|
await checkServer(data.server);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-03-18 17:02:58 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should add server', async () => {
|
2021-03-18 17:02:58 +00:00
|
|
|
await sleep(5000);
|
|
|
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 17:02:58 +00:00
|
|
|
await element(by.id('rooms-list-header-server-add')).tap();
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('new-server-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('new-server-view-input')).replaceText(`${data.alternateServer}`);
|
|
|
|
await element(by.id('new-server-view-input')).tapReturnKey();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('workspace-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-18 17:02:58 +00:00
|
|
|
await element(by.id('workspace-view-register')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('register-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-03-18 17:02:58 +00:00
|
|
|
|
|
|
|
// Register new user
|
2023-03-07 12:28: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);
|
|
|
|
await element(by.id('register-view-password')).tapReturnKey();
|
|
|
|
await expectValidRegisterOrRetry(device.getPlatform());
|
2023-06-27 12:57:52 +00:00
|
|
|
deleteUsersAfterAll.push({ server: data.alternateServer, username: randomUser.username });
|
2021-03-18 17:02:58 +00:00
|
|
|
|
|
|
|
await checkServer(data.alternateServer);
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should delete server', async () => {
|
2021-03-18 17:02:58 +00:00
|
|
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await element(by.id(`rooms-list-header-server-${data.server}`)).longPress(1500);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Delete').and(by.type(alertButtonType))).tap();
|
2021-03-18 17:02:58 +00:00
|
|
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by.id(`rooms-list-header-server-${data.server}`)))
|
|
|
|
.toBeNotVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-18 17:02:58 +00:00
|
|
|
});
|
|
|
|
});
|