2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by, expect } from 'detox';
|
2021-03-18 16:52:47 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
import { navigateToLogin, login, sleep, platformTypes, TTextMatcher, navigateToRoom } from '../../helpers/app';
|
|
|
|
import { createRandomUser, ITestUser, sendMessage } from '../../helpers/data_setup';
|
2021-03-18 16:52:47 +00:00
|
|
|
|
|
|
|
describe('Mark as unread', () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
let user: ITestUser;
|
|
|
|
let otherUser: ITestUser;
|
2022-09-12 14:51:33 +00:00
|
|
|
let textMatcher: TTextMatcher;
|
2021-03-18 16:52:47 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
user = await createRandomUser();
|
|
|
|
otherUser = await createRandomUser();
|
2021-03-18 16:52:47 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
2021-12-02 13:19:15 +00:00
|
|
|
({ textMatcher } = platformTypes[device.getPlatform()]);
|
2021-03-18 16:52:47 +00:00
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(user.username, user.password);
|
|
|
|
await navigateToRoom(otherUser.username);
|
2021-03-18 16:52:47 +00:00
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Usage', () => {
|
|
|
|
describe('Mark message as unread', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should mark message as unread', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
const message = 'message-mark-as-unread';
|
|
|
|
await sendMessage(otherUser, `@${user.username}`, message);
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher](message)).atIndex(0))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(30000);
|
2021-06-11 18:23:43 +00:00
|
|
|
await sleep(300);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher](message)).atIndex(0).longPress();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('action-sheet-handle')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(3000);
|
2021-03-18 16:52:47 +00:00
|
|
|
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by[textMatcher]('Mark Unread')).atIndex(0).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(5000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await expect(element(by.id(`rooms-list-view-item-${otherUser.username}`))).toExist();
|
2021-03-18 16:52:47 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|