Ready for review

This commit is contained in:
Anant Bhasin 2021-07-27 03:24:31 +05:30
parent 76bf7ac571
commit 52342540f4
9 changed files with 60 additions and 24 deletions

View File

@ -34,7 +34,7 @@ buildscript {
if (isPlay) { if (isPlay) {
classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'
classpath 'com.bugsnag:bugsnag-android-gradle-plugin:5.+' classpath 'com.bugsnag:bugsnag-android-gradle-plugin:5.7.7' // 5.7.8+ breaks the build by requiring the @bugsnag/react-native package instead of bugsnag-react-native that is being used currently.
} }
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

View File

@ -4,6 +4,8 @@ const {
const platformTypes = require('../../helpers/platformTypes'); const platformTypes = require('../../helpers/platformTypes');
const { closeKeyboardAndroid } = require('../../helpers/platformFunctions');
const data = require('../../data'); const data = require('../../data');
const testuser = data.users.regular; const testuser = data.users.regular;
@ -199,6 +201,7 @@ describe('E2E Encryption', () => {
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000); await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
await expect(element(by.text('You\'re going to be logged out.'))).toExist(); await expect(element(by.text('You\'re going to be logged out.'))).toExist();
await element(by.text('Yes, reset it').and(by.type(alertButtonType))).tap(); await element(by.text('Yes, reset it').and(by.type(alertButtonType))).tap();
await waitFor(element(by.text('OK'))).toBeVisible().withTimeout(5000);
await element(by.text('OK').and(by.type(alertButtonType))).tap(); await element(by.text('OK').and(by.type(alertButtonType))).tap();
await sleep(2000); await sleep(2000);
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
@ -234,6 +237,7 @@ describe('E2E Encryption', () => {
await element(by.id('register-view-username')).replaceText(data.registeringUser.username); await element(by.id('register-view-username')).replaceText(data.registeringUser.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser.email); await element(by.id('register-view-email')).replaceText(data.registeringUser.email);
await element(by.id('register-view-password')).typeText(data.registeringUser.password); await element(by.id('register-view-password')).typeText(data.registeringUser.password);
await closeKeyboardAndroid();
element(by.type(scrollViewType)).atIndex(1).scrollTo('bottom'); element(by.type(scrollViewType)).atIndex(1).scrollTo('bottom');
await element(by.id('register-view-submit')).tap(); await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000); await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);

View File

@ -11,7 +11,7 @@ const room = data.channels.detoxpublic.name;
async function navigateToRoom() { async function navigateToRoom() {
await searchRoom(room); await searchRoom(room);
await element(by.id(`rooms-list-view-item-${ room }`)).tap(); await element(by.id(`rooms-list-view-item-${ room }`)).tap();
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('room-view')).atIndex(0)).toBeVisible().withTimeout(5000);
} }
async function navigateToRoomActions() { async function navigateToRoomActions() {

View File

@ -10,7 +10,7 @@ async function navigateToRoom(search) {
await waitFor(element(by.id(`directory-view-item-${ search }`))).toBeVisible().withTimeout(10000); await waitFor(element(by.id(`directory-view-item-${ search }`))).toBeVisible().withTimeout(10000);
await sleep(300); // app takes some time to animate await sleep(300); // app takes some time to animate
await element(by.id(`directory-view-item-${ search }`)).tap(); await element(by.id(`directory-view-item-${ search }`)).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view')).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${ search }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ search }`))).toExist().withTimeout(5000);
} }

View File

@ -80,7 +80,7 @@ describe('Threads', () => {
it('should navigate to thread from button', async() => { it('should navigate to thread from button', async() => {
await element(by.id(`message-thread-button-${ thread }`)).tap(); await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view')).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000);
await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); await expect(element(by.id(`room-view-title-${ thread }`))).toExist();
await tapBack(); await tapBack();
@ -88,7 +88,7 @@ describe('Threads', () => {
it('should toggle follow thread', async() => { it('should toggle follow thread', async() => {
await element(by.id(`message-thread-button-${ thread }`)).tap(); await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view')).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000);
await expect(element(by.id(`room-view-title-${ thread }`))).toExist(); await expect(element(by.id(`room-view-title-${ thread }`))).toExist();
await element(by.id('room-view-header-unfollow')).tap(); await element(by.id('room-view-header-unfollow')).tap();

View File

@ -43,6 +43,9 @@ describe('Room', () => {
}); });
it('should jump to an old message and load its surroundings', async() => { it('should jump to an old message and load its surroundings', async() => {
if (device.getPlatform() === 'android') {
return; // 'Room' tests don't work well on Android currently
}
await navigateToRoom('jumping'); await navigateToRoom('jumping');
await waitFor(element(by.text('Quote first message'))).toExist().withTimeout(5000); await waitFor(element(by.text('Quote first message'))).toExist().withTimeout(5000);
await element(by.text('1')).atIndex(0).tap(); await element(by.text('1')).atIndex(0).tap();
@ -52,6 +55,9 @@ describe('Room', () => {
}); });
it('should tap FAB and scroll to bottom', async() => { it('should tap FAB and scroll to bottom', async() => {
if (device.getPlatform() === 'android') {
return;
}
await waitFor(element(by.id('nav-jump-to-bottom'))).toExist().withTimeout(5000); await waitFor(element(by.id('nav-jump-to-bottom'))).toExist().withTimeout(5000);
await element(by.id('nav-jump-to-bottom')).tap(); await element(by.id('nav-jump-to-bottom')).tap();
await waitFor(element(by.text('Quote first message'))).toExist().withTimeout(5000); await waitFor(element(by.text('Quote first message'))).toExist().withTimeout(5000);
@ -59,12 +65,15 @@ describe('Room', () => {
}); });
it('should load messages on scroll', async() => { it('should load messages on scroll', async() => {
if (device.getPlatform() === 'android') {
return;
}
await navigateToRoom('jumping'); await navigateToRoom('jumping');
await waitFor(element(by.id('room-view-messages'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view-messages'))).toExist().withTimeout(5000);
await waitFor(element(by.text('300'))).toExist().withTimeout(5000); await waitFor(element(by.text('300'))).toExist().withTimeout(5000);
let found = false; let found = false;
while (!found) { while (!found) {
await element(by.id('room-view-messages')).atIndex(0).scroll(500, 'up'); await element(by.id('room-view-messages')).atIndex(0).scroll(500, 'down');
try { try {
await expect(element(by.text('249'))).toExist(); await expect(element(by.text('249'))).toExist();
found = true; found = true;
@ -76,20 +85,26 @@ describe('Room', () => {
}); });
it('should search for old message and load its surroundings', async() => { it('should search for old message and load its surroundings', async() => {
if (device.getPlatform() === 'android') {
return;
}
await navigateToRoom('jumping'); await navigateToRoom('jumping');
await element(by.id('room-view-search')).tap(); await element(by.id('room-view-search')).tap();
await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);
await element(by.id('search-message-view-input')).typeText('30\n'); await element(by.id('search-message-view-input')).typeText('30\n');
await sleep(1000); await waitFor(element(by.text('30')).atIndex(1)).toExist().withTimeout(5000);
await waitFor(element(by.text('30')).atIndex(0)).toExist().withTimeout(5000); await element(by.text('30')).atIndex(1).tap();
await element(by.text('30')).atIndex(0).tap();
await waitForLoading(); await waitForLoading();
await expect(element(by.text('30'))).toExist(); await expect(element(by.text('30'))).toExist();
await expect(element(by.text('31'))).toExist(); await expect(element(by.text('31'))).toExist();
await expect(element(by.text('32'))).toExist(); await expect(element(by.text('32'))).toExist();
await waitFor(element(by.text('32'))).toBeVisible().withTimeout(5000);
}); });
it('should load newer and older messages', async() => { it('should load newer and older messages', async() => {
if (device.getPlatform() === 'android') {
return;
}
await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8); await element(by.id('room-view-messages')).atIndex(0).swipe('down', 'fast', 0.8);
await waitFor(element(by.text('5'))).toExist().withTimeout(10000); await waitFor(element(by.text('5'))).toExist().withTimeout(10000);
await waitFor(element(by.label('Load Older'))).toExist().withTimeout(5000); await waitFor(element(by.label('Load Older'))).toExist().withTimeout(5000);
@ -120,7 +135,7 @@ describe('Room', () => {
const expectThreadMessages = async(message) => { const expectThreadMessages = async(message) => {
await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000); await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);
await expect(element(by.text(message))).toExist(); await expect(element(by.text(message)).atIndex(0)).toExist();
}; };
describe('Threads', () => { describe('Threads', () => {
@ -152,7 +167,7 @@ describe('Threads', () => {
await element(by.id('room-view-search')).atIndex(0).tap(); await element(by.id('room-view-search')).atIndex(0).tap();
await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('search-messages-view'))).toExist().withTimeout(5000);
await element(by.id('search-message-view-input')).typeText('to be searched\n'); await element(by.id('search-message-view-input')).typeText('to be searched\n');
await waitFor(element(by.text('to be searched'))).toExist().withTimeout(5000); await waitFor(element(by.text('to be searched')).atIndex(1)).toExist().withTimeout(5000);
await element(by.text('to be searched')).atIndex(1).tap(); await element(by.text('to be searched')).atIndex(1).tap();
await expectThreadMessages('to be searched'); await expectThreadMessages('to be searched');
}); });

View File

@ -29,12 +29,28 @@ async function backToActions() {
} }
async function closeActionSheet() { async function closeActionSheet() {
await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6); await element(by.id('action-sheet-handle')).swipe('down', 'fast', 0.6);
await waitFor(element(by.id('action-sheet-handle'))).toBeNotVisible().withTimeout(3000);
await sleep(200);
} }
async function waitForToast() { async function waitForToast() {
await sleep(1000); await sleep(1000);
} }
async function swipeTillVisible(container, find, direction = 'up', delta = 0.3, speed = 'slow') {
let found = false;
while (!found) {
try {
await element(container).swipe(direction, speed, delta);
await sleep(200);
await expect(element(find)).toBeVisible();
found = true;
} catch (e) {
//
}
}
}
describe('Team', () => { describe('Team', () => {
const team = data.teams.private.name; const team = data.teams.private.name;
const user = data.users.alternate; const user = data.users.alternate;
@ -77,7 +93,7 @@ describe('Team', () => {
describe('Team Channels Header', () => { describe('Team Channels Header', () => {
it('should have actions button ', async() => { it('should have actions button ', async() => {
await expect(element(by.id('room-header'))).toExist(); await expect(element(by.id('room-header')).atIndex(0)).toExist();
}); });
it('should have team channels button ', async() => { it('should have team channels button ', async() => {
@ -109,7 +125,7 @@ describe('Team', () => {
await element(by.id('add-channel-team-view-create-channel')).tap(); await element(by.id('add-channel-team-view-create-channel')).tap();
await element(by.id('select-users-view-search')).replaceText('rocket.cat'); await element(by.id('select-users-view-search')).replaceText('rocket.cat');
await waitFor(element(by.id('select-users-view-item-rocket.cat'))).toBeVisible().withTimeout(2000); await waitFor(element(by.id('select-users-view-item-rocket.cat'))).toBeVisible().withTimeout(5000);
await element(by.id('select-users-view-item-rocket.cat')).tap(); await element(by.id('select-users-view-item-rocket.cat')).tap();
await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000); await waitFor(element(by.id('selected-user-rocket.cat'))).toBeVisible().withTimeout(10000);
await element(by.id('selected-users-view-submit')).tap(); await element(by.id('selected-users-view-submit')).tap();
@ -130,9 +146,9 @@ describe('Team', () => {
await element(by.id(`rooms-list-view-item-${ room }`)).tap(); await element(by.id(`rooms-list-view-item-${ room }`)).tap();
await waitFor(element(by.id(`room-view-title-${ room }`))).toExist().withTimeout(60000); await waitFor(element(by.id(`room-view-title-${ room }`))).toExist().withTimeout(60000);
await expect(element(by.id(`room-view-title-${ room }`))).toExist(); await expect(element(by.id(`room-view-title-${ room }`))).toExist();
await expect(element(by.id('room-view-header-team-channels'))).toExist(); await expect(element(by.id('room-view-header-team-channels')).atIndex(0)).toExist();
await expect(element(by.id('room-view-header-threads'))).toExist(); await expect(element(by.id('room-view-header-threads')).atIndex(0)).toExist();
await expect(element(by.id('room-view-search'))).toExist(); await expect(element(by.id('room-view-search')).atIndex(0)).toExist();
await tapBack(); await tapBack();
}); });
@ -152,12 +168,13 @@ describe('Team', () => {
await expect(element(by.id('room-view-header-team-channels'))).toExist(); await expect(element(by.id('room-view-header-team-channels'))).toExist();
await element(by.id('room-view-header-team-channels')).tap(); await element(by.id('room-view-header-team-channels')).tap();
await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(10000); await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0)).toExist().withTimeout(10000);
}); });
it('should activate/deactivate auto-join to channel', async() => { it('should activate/deactivate auto-join to channel', async() => {
await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress(); await element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0).longPress();
await element(by.id('action-sheet')).swipe('up', 'fast', 0.3); await sleep(500);
await swipeTillVisible(by.id('action-sheet-remove-from-team'), by.id('action-sheet-delete'));
await waitFor(element(by.id('action-sheet-auto-join'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('action-sheet-auto-join'))).toBeVisible().withTimeout(5000);
await waitFor(element(by.id('auto-join-unchecked'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('auto-join-unchecked'))).toBeVisible().withTimeout(5000);
await waitFor(element(by.id('action-sheet-remove-from-team'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('action-sheet-remove-from-team'))).toBeVisible().withTimeout(5000);
@ -170,7 +187,7 @@ describe('Team', () => {
await waitFor(element(by.id('auto-join-checked'))).toBeVisible().withTimeout(5000); await waitFor(element(by.id('auto-join-checked'))).toBeVisible().withTimeout(5000);
await element(by.id('auto-join-checked')).tap(); await element(by.id('auto-join-checked')).tap();
await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000); await waitFor(element(by.id('auto-join-tag'))).toBeNotVisible().withTimeout(5000);
await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`))).toExist().withTimeout(6000); await waitFor(element(by.id(`rooms-list-view-item-${ existingRoom }`)).atIndex(0)).toExist().withTimeout(6000);
}); });
}); });
@ -248,7 +265,7 @@ describe('Team', () => {
it('should remove member from team', async() => { it('should remove member from team', async() => {
await openActionSheet('rocket.cat'); await openActionSheet('rocket.cat');
await element(by.id('room-actions-scrollview')).scrollTo('bottom'); await swipeTillVisible(by.id('room-actions-scrollview'), by.id('action-sheet-remove-from-team'));
await element(by.id('action-sheet-remove-from-team')).tap(); await element(by.id('action-sheet-remove-from-team')).tap();
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(5000); await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(5000);
await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(5000); await waitFor(element(by.id(`select-list-view-item-${ room }`))).toExist().withTimeout(5000);
@ -281,7 +298,7 @@ describe('Team', () => {
await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ existingRoom }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${ room }`)).tap(); await element(by.id(`select-list-view-item-${ room }`)).tap();
await waitFor(element(by.label('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000); await waitFor(element(by.text('You are the last owner of this channel. Once you leave the team, the channel will be kept inside the team but you will be managing it from outside.'))).toExist().withTimeout(2000);
await element(by.text('OK')).tap(); await element(by.text('OK')).tap();
await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);
await element(by.id('select-list-view-submit')).tap(); await element(by.id('select-list-view-submit')).tap();

View File

@ -76,7 +76,7 @@ describe('Move/Convert Team', () => {
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000);
await element(by.id('select-list-view-submit')).tap(); await element(by.id('select-list-view-submit')).tap();
await sleep(2000); await sleep(2000);
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view')).atIndex(0)).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${ toBeConverted }`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ toBeConverted }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${ toBeConverted }`)).tap(); await element(by.id(`select-list-view-item-${ toBeConverted }`)).tap();
await element(by.id('select-list-view-submit')).atIndex(0).tap(); await element(by.id('select-list-view-submit')).atIndex(0).tap();
@ -98,7 +98,7 @@ describe('Move/Convert Team', () => {
await waitFor(element(by.id('room-actions-convert-channel-to-team'))).toExist().withTimeout(2000); await waitFor(element(by.id('room-actions-convert-channel-to-team'))).toExist().withTimeout(2000);
await element(by.id('room-actions-convert-channel-to-team')).tap(); await element(by.id('room-actions-convert-channel-to-team')).tap();
await sleep(2000); await sleep(2000);
await waitFor(element(by.id('select-list-view'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view')).atIndex(0)).toExist().withTimeout(2000);
await waitFor(element(by.id(`select-list-view-item-${ toBeMoved }`))).toExist().withTimeout(2000); await waitFor(element(by.id(`select-list-view-item-${ toBeMoved }`))).toExist().withTimeout(2000);
await element(by.id(`select-list-view-item-${ toBeMoved }`)).tap(); await element(by.id(`select-list-view-item-${ toBeMoved }`)).tap();
await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000); await waitFor(element(by.id('select-list-view-submit'))).toExist().withTimeout(2000);

View File

@ -23,7 +23,7 @@
}, },
"lint-staged": { "lint-staged": {
"*.{js,ts,tsx}": [ "*.{js,ts,tsx}": [
"eslint", "eslint",
"jest --bail --findRelatedTests" "jest --bail --findRelatedTests"
] ]
}, },