2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
2022-09-12 14:51:33 +00:00
|
|
|
|
|
|
|
import data from '../../data';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { navigateToLogin, login, searchRoom, mockMessage } from '../../helpers/app';
|
|
|
|
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
|
|
|
import random from '../../helpers/random';
|
2020-12-01 17:30:39 +00:00
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
const room = data.channels.detoxpublicprotected.name;
|
|
|
|
const { joinCode } = data.channels.detoxpublicprotected;
|
2020-12-01 17:30:39 +00:00
|
|
|
|
|
|
|
async function navigateToRoom() {
|
|
|
|
await searchRoom(room);
|
2021-09-13 20:41:05 +00:00
|
|
|
await element(by.id(`rooms-list-view-item-${room}`)).tap();
|
|
|
|
await waitFor(element(by.id('room-view')))
|
2021-12-02 13:19:15 +00:00
|
|
|
.toExist()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(5000);
|
2020-12-01 17:30:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function openJoinCode() {
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view-join-button')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
|
|
|
let n = 0;
|
2023-03-07 12:28:51 +00:00
|
|
|
// FIXME: this while is always matching 3 loops
|
2021-12-02 13:19:15 +00:00
|
|
|
while (n < 3) {
|
|
|
|
try {
|
|
|
|
await element(by.id('room-view-join-button')).tap();
|
|
|
|
await waitFor(element(by.id('join-code')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(500);
|
|
|
|
} catch (error) {
|
|
|
|
n += 1;
|
|
|
|
}
|
|
|
|
}
|
2020-12-01 17:30:39 +00:00
|
|
|
}
|
|
|
|
|
2021-04-19 14:31:43 +00:00
|
|
|
describe('Join protected room', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
2020-12-01 17:30:39 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
2020-12-01 17:30:39 +00:00
|
|
|
await navigateToRoom();
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should tap join and ask for join code', async () => {
|
2020-12-01 17:30:39 +00:00
|
|
|
await openJoinCode();
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2020-12-01 17:30:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should cancel join room', async () => {
|
2020-12-01 17:30:39 +00:00
|
|
|
await element(by.id('join-code-cancel')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('join-code')))
|
|
|
|
.toBeNotVisible()
|
|
|
|
.withTimeout(5000);
|
2020-12-01 17:30:39 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should join room', async () => {
|
2020-12-01 17:30:39 +00:00
|
|
|
await openJoinCode();
|
|
|
|
await element(by.id('join-code-input')).replaceText(joinCode);
|
|
|
|
await element(by.id('join-code-submit')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('join-code')))
|
|
|
|
.toBeNotVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by.id('messagebox')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(60000);
|
2020-12-01 17:30:39 +00:00
|
|
|
await expect(element(by.id('messagebox'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-view-join'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should send message', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await mockMessage(`${random()}message`);
|
2020-12-01 17:30:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|