2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
|
|
|
|
|
|
|
import {
|
|
|
|
TTextMatcher,
|
|
|
|
navigateToLogin,
|
|
|
|
login,
|
|
|
|
tapBack,
|
|
|
|
navigateToRoom,
|
|
|
|
platformTypes,
|
|
|
|
mockMessage,
|
|
|
|
sleep,
|
|
|
|
checkRoomTitle
|
|
|
|
} from '../../helpers/app';
|
|
|
|
import { createRandomRoom, createRandomUser, ITestUser } from '../../helpers/data_setup';
|
|
|
|
import random from '../../helpers/random';
|
2021-03-18 14:36:50 +00:00
|
|
|
|
|
|
|
describe('Discussion', () => {
|
2022-09-12 14:51:33 +00:00
|
|
|
let textMatcher: TTextMatcher;
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
|
|
|
let room: string;
|
|
|
|
const discussionFromNewMessage = `${random()} Discussion NewMessageView`;
|
2024-01-25 14:11:07 +00:00
|
|
|
const discussionFromMessageComposer = `${random()} Discussion MessageComposer actions`;
|
2023-03-07 12:28:51 +00:00
|
|
|
let discussionFromActionSheet: string;
|
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
|
|
|
({ name: room } = await createRandomRoom(user));
|
2021-03-18 14:36:50 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ textMatcher } = platformTypes[device.getPlatform()]);
|
2021-03-18 14:36:50 +00:00
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should create discussion from NewMessageView', async () => {
|
2023-08-03 19:37:14 +00:00
|
|
|
const selectUser = 'rocket.cat';
|
2022-08-08 21:02:08 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view-create-channel')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await element(by.id('rooms-list-view-create-channel')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('new-message-view')))
|
2023-03-07 12:28:51 +00:00
|
|
|
.toBeVisible()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id('new-message-view-create-discussion')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2022-08-26 19:16:45 +00:00
|
|
|
await element(by[textMatcher]('Discussion')).atIndex(0).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('create-discussion-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(60000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('create-discussion-view'))).toExist();
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Select a channel...')).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id('multi-select-search')).replaceText(`${room}`);
|
|
|
|
await waitFor(element(by.id(`multi-select-item-${room}`)))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.id(`multi-select-item-${room}`)).tap();
|
|
|
|
await element(by.id('multi-select-discussion-name')).replaceText(discussionFromNewMessage);
|
2023-08-03 19:37:14 +00:00
|
|
|
await element(by[textMatcher]('Select users...')).tap();
|
|
|
|
await element(by.id('multi-select-search')).replaceText(`${selectUser}`);
|
|
|
|
await waitFor(element(by.id(`multi-select-item-${selectUser}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await element(by.id(`multi-select-item-${selectUser}`)).tap();
|
|
|
|
await sleep(300);
|
|
|
|
// checking if the chip was placed properly
|
|
|
|
await waitFor(element(by.id(`multi-select-chip-${selectUser}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
// should keep the same chip even when the user does a new research
|
|
|
|
await element(by.id('multi-select-search')).replaceText(`user`);
|
|
|
|
await waitFor(element(by.id(`multi-select-item-${selectUser}`)))
|
|
|
|
.not.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await waitFor(element(by.id(`multi-select-chip-${selectUser}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
await sleep(500);
|
|
|
|
await element(by.id('multi-select-search')).tapReturnKey();
|
|
|
|
await sleep(500);
|
|
|
|
// removing the rocket.cat from the users
|
|
|
|
await element(by.id(`multi-select-chip-${selectUser}`)).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('create-discussion-submit')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await element(by.id('create-discussion-submit')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${discussionFromNewMessage}`)))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${discussionFromNewMessage}`)))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
|
2024-01-25 14:11:07 +00:00
|
|
|
it('should create discussion from MessageComposer Actions', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await navigateToRoom(room);
|
2024-01-25 14:11:07 +00:00
|
|
|
await element(by.id('message-composer-actions')).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await sleep(300); // wait for animation
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('action-sheet')))
|
2023-03-07 12:28:51 +00:00
|
|
|
.toBeVisible()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(2000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Create discussion')).atIndex(0).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('create-discussion-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2024-01-25 14:11:07 +00:00
|
|
|
await element(by.id('multi-select-discussion-name')).replaceText(discussionFromMessageComposer);
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('create-discussion-submit')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await element(by.id('create-discussion-submit')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2024-01-25 14:11:07 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${discussionFromMessageComposer}`)))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Create Discussion from action sheet', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should send a message', async () => {
|
2024-01-25 14:11:07 +00:00
|
|
|
await waitFor(element(by.id('message-composer')))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(60000);
|
2023-03-07 12:28:51 +00:00
|
|
|
discussionFromActionSheet = await mockMessage('message');
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should create discussion', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by[textMatcher](discussionFromActionSheet)).atIndex(0).tap();
|
|
|
|
await element(by[textMatcher](discussionFromActionSheet)).atIndex(0).longPress();
|
|
|
|
await sleep(1000); // wait for animation
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('action-sheet')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Start a discussion')).atIndex(0).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await sleep(1000); // wait for animation
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('create-discussion-view')))
|
2023-03-07 12:28:51 +00:00
|
|
|
.toBeVisible()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(2000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await element(by.id('create-discussion-submit')).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await sleep(1000); // wait for animation
|
|
|
|
await checkRoomTitle(discussionFromActionSheet);
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
});
|
2021-07-02 17:39:39 +00:00
|
|
|
|
|
|
|
describe('Check RoomActionsView render', () => {
|
2021-11-08 18:26:05 +00:00
|
|
|
it('should navigate to RoomActionsView', async () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-header')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
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')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room actions screen', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-view'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have info', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-info'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have members', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-members'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have files', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-files'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have mentions', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-mentioned'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have starred', async () => {
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('room-actions-scrollview')).swipe('up', 'slow', 0.5);
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-starred'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have share', async () => {
|
2021-07-21 15:50:39 +00:00
|
|
|
await element(by.id('room-actions-scrollview')).swipe('up');
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-share'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have pinned', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-pinned'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should not have notifications', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-notifications'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should not have leave channel', async () => {
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-leave-channel'))).toBeVisible();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to RoomActionView', async () => {
|
2021-07-21 15:50:39 +00:00
|
|
|
await element(by.id('room-actions-scrollview')).swipe('down');
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-actions-info'))).toBeVisible();
|
|
|
|
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(60000);
|
2021-03-18 14:36:50 +00:00
|
|
|
await expect(element(by.id('room-info-view'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have edit button', async () => {
|
2021-05-27 20:44:35 +00:00
|
|
|
await expect(element(by.id('room-info-view-edit-button'))).toBeVisible();
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|
|
|
|
});
|
2021-07-21 21:17:48 +00:00
|
|
|
|
2021-09-16 18:16:02 +00:00
|
|
|
describe('Open Discussion from DiscussionsView', () => {
|
|
|
|
it('should go back to main room', async () => {
|
2021-07-21 21:17:48 +00:00
|
|
|
await tapBack();
|
2021-09-16 18:16:02 +00:00
|
|
|
await waitFor(element(by.id('room-actions-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-07-21 21:17:48 +00:00
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${discussionFromActionSheet}`)))
|
2021-09-16 18:16:02 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-07-21 21:17:48 +00:00
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await navigateToRoom(room);
|
2021-07-21 21:17:48 +00:00
|
|
|
});
|
|
|
|
|
2021-09-16 18:16:02 +00:00
|
|
|
it('should navigate to DiscussionsView', async () => {
|
|
|
|
await waitFor(element(by.id('room-header')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-07-21 21:17:48 +00:00
|
|
|
await element(by.id('room-header')).tap();
|
2021-09-16 18:16:02 +00:00
|
|
|
await waitFor(element(by.id('room-actions-discussions')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-07-21 21:17:48 +00:00
|
|
|
await element(by.id('room-actions-discussions')).tap();
|
2021-09-17 19:26:48 +00:00
|
|
|
await waitFor(element(by.id('discussions-view')))
|
2021-09-16 18:16:02 +00:00
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
2021-07-21 21:17:48 +00:00
|
|
|
});
|
2021-11-08 18:26:05 +00:00
|
|
|
|
|
|
|
it('should navigate to discussion', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.label(discussionFromNewMessage)).atIndex(0))
|
2021-11-08 18:26:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await element(by.label(discussionFromNewMessage)).atIndex(0).tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${discussionFromNewMessage}`)))
|
2021-11-08 18:26:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
});
|
2021-07-21 21:17:48 +00:00
|
|
|
});
|
2021-03-18 14:36:50 +00:00
|
|
|
});
|