2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
2022-09-12 14:51:33 +00:00
|
|
|
|
|
|
|
import {
|
2021-12-02 13:19:15 +00:00
|
|
|
navigateToLogin,
|
|
|
|
login,
|
|
|
|
tapBack,
|
|
|
|
sleep,
|
|
|
|
platformTypes,
|
2023-03-07 12:28:51 +00:00
|
|
|
TTextMatcher,
|
|
|
|
tapAndWaitFor,
|
|
|
|
navigateToRoom,
|
2023-08-29 16:50:42 +00:00
|
|
|
mockMessage,
|
|
|
|
tryTapping
|
2022-09-12 14:51:33 +00:00
|
|
|
} from '../../helpers/app';
|
2023-03-07 12:28:51 +00:00
|
|
|
import { createRandomRoom, createRandomUser } from '../../helpers/data_setup';
|
2021-04-01 20:08:15 +00:00
|
|
|
|
|
|
|
describe('Threads', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let room: string;
|
2022-09-12 14:51:33 +00:00
|
|
|
let textMatcher: TTextMatcher;
|
2023-08-29 16:50:42 +00:00
|
|
|
let alertButtonType: string;
|
2021-04-01 20:08:15 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
const user = await createRandomUser();
|
|
|
|
({ name: room } = await createRandomRoom(user));
|
2023-08-29 16:50:42 +00:00
|
|
|
({ textMatcher, alertButtonType } = platformTypes[device.getPlatform()]);
|
2023-03-07 12:28:51 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
|
|
|
await navigateToLogin();
|
|
|
|
await login(user.username, user.password);
|
|
|
|
await navigateToRoom(room);
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Render', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have room screen', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${room}`)))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// 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'))).toExist();
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have threads button ', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('room-view-header-threads'))).toExist();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// Render - Messagebox
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Messagebox', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have messagebox', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('messagebox'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have open emoji button', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await expect(element(by.id('messagebox-open-emoji'))).toExist();
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have message input', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('messagebox-input'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have audio button', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('messagebox-send-audio'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should have actions button', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('messagebox-actions'))).toExist();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
|
|
|
describe('Thread', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let thread: string;
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should create thread', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
thread = await mockMessage('thread');
|
|
|
|
await element(by[textMatcher](thread)).atIndex(0).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher](thread)).atIndex(0).longPress();
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('action-sheet'))).toExist();
|
|
|
|
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
|
|
|
|
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
2023-06-26 19:28:11 +00:00
|
|
|
await element(by[textMatcher]('Reply in thread')).atIndex(0).tap();
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('messagebox-input')).replaceText('replied');
|
|
|
|
await waitFor(element(by.id('messagebox-send-message')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await element(by.id('messagebox-send-message')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`message-thread-button-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await expect(element(by.id(`message-thread-button-${thread}`))).toExist();
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to thread from button', async () => {
|
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await expect(element(by.id(`room-view-title-${thread}`))).toExist();
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should toggle follow thread', async () => {
|
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await element(by.id('room-view-header-unfollow')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view-header-follow')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(60000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('room-view-header-follow'))).toExist();
|
|
|
|
await element(by.id('room-view-header-follow')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('room-view-header-unfollow')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(60000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('room-view-header-unfollow'))).toExist();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should send message in thread only', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
const messageText = await mockMessage('threadonly', true);
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.not.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${room}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by[textMatcher](messageText)).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toNotExist()
|
|
|
|
.withTimeout(2000);
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should mark send to channel and show on main channel', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
const messageText = 'sendToChannel';
|
2021-09-13 20:41:05 +00:00
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id('messagebox-input-thread')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('messagebox-input-thread')).replaceText(messageText);
|
2021-04-01 20:08:15 +00:00
|
|
|
await element(by.id('messagebox-send-to-channel')).tap();
|
|
|
|
await element(by.id('messagebox-send-message')).tap();
|
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.not.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${room}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await waitFor(element(by[textMatcher](messageText)).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to thread from thread name', async () => {
|
2021-04-01 20:08:15 +00:00
|
|
|
const messageText = 'navthreadname';
|
2023-03-07 12:28:51 +00:00
|
|
|
await mockMessage('dummymessagebetweenthethread');
|
2021-09-13 20:41:05 +00:00
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id('messagebox-input-thread')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('messagebox-input-thread')).replaceText(messageText);
|
2021-04-01 20:08:15 +00:00
|
|
|
await element(by.id('messagebox-send-to-channel')).tap();
|
|
|
|
await element(by.id('messagebox-send-message')).tap();
|
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.not.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${room}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`message-thread-replied-on-${thread}`)))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
|
|
|
await element(by.id(`message-thread-replied-on-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await expect(element(by.id(`room-view-title-${thread}`))).toExist();
|
2021-07-21 15:50:39 +00:00
|
|
|
await sleep(2000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to thread from threads view', async () => {
|
|
|
|
await waitFor(element(by.id('room-view-header-threads')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(1000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await element(by.id('room-view-header-threads')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('thread-messages-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await element(by.id(`thread-messages-view-${thread}`))
|
|
|
|
.atIndex(0)
|
|
|
|
.tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await expect(element(by.id(`room-view-title-${thread}`))).toExist();
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('thread-messages-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-04-01 20:08:15 +00:00
|
|
|
await expect(element(by.id('thread-messages-view'))).toExist();
|
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should draft thread message', async () => {
|
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await waitFor(element(by.id(`room-view-title-${thread}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('messagebox-input-thread')).replaceText(`${thread}draft`);
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
await tapAndWaitFor(element(by.id(`message-thread-button-${thread}`)), element(by.id(`room-view-title-${thread}`)), 2000);
|
2021-09-13 20:41:05 +00:00
|
|
|
await expect(element(by.id('messagebox-input-thread'))).toHaveText(`${thread}draft`);
|
2021-04-19 14:31:43 +00:00
|
|
|
await element(by.id('messagebox-input-thread')).clearText();
|
2021-04-01 20:08:15 +00:00
|
|
|
await tapBack();
|
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
await tapAndWaitFor(element(by.id(`message-thread-button-${thread}`)), element(by.id(`room-view-title-${thread}`)), 2000);
|
2021-04-19 14:31:43 +00:00
|
|
|
await expect(element(by.id('messagebox-input-thread'))).toHaveText('');
|
2023-08-29 16:50:42 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create thread delete the message and the thread show the correct number of messages', async () => {
|
|
|
|
thread = await mockMessage('thread-message-count');
|
|
|
|
await element(by[textMatcher](thread)).atIndex(0).tap();
|
|
|
|
await element(by[textMatcher](thread)).atIndex(0).longPress();
|
|
|
|
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
|
|
|
await element(by[textMatcher]('Reply in thread')).atIndex(0).tap();
|
|
|
|
await element(by.id('messagebox-input')).replaceText('replied');
|
|
|
|
await element(by.id('messagebox-send-message')).tap();
|
|
|
|
await waitFor(element(by.id(`thread-count-1`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await element(by.id(`message-thread-button-${thread}`)).tap();
|
|
|
|
await tryTapping(element(by[textMatcher]('replied')).atIndex(0), 2000, true);
|
|
|
|
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
|
|
|
await sleep(300); // wait for animation
|
|
|
|
await element(by[textMatcher]('Delete')).atIndex(0).tap();
|
|
|
|
await element(by[textMatcher]('Delete').and(by.type(alertButtonType))).tap();
|
|
|
|
await tapBack();
|
|
|
|
await waitFor(element(by.id(`thread-count-0`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2021-04-01 20:08:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|