Rocket.Chat.ReactNative/e2e/tests/assorted/14-in-app-notification.spec.ts

58 lines
1.9 KiB
TypeScript
Raw Normal View History

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