Skip to content

Commit

Permalink
Update rocketchat and add e2e test for deep linking
Browse files Browse the repository at this point in the history
  • Loading branch information
gerzonc authored and diegolmello committed Mar 25, 2021
1 parent 8bc8a07 commit 96d4582
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ const RocketChat = {
if (this?.sdk?.client?.host === server) {
return resolve();
} else {
database.setActiveDB(server);
this.sdk?.disconnect?.();
this.sdk = null;
database.setActiveDB(server);
}
reduxStore.dispatch(connectRequest());

Expand Down
38 changes: 38 additions & 0 deletions e2e/tests/assorted/11-deeplinking.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const {
device, element, by, waitFor
} = require('detox');
const data = require('../../data');
const { navigateToLogin, login, mockMessage, tapBack, searchRoom } = require('../../helpers/app');

const testuser = data.users.regular
const room = data.channels.detoxpublic.name;
const mainRoom = data.groups.private.name;
async function navigateToRoom(roomName) {
await searchRoom(`${ roomName }`);
await waitFor(element(by.id(`rooms-list-view-item-${ roomName }`))).toExist().withTimeout(60000);
await element(by.id(`rooms-list-view-item-${ roomName }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
}

describe('Deep linking authentication', () => {
it('should be logged in server from URL', async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
await device.launchApp({
newInstance: true,
url: 'https://go.rocket.chat/auth',
sourceApp: 'com.apple.mobilesafari',
permissions: { notifications: 'YES' }
});
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
});

it('should be logged in from URL sent to room', async() => {
await device.launchApp({ permissions: { notifications: 'YES' }, newInstance: true, delete: true });
await navigateToLogin();
await login(testuser.username, testuser.password);
await element(by.id('login-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);
await navigateToRoom();
await mockMessage('https://go.rocket.chat/auth');
});
});

0 comments on commit 96d4582

Please sign in to comment.