2023-01-25 19:03:02 +00:00
|
|
|
import { expect } from 'detox';
|
|
|
|
|
|
|
|
import data from '../../data';
|
2023-02-22 13:36:51 +00:00
|
|
|
import { navigateToLogin, login, tapBack, searchRoom, platformTypes, TTextMatcher, mockRandomMessage } from '../../helpers/app';
|
2023-02-22 17:46:16 +00:00
|
|
|
import { createRandomUser, ITestUser } from '../../helpers/data_setup';
|
2023-02-24 19:01:26 +00:00
|
|
|
import random from '../../helpers/random';
|
2023-01-25 19:03:02 +00:00
|
|
|
|
|
|
|
const room = data.channels.detoxpublic.name;
|
|
|
|
|
|
|
|
async function navigateToRoom() {
|
|
|
|
await searchRoom(room);
|
|
|
|
await element(by.id(`rooms-list-view-item-${room}`)).tap();
|
|
|
|
await waitFor(element(by.id('room-view')).atIndex(0))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function navigateToRoomActions() {
|
|
|
|
await element(by.id(`room-view-title-${room}`)).tap();
|
|
|
|
await waitFor(element(by.id('room-actions-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Join public room', () => {
|
|
|
|
let alertButtonType: string;
|
|
|
|
let textMatcher: TTextMatcher;
|
2023-02-22 17:46:16 +00:00
|
|
|
let user: ITestUser;
|
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-01-25 19:03:02 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
|
|
|
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
|
|
|
await navigateToLogin();
|
2023-02-22 13:36:51 +00:00
|
|
|
await login(user.username, user.password);
|
2023-01-25 19:03:02 +00:00
|
|
|
await navigateToRoom();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Render', () => {
|
|
|
|
it('should have room screen', async () => {
|
|
|
|
await expect(element(by.id('room-view'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Render - Header
|
|
|
|
describe('Header', () => {
|
|
|
|
it('should have actions button ', async () => {
|
|
|
|
await expect(element(by.id('room-header'))).toBeVisible();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Render - Join
|
|
|
|
describe('Join', () => {
|
|
|
|
it('should have join', async () => {
|
|
|
|
await expect(element(by.id('room-view-join'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have join text', async () => {
|
|
|
|
await expect(element(by.label('You are in preview mode'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have join button', async () => {
|
|
|
|
await expect(element(by.id('room-view-join-button'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not have messagebox', async () => {
|
|
|
|
await expect(element(by.id('messagebox'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Room Actions', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
await navigateToRoomActions();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have room actions screen', async () => {
|
|
|
|
await expect(element(by.id('room-actions-view'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have info', async () => {
|
|
|
|
await expect(element(by.id('room-actions-info'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have members', async () => {
|
|
|
|
await waitFor(element(by.id('room-actions-members')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have files', async () => {
|
|
|
|
await expect(element(by.id('room-actions-files'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have mentions', async () => {
|
|
|
|
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have starred', async () => {
|
|
|
|
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have share', async () => {
|
|
|
|
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should have pinned', async () => {
|
|
|
|
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not have notifications', async () => {
|
|
|
|
await expect(element(by.id('room-actions-notifications'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should not have leave channel', async () => {
|
|
|
|
await expect(element(by.id('room-actions-leave-channel'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await tapBack();
|
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Usage', () => {
|
|
|
|
it('should join room', async () => {
|
|
|
|
await element(by.id('room-view-join-button')).tap();
|
2023-02-21 20:38:23 +00:00
|
|
|
await waitFor(element(by.id('room-view-join-button')))
|
|
|
|
.not.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2023-01-25 19:03:02 +00:00
|
|
|
await tapBack();
|
2023-02-16 13:57:42 +00:00
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2023-01-25 19:03:02 +00:00
|
|
|
await element(by.id(`rooms-list-view-item-${room}`)).tap();
|
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.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-24 19:01:26 +00:00
|
|
|
await mockRandomMessage(`${random()}message`);
|
2023-01-25 19:03:02 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have notifications and leave channel', async () => {
|
|
|
|
await navigateToRoomActions();
|
|
|
|
await expect(element(by.id('room-actions-view'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-info'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-members'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-files'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
|
|
|
await expect(element(by.id('room-actions-notifications'))).toBeVisible();
|
|
|
|
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
|
|
|
|
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should leave room', async () => {
|
|
|
|
await element(by.id('room-actions-leave-channel')).tap();
|
|
|
|
await waitFor(element(by[textMatcher]('Yes, leave it!').and(by.type(alertButtonType))))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await element(by[textMatcher]('Yes, leave it!').and(by.type(alertButtonType))).tap();
|
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
|
|
|
.toBeNotVisible()
|
2023-02-23 13:55:13 +00:00
|
|
|
.withTimeout(60000);
|
2023-01-25 19:03:02 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|