fix in app notification and added navigateToRoom and checkRoomTitle
This commit is contained in:
parent
a0606aa23c
commit
d3763e37db
|
@ -163,6 +163,12 @@ async function searchRoom(room: string) {
|
|||
.withTimeout(60000);
|
||||
}
|
||||
|
||||
async function navigateToRoom(room: string) {
|
||||
await searchRoom(room);
|
||||
await element(by.id(`rooms-list-view-item-${room}`)).tap();
|
||||
await checkRoomTitle(room);
|
||||
}
|
||||
|
||||
async function tryTapping(theElement: Detox.IndexableNativeElement, timeout: number, longtap = false) {
|
||||
try {
|
||||
if (longtap) {
|
||||
|
@ -196,6 +202,12 @@ async function tapAndWaitFor(
|
|||
}
|
||||
}
|
||||
|
||||
async function checkRoomTitle(room: string) {
|
||||
await waitFor(element(by.id(`room-view-title-${room}`)))
|
||||
.toBeVisible()
|
||||
.withTimeout(60000);
|
||||
}
|
||||
|
||||
const checkServer = async (server: string) => {
|
||||
const label = `Connected to ${server}`;
|
||||
await element(by.id('rooms-list-view-sidebar')).tap();
|
||||
|
@ -227,8 +239,10 @@ export {
|
|||
tapBack,
|
||||
sleep,
|
||||
searchRoom,
|
||||
navigateToRoom,
|
||||
tryTapping,
|
||||
tapAndWaitFor,
|
||||
checkRoomTitle,
|
||||
checkServer,
|
||||
platformTypes
|
||||
};
|
||||
|
|
|
@ -22,8 +22,7 @@ const login = async (username: string, password: string) => {
|
|||
user: username,
|
||||
password
|
||||
});
|
||||
const { userId } = response.data.data;
|
||||
const { authToken } = response.data.data;
|
||||
const { authToken, userId } = response.data.data;
|
||||
rocketchat.defaults.headers.common['X-User-Id'] = userId;
|
||||
rocketchat.defaults.headers.common['X-Auth-Token'] = authToken;
|
||||
return { authToken, userId };
|
||||
|
@ -186,7 +185,9 @@ const get = (endpoint: string) => {
|
|||
return rocketchat.get(endpoint);
|
||||
};
|
||||
|
||||
const post = (endpoint: string, body: any) => {
|
||||
const post = async (endpoint: string, body: any) => {
|
||||
const data = new Data(globalThis.random);
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
console.log(`POST /${endpoint} ${JSON.stringify(body)}`);
|
||||
return rocketchat.post(endpoint, body);
|
||||
};
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { expect } from 'detox';
|
||||
|
||||
import data from '../../data';
|
||||
import { navigateToLogin, login, sleep, tapBack } from '../../helpers/app';
|
||||
import { navigateToLogin, login, sleep, tapBack, navigateToRoom, checkRoomTitle } from '../../helpers/app';
|
||||
import { sendMessage, post } from '../../helpers/data_setup';
|
||||
|
||||
const waitForInAppNotificationAnimation = async () => {
|
||||
await sleep(500);
|
||||
};
|
||||
|
||||
describe('InApp Notification', () => {
|
||||
let dmCreatedRid: string;
|
||||
|
||||
|
@ -11,62 +13,42 @@ describe('InApp Notification', () => {
|
|||
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
||||
await navigateToLogin();
|
||||
await login(data.users.regular.username, data.users.regular.password);
|
||||
const result = await post(`im.create`, { username: data.users.alternate.username });
|
||||
const result = await post('im.create', { username: data.users.alternate.username });
|
||||
dmCreatedRid = result.data.room.rid;
|
||||
});
|
||||
|
||||
describe('receive in RoomsListView', () => {
|
||||
const text = 'Message in DM';
|
||||
it('should have rooms list screen', async () => {
|
||||
await expect(element(by.id('rooms-list-view'))).toBeVisible();
|
||||
});
|
||||
|
||||
it('should send direct message from user alternate to user regular', async () => {
|
||||
await sleep(1000);
|
||||
await sendMessage(data.users.alternate, dmCreatedRid, text);
|
||||
});
|
||||
|
||||
it('should tap on InApp Notification', async () => {
|
||||
await sendMessage(data.users.alternate, dmCreatedRid, text);
|
||||
await waitFor(element(by.id(`in-app-notification-${text}`)))
|
||||
.toExist()
|
||||
.withTimeout(2000);
|
||||
await sleep(500);
|
||||
await waitForInAppNotificationAnimation();
|
||||
await element(by.id(`in-app-notification-${text}`)).tap();
|
||||
await waitFor(element(by.id('room-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(5000);
|
||||
await expect(element(by.id(`room-view-title-${data.users.alternate.username}`))).toExist();
|
||||
await checkRoomTitle(data.users.alternate.username);
|
||||
await tapBack();
|
||||
});
|
||||
});
|
||||
|
||||
describe('receive in another room', () => {
|
||||
const text = 'Another msg';
|
||||
it('should back to RoomsListView and open the channel Detox Public', async () => {
|
||||
await tapBack();
|
||||
await sleep(500);
|
||||
await element(by.id(`rooms-list-view-item-${data.userRegularChannels.detoxpublic.name}`)).tap();
|
||||
await waitFor(element(by.id('room-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(5000);
|
||||
await expect(element(by.id(`room-view-title-${data.userRegularChannels.detoxpublic.name}`))).toExist();
|
||||
});
|
||||
|
||||
it('should receive and tap InAppNotification in another room', async () => {
|
||||
it('should receive and tap InAppNotification while in another room', async () => {
|
||||
await navigateToRoom(data.userRegularChannels.detoxpublic.name);
|
||||
await sendMessage(data.users.alternate, dmCreatedRid, text);
|
||||
await waitFor(element(by.id(`in-app-notification-${text}`)))
|
||||
.toExist()
|
||||
.withTimeout(2000);
|
||||
await sleep(500);
|
||||
await waitForInAppNotificationAnimation();
|
||||
await element(by.id(`in-app-notification-${text}`)).tap();
|
||||
await sleep(500);
|
||||
await expect(element(by.id('room-header'))).toExist();
|
||||
await expect(element(by.id(`room-view-title-${data.users.alternate.username}`))).toExist();
|
||||
await checkRoomTitle(data.users.alternate.username);
|
||||
});
|
||||
|
||||
it('should back to RoomsListView', async () => {
|
||||
it('should tap back and go back to RoomsListView', async () => {
|
||||
await tapBack();
|
||||
await sleep(500);
|
||||
await expect(element(by.id('rooms-list-view'))).toBeVisible();
|
||||
await waitFor(element(by.id('rooms-list-view')))
|
||||
.toBeVisible()
|
||||
.withTimeout(2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue