2023-03-07 12:28:51 +00:00
|
|
|
import Detox, { device, waitFor, element, by, expect } from 'detox';
|
|
|
|
|
|
|
|
import { navigateToLogin, login, tapBack, sleep, platformTypes, TTextMatcher, navigateToRoom } from '../../helpers/app';
|
|
|
|
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
|
|
|
|
|
|
|
|
async function navigateToRoomInfo(room: string) {
|
|
|
|
await navigateToRoom(room);
|
2021-04-07 18:31:25 +00:00
|
|
|
await element(by.id('room-header')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-actions-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2018-07-10 13:40:32 +00:00
|
|
|
await element(by.id('room-actions-info')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-05-23 13:39:18 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 14:51:33 +00:00
|
|
|
async function swipe(direction: Detox.Direction) {
|
2023-04-10 14:59:00 +00:00
|
|
|
await element(by.id('room-info-edit-view-list')).swipe(direction);
|
2021-12-02 13:19:15 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 20:27:38 +00:00
|
|
|
async function waitForToast() {
|
2020-09-11 14:31:38 +00:00
|
|
|
await sleep(300);
|
2020-03-03 20:27:38 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 13:39:18 +00:00
|
|
|
describe('Room info screen', () => {
|
2022-09-12 14:51:33 +00:00
|
|
|
let alertButtonType: string;
|
|
|
|
let textMatcher: TTextMatcher;
|
2023-03-07 12:28:51 +00:00
|
|
|
let room: string;
|
|
|
|
let user: ITestUser;
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
|
|
|
({ name: room } = await createRandomRoom(user, 'p'));
|
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();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Channel/Group', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
await navigateToRoomInfo(room);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Render', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room info view', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-view'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have name', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-view-name'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have description', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('Description'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have topic', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('Topic'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have announcement', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by[textMatcher]('Announcement'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have edit button', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-view-edit-button'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Render Edit', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-view-edit-button')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-view-edit-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-edit-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room info edit view', async () => {
|
2018-05-23 13:39:18 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view'))).toExist();
|
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have name input', async () => {
|
2018-05-29 17:09:20 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-name'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have description input', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-description'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have topic input', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-topic'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have announcement input', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-announcement'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have password input', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-password'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have type switch', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await swipe('up');
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-t'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have ready only switch', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-ro'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have submit button', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-submit'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have reset button', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-reset'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have archive button', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-archive'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have delete button', async () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-delete'))).toExist();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
afterAll(async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await swipe('down');
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
|
|
|
describe('Usage', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should reset form', async () => {
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-name')).replaceText('abc');
|
|
|
|
await element(by.id('room-info-edit-view-description')).replaceText('abc');
|
|
|
|
await element(by.id('room-info-edit-view-topic')).replaceText('abc');
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-info-edit-view-topic')).tapReturnKey();
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-announcement')).replaceText('abc');
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-info-edit-view-announcement')).tapReturnKey();
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-password')).replaceText('abc');
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-info-edit-view-password')).tapReturnKey();
|
|
|
|
await swipe('down'); // dismiss keyboard
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-t')).tap();
|
2022-10-21 18:27:55 +00:00
|
|
|
await swipe('up');
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-info-edit-view-ro')).tap();
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-react-when-ro')).tap();
|
|
|
|
await element(by.id('room-info-edit-view-reset')).tap();
|
|
|
|
// after reset
|
2023-03-07 12:28:51 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-name'))).toHaveText(room);
|
2018-05-23 13:39:18 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-description'))).toHaveText('');
|
|
|
|
await expect(element(by.id('room-info-edit-view-topic'))).toHaveText('');
|
|
|
|
await expect(element(by.id('room-info-edit-view-announcement'))).toHaveText('');
|
|
|
|
await expect(element(by.id('room-info-edit-view-password'))).toHaveText('');
|
2021-12-02 13:19:15 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-t'))).toHaveToggleValue(true);
|
2022-10-21 18:27:55 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-ro'))).toHaveToggleValue(false);
|
2023-03-07 12:28:51 +00:00
|
|
|
await expect(element(by.id('room-info-edit-view-react-when-ro'))).not.toBeVisible();
|
2021-12-02 13:19:15 +00:00
|
|
|
await swipe('down');
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
it('should change room name', async () => {
|
|
|
|
await element(by.id('room-info-edit-view-name')).replaceText(`${room}new`);
|
|
|
|
await swipe('down'); // dismiss keyboard
|
|
|
|
await swipe('up');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-submit')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-08-31 18:13:30 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
const matcher = device.getPlatform() === 'android' ? 'toHaveText' : 'toHaveLabel';
|
|
|
|
await waitFor(element(by.id('room-info-view-name')))
|
|
|
|
[matcher](`${room}new`)
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(10000);
|
2020-05-20 16:33:40 +00:00
|
|
|
await element(by.id('room-info-view-edit-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-edit-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
it('should change room description, topic, announcement', async () => {
|
|
|
|
await sleep(5000); // wait for changes to be applied from socket
|
|
|
|
await element(by.id('room-info-edit-view-description')).replaceText('new description');
|
|
|
|
await element(by.id('room-info-edit-view-topic')).replaceText('new topic');
|
2023-04-10 14:59:00 +00:00
|
|
|
await swipe('down'); // dismiss keyboard
|
|
|
|
// announcement is hide by the keyboard
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-announcement')).replaceText('new announcement');
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('room-info-edit-view-announcement')).tapReturnKey();
|
|
|
|
await element(by.id('room-info-edit-view-password')).tapReturnKey();
|
|
|
|
await swipe('down'); // dismiss keyboard
|
|
|
|
await swipe('up');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-submit')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-08-31 18:13:30 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by[textMatcher]('new description').withAncestor(by.id('room-info-view-description'))))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await expect(element(by[textMatcher]('new topic').withAncestor(by.id('room-info-view-topic')))).toExist();
|
|
|
|
await expect(element(by[textMatcher]('new announcement').withAncestor(by.id('room-info-view-announcement')))).toExist();
|
|
|
|
|
2020-05-20 16:33:40 +00:00
|
|
|
await element(by.id('room-info-view-edit-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-info-edit-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
// Commented because we're not actually asserting anything
|
|
|
|
// it('should change room password', async () => {
|
|
|
|
// await waitFor(element(by.id('room-info-view-edit-button')))
|
|
|
|
// .toExist()
|
|
|
|
// .withTimeout(10000);
|
|
|
|
// await element(by.id('room-info-view-edit-button')).tap();
|
|
|
|
// await waitFor(element(by.id('room-info-edit-view')))
|
|
|
|
// .toExist()
|
|
|
|
// .withTimeout(2000);
|
|
|
|
// await sleep(2000);
|
|
|
|
// await element(by.id('room-info-edit-view-password')).replaceText('password');
|
|
|
|
// await element(by.id('room-info-edit-view-list')).swipe('up', 'fast', 0.5);
|
|
|
|
// await element(by.id('room-info-edit-view-submit')).tap();
|
|
|
|
// await waitForToast();
|
|
|
|
// });
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should change room type', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await swipe('down');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-t')).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await swipe('up');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-submit')).tap();
|
2020-03-03 20:27:38 +00:00
|
|
|
await waitForToast();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should archive room', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await swipe('up');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-archive')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Yes, archive it!')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Yes, archive it!').and(by.type(alertButtonType))).tap();
|
2022-07-06 13:23:02 +00:00
|
|
|
await waitForToast();
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should delete room', async () => {
|
2023-04-10 14:59:00 +00:00
|
|
|
await element(by.id('room-info-edit-view-list')).swipe('up');
|
2018-05-23 13:39:18 +00:00
|
|
|
await element(by.id('room-info-edit-view-delete')).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]('Yes, delete it!')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Yes, delete it!').and(by.type(alertButtonType))).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${room}new`)))
|
|
|
|
.not.toBeVisible()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(60000);
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
});
|
2023-08-11 20:35:24 +00:00
|
|
|
|
|
|
|
describe('Navigate to random user', () => {
|
|
|
|
it('should see user role correctly', async () => {
|
|
|
|
await navigateToRoomInfo('roles-test');
|
|
|
|
await waitFor(element(by.id(`user-roles`)))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await waitFor(element(by.id(`user-role-Livechat-Agent`)))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
|
|
|
});
|
|
|
|
});
|
2018-05-23 13:39:18 +00:00
|
|
|
});
|
|
|
|
});
|