2023-03-07 12:28:51 +00:00
|
|
|
import { device, waitFor, element, by } from 'detox';
|
2022-11-25 13:21:56 +00:00
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
import { navigateToLogin, login, sleep, tapBack, navigateToRoom, checkRoomTitle } from '../../helpers/app';
|
|
|
|
import { sendMessage, post, ITestUser, createRandomUser, createRandomRoom } from '../../helpers/data_setup';
|
|
|
|
|
|
|
|
const waitForInAppNotificationAnimation = async () => {
|
|
|
|
await sleep(500);
|
|
|
|
};
|
2022-11-25 13:21:56 +00:00
|
|
|
|
|
|
|
describe('InApp Notification', () => {
|
|
|
|
let dmCreatedRid: string;
|
2023-03-07 12:28:51 +00:00
|
|
|
let sender: ITestUser;
|
|
|
|
let receiver: ITestUser;
|
|
|
|
let room: string;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
sender = await createRandomUser();
|
|
|
|
receiver = await createRandomUser();
|
|
|
|
({ name: room } = await createRandomRoom(sender));
|
2022-11-25 13:21:56 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
|
|
|
await navigateToLogin();
|
2023-03-07 12:28:51 +00:00
|
|
|
await login(receiver.username, receiver.password);
|
|
|
|
const result = await post('im.create', { username: sender.username }, receiver);
|
2022-11-25 13:21:56 +00:00
|
|
|
dmCreatedRid = result.data.room.rid;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receive in RoomsListView', () => {
|
|
|
|
const text = 'Message in DM';
|
|
|
|
it('should tap on InApp Notification', async () => {
|
2023-03-07 12:28:51 +00:00
|
|
|
await sendMessage(sender, dmCreatedRid, text);
|
2022-11-25 13:21:56 +00:00
|
|
|
await waitFor(element(by.id(`in-app-notification-${text}`)))
|
2023-03-07 12:28:51 +00:00
|
|
|
.toBeVisible()
|
2022-11-25 13:21:56 +00:00
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitForInAppNotificationAnimation();
|
2022-11-25 13:21:56 +00:00
|
|
|
await element(by.id(`in-app-notification-${text}`)).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await checkRoomTitle(sender.username);
|
|
|
|
await tapBack();
|
2022-11-25 13:21:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('receive in another room', () => {
|
|
|
|
const text = 'Another msg';
|
2023-03-07 12:28:51 +00:00
|
|
|
it('should receive and tap InAppNotification while in another room', async () => {
|
|
|
|
await navigateToRoom(room);
|
|
|
|
await sendMessage(sender, dmCreatedRid, text);
|
2022-11-25 13:21:56 +00:00
|
|
|
await waitFor(element(by.id(`in-app-notification-${text}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(2000);
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitForInAppNotificationAnimation();
|
2022-11-25 13:21:56 +00:00
|
|
|
await element(by.id(`in-app-notification-${text}`)).tap();
|
2023-03-07 12:28:51 +00:00
|
|
|
await checkRoomTitle(sender.username);
|
2022-11-25 13:21:56 +00:00
|
|
|
});
|
|
|
|
|
2023-03-07 12:28:51 +00:00
|
|
|
it('should tap back and go back to RoomsListView', async () => {
|
2022-11-25 13:21:56 +00:00
|
|
|
await tapBack();
|
2023-03-07 12:28:51 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2022-11-25 13:21:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|