2022-09-12 14:51:33 +00:00
|
|
|
import { expect } from 'detox';
|
|
|
|
|
|
|
|
import data from '../../data';
|
|
|
|
import { navigateToLogin, login, mockMessage, tapBack, searchRoom, platformTypes, TTextMatcher } from '../../helpers/app';
|
2018-12-21 10:55:35 +00:00
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
const testuser = data.users.regular;
|
2020-07-22 16:32:21 +00:00
|
|
|
const room = data.channels.detoxpublic.name;
|
2018-12-21 10:55:35 +00:00
|
|
|
|
|
|
|
async function navigateToRoom() {
|
2020-07-06 20:56:28 +00:00
|
|
|
await searchRoom(room);
|
2021-09-13 20:41:05 +00:00
|
|
|
await element(by.id(`rooms-list-view-item-${room}`)).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-view')).atIndex(0))
|
|
|
|
.toExist()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(5000);
|
2018-12-21 10:55:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function navigateToRoomActions() {
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id(`room-view-title-${room}`)).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-actions-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2018-12-21 10:55:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
describe('Join public room', () => {
|
2022-09-12 14:51:33 +00:00
|
|
|
let alertButtonType: string;
|
|
|
|
let textMatcher: TTextMatcher;
|
2021-09-13 20:41:05 +00:00
|
|
|
before(async () => {
|
2020-07-22 16:32:21 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ alertButtonType, textMatcher } = platformTypes[device.getPlatform()]);
|
2020-07-22 16:32:21 +00:00
|
|
|
await navigateToLogin();
|
|
|
|
await login(testuser.username, testuser.password);
|
2018-12-21 10:55:35 +00:00
|
|
|
await navigateToRoom();
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Render', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room screen', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-view'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
|
|
|
// Render - Header
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Header', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have actions button ', async () => {
|
2021-04-07 18:31:25 +00:00
|
|
|
await expect(element(by.id('room-header'))).toBeVisible();
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Render - Join
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Join', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have join', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-view-join'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have join text', async () => {
|
2020-03-03 20:27:38 +00:00
|
|
|
await expect(element(by.label('You are in preview mode'))).toBeVisible();
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have join button', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-view-join-button'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should not have messagebox', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('messagebox'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Room Actions', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
before(async () => {
|
2021-04-19 14:31:43 +00:00
|
|
|
await navigateToRoomActions();
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room actions screen', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-view'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have info', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-info'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have members', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by.id('room-actions-members')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have files', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-files'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have mentions', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have starred', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have share', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have pinned', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should not have notifications', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-notifications'))).toBeNotVisible();
|
|
|
|
});
|
2019-05-28 13:03:08 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should not have leave channel', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-leave-channel'))).toBeNotVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
after(async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-07-02 17:39:39 +00:00
|
|
|
});
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should join room', async () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await element(by.id('room-view-join-button')).tap();
|
2019-05-28 13:03:08 +00:00
|
|
|
await tapBack();
|
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')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by.id('messagebox')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(60000);
|
2018-12-21 10:55:35 +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 () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
await mockMessage('message');
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have notifications and leave channel', async () => {
|
2021-04-19 14:31:43 +00:00
|
|
|
await navigateToRoomActions();
|
2018-12-21 10:55:35 +00:00
|
|
|
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();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('room-actions-scrollview')).scrollTo('bottom');
|
2018-12-21 10:55:35 +00:00
|
|
|
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should leave room', async () => {
|
2020-03-03 20:27:38 +00:00
|
|
|
await element(by.id('room-actions-leave-channel')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Yes, leave it!').and(by.type(alertButtonType))))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Yes, leave it!').and(by.type(alertButtonType))).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${room}`)))
|
|
|
|
.toBeNotVisible()
|
2021-12-02 13:19:15 +00:00
|
|
|
.withTimeout(60000); // flaky on Android
|
2018-12-21 10:55:35 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|