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';
|
|
|
|
import { navigateToLogin, login, tapBack, sleep } from '../../helpers/app';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { createRandomTeam, createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
|
|
|
|
import random from '../../helpers/random';
|
2021-03-18 13:32:48 +00:00
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
async function navigateToRoom(search: string) {
|
2021-07-02 17:39:39 +00:00
|
|
|
await element(by.id('directory-view-search')).replaceText(search);
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`directory-view-item-${search}`)))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-18 13:32:48 +00:00
|
|
|
await sleep(300); // app takes some time to animate
|
2021-09-13 20:41:05 +00:00
|
|
|
await element(by.id(`directory-view-item-${search}`)).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view')).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by.id(`room-view-title-${search}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 13:32:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('Join room from directory', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
|
|
|
let otherUser: ITestUser;
|
|
|
|
let team: string;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
|
|
|
otherUser = await createRandomUser();
|
|
|
|
team = await createRandomTeam(user);
|
|
|
|
|
2021-03-18 13:32:48 +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);
|
2021-03-18 13:32:48 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
const thread = `${random()}thread`;
|
|
|
|
beforeAll(async () => {
|
|
|
|
const result = await sendMessage(user, data.channels.detoxpublic.name, thread);
|
2022-12-02 17:06:14 +00:00
|
|
|
const threadId = result.message._id;
|
2023-03-07 12:28:51 +00:00
|
|
|
await sendMessage(user, result.message.rid, 'insidethread', threadId);
|
2022-12-02 17:06:14 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should tap directory', async () => {
|
2021-07-02 17:39:39 +00:00
|
|
|
await element(by.id('rooms-list-view-directory')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('directory-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-03-18 13:32:48 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should search public channel and navigate', async () => {
|
2021-03-18 13:32:48 +00:00
|
|
|
await navigateToRoom(data.channels.detoxpublic.name);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-03-18 13:32:48 +00:00
|
|
|
|
2022-12-02 17:06:14 +00:00
|
|
|
it('should navigate to thread messages view and load messages', async () => {
|
|
|
|
await waitFor(element(by.id('room-view-header-threads')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
await element(by.id('room-view-header-threads')).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`thread-messages-view-${thread}`)))
|
2022-12-02 17:06:14 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
await tapBack();
|
|
|
|
await waitFor(element(by.id('room-view-header-threads')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should search user and navigate', async () => {
|
2021-03-18 13:32:48 +00:00
|
|
|
await tapBack();
|
2021-07-02 17:39:39 +00:00
|
|
|
await element(by.id('rooms-list-view-directory')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('directory-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-07-02 17:39:39 +00:00
|
|
|
await element(by.id('directory-view-dropdown')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.label('Users')).atIndex(0).tap();
|
|
|
|
await element(by.label('Search by')).atIndex(0).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await navigateToRoom(otherUser.username);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-03-18 13:32:48 +00:00
|
|
|
|
2021-12-02 13:19:15 +00:00
|
|
|
it('should search team and navigate', async () => {
|
2021-06-04 18:07:26 +00:00
|
|
|
await tapBack();
|
|
|
|
await element(by.id('rooms-list-view-directory')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('directory-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-07-02 17:39:39 +00:00
|
|
|
await element(by.id('directory-view-dropdown')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.label('Teams')).atIndex(0).tap();
|
|
|
|
await element(by.label('Search by')).atIndex(0).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await navigateToRoom(team);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2021-03-18 13:32:48 +00:00
|
|
|
});
|
|
|
|
});
|