2021-03-31 21:01:20 +00:00
|
|
|
const data = require('../../data');
|
2021-12-02 13:19:15 +00:00
|
|
|
const { tapBack, checkServer, navigateToRegister, platformTypes } = require('../../helpers/app');
|
2021-10-26 16:11:50 +00:00
|
|
|
const { get, login, sendMessage } = require('../../helpers/data_setup');
|
2021-03-31 21:01:20 +00:00
|
|
|
|
|
|
|
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
|
2021-12-02 13:19:15 +00:00
|
|
|
|
|
|
|
let amp = '&';
|
|
|
|
|
2021-03-31 21:01:20 +00:00
|
|
|
const getDeepLink = (method, server, params) => {
|
2021-12-02 13:19:15 +00:00
|
|
|
const deeplink = `rocketchat://${method}?host=${server.replace(/^(http:\/\/|https:\/\/)/, '')}${amp}${params}`;
|
2021-09-13 20:41:05 +00:00
|
|
|
console.log(`Deeplinking to: ${deeplink}`);
|
2021-03-31 21:01:20 +00:00
|
|
|
return deeplink;
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Deep linking', () => {
|
|
|
|
let userId;
|
2021-04-19 14:31:43 +00:00
|
|
|
let authToken;
|
2021-12-02 13:19:15 +00:00
|
|
|
let scrollViewType;
|
2021-10-26 16:11:50 +00:00
|
|
|
let threadId;
|
2021-12-02 13:19:15 +00:00
|
|
|
let textMatcher;
|
|
|
|
let alertButtonType;
|
2021-10-26 16:11:50 +00:00
|
|
|
const threadMessage = `to-thread-${data.random}`;
|
2021-09-13 20:41:05 +00:00
|
|
|
before(async () => {
|
2021-04-19 14:31:43 +00:00
|
|
|
const loginResult = await login(data.users.regular.username, data.users.regular.password);
|
|
|
|
({ userId, authToken } = loginResult);
|
2021-12-02 13:19:15 +00:00
|
|
|
const deviceType = device.getPlatform();
|
|
|
|
amp = deviceType === 'android' ? '\\&' : '&';
|
|
|
|
({ scrollViewType, textMatcher, alertButtonType } = platformTypes[deviceType]);
|
2021-10-26 16:11:50 +00:00
|
|
|
// create a thread with api
|
|
|
|
const result = await sendMessage(data.users.regular, data.groups.alternate2.name, threadMessage);
|
|
|
|
threadId = result.message._id;
|
|
|
|
await sendMessage(data.users.regular, result.message.rid, data.random, threadId);
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Authentication', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should run a deep link to an invalid account and raise error', async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
2021-04-19 14:31:43 +00:00
|
|
|
delete: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.AUTH, data.server, `userId=123${amp}token=abc`)
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-12-02 13:19:15 +00:00
|
|
|
await waitFor(element(by[textMatcher]("You've been logged out by the server. Please log in again.")))
|
2021-09-13 20:41:05 +00:00
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000); // TODO: we need to improve this message
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const authAndNavigate = async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-09-13 20:41:05 +00:00
|
|
|
url: getDeepLink(
|
|
|
|
DEEPLINK_METHODS.AUTH,
|
|
|
|
data.server,
|
2021-12-02 13:19:15 +00:00
|
|
|
`userId=${userId}${amp}token=${authToken}${amp}path=group/${data.groups.private.name}`
|
|
|
|
)
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(30000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await tapBack();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await checkServer(data.server);
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`rooms-list-view-item-${data.groups.private.name}`)))
|
2021-12-02 13:19:15 +00:00
|
|
|
.toExist()
|
2021-09-13 20:41:05 +00:00
|
|
|
.withTimeout(2000);
|
2021-07-02 17:39:39 +00:00
|
|
|
};
|
2021-03-31 21:01:20 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should authenticate and navigate', async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await authAndNavigate();
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should authenticate while logged in another server', async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({ permissions: { notifications: 'YES' }, delete: true });
|
|
|
|
await navigateToRegister(data.alternateServer);
|
2021-04-19 14:31:43 +00:00
|
|
|
await element(by.id('register-view-name')).replaceText(data.registeringUser4.username);
|
|
|
|
await element(by.id('register-view-username')).replaceText(data.registeringUser4.username);
|
|
|
|
await element(by.id('register-view-email')).replaceText(data.registeringUser4.email);
|
2021-12-02 13:19:15 +00:00
|
|
|
await element(by.id('register-view-password')).replaceText(data.registeringUser4.password);
|
|
|
|
await element(by.type(scrollViewType)).atIndex(0).scrollTo('bottom');
|
2021-03-31 21:01:20 +00:00
|
|
|
await element(by.id('register-view-submit')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await authAndNavigate();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Room', () => {
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('While logged in', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to the room using path', async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.private.name}`)
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
|
|
|
|
2021-10-26 16:11:50 +00:00
|
|
|
it('should navigate to the thread using path', async () => {
|
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.alternate2.name}/thread/${threadId}`)
|
2021-10-26 16:11:50 +00:00
|
|
|
});
|
|
|
|
await waitFor(element(by.id(`room-view-title-${threadMessage}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should navigate to the room using rid', async () => {
|
|
|
|
const roomResult = await get(`groups.info?roomName=${data.groups.private.name}`);
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `rid=${roomResult.data.group._id}`)
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(15000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await tapBack();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-02 17:39:39 +00:00
|
|
|
describe('Others', () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should change server', async () => {
|
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(2000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await element(by.id('rooms-list-header-server-dropdown-button')).tap();
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-header-server-dropdown')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(5000);
|
|
|
|
await element(by.id(`rooms-list-header-server-${data.alternateServer}`)).tap();
|
2021-03-31 21:01:20 +00:00
|
|
|
await checkServer(data.alternateServer);
|
|
|
|
|
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.ROOM, data.server, `path=group/${data.groups.private.name}`)
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`)))
|
|
|
|
.toExist()
|
|
|
|
.withTimeout(10000);
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
it('should add a not existing server and fallback to the previous one', async () => {
|
2021-03-31 21:01:20 +00:00
|
|
|
await device.launchApp({
|
|
|
|
permissions: { notifications: 'YES' },
|
|
|
|
newInstance: true,
|
2021-12-02 13:19:15 +00:00
|
|
|
url: getDeepLink(DEEPLINK_METHODS.ROOM, 'https://google.com')
|
2021-03-31 21:01:20 +00:00
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
await waitFor(element(by.id('rooms-list-view')))
|
|
|
|
.toBeVisible()
|
|
|
|
.withTimeout(10000);
|
2021-03-31 21:01:20 +00:00
|
|
|
await checkServer(data.server);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|