Rocket.Chat.ReactNative/e2e/tests/assorted/08-joinprotectedroom.spec.ts

78 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-01-25 19:03:02 +00:00
import { expect } from 'detox';
import data from '../../data';
2023-02-22 14:03:29 +00:00
import { navigateToLogin, login, searchRoom, mockRandomMessage } from '../../helpers/app';
2023-02-22 17:46:16 +00:00
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
2023-01-25 19:03:02 +00:00
const room = data.channels.detoxpublicprotected.name;
const { joinCode } = data.channels.detoxpublicprotected;
async function navigateToRoom() {
await searchRoom(room);
await element(by.id(`rooms-list-view-item-${room}`)).tap();
await waitFor(element(by.id('room-view')))
.toExist()
.withTimeout(5000);
}
async function openJoinCode() {
await waitFor(element(by.id('room-view-join-button')))
.toExist()
.withTimeout(2000);
let n = 0;
2023-01-26 13:22:52 +00:00
// FIXME: this while is always matching 3 loops
2023-01-25 19:03:02 +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;
}
}
}
describe('Join protected room', () => {
2023-02-22 17:46:16 +00:00
let user: ITestUser;
2023-02-22 14:03:29 +00:00
2023-01-25 19:03:02 +00:00
beforeAll(async () => {
2023-02-22 14:03:29 +00:00
user = await createRandomUser();
2023-01-25 19:03:02 +00:00
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
await navigateToLogin();
2023-02-22 14:03:29 +00:00
await login(user.username, user.password);
2023-01-25 19:03:02 +00:00
await navigateToRoom();
});
describe('Usage', () => {
it('should tap join and ask for join code', async () => {
await openJoinCode();
});
it('should cancel join room', async () => {
await element(by.id('join-code-cancel')).tap();
await waitFor(element(by.id('join-code')))
.toBeNotVisible()
.withTimeout(5000);
});
it('should join room', async () => {
await openJoinCode();
await element(by.id('join-code-input')).replaceText(joinCode);
await element(by.id('join-code-submit')).tap();
await waitFor(element(by.id('join-code')))
.toBeNotVisible()
.withTimeout(5000);
await waitFor(element(by.id('messagebox')))
.toBeVisible()
.withTimeout(60000);
await expect(element(by.id('messagebox'))).toBeVisible();
await expect(element(by.id('room-view-join'))).toBeNotVisible();
});
it('should send message', async () => {
2023-02-22 14:03:29 +00:00
await mockRandomMessage('message');
2023-01-25 19:03:02 +00:00
});
});
});