replaceText where usable

This commit is contained in:
Anant Bhasin 2021-08-03 13:28:30 +05:30
parent df6f85e940
commit 2d765eea77
17 changed files with 47 additions and 58 deletions

View File

@ -34,7 +34,7 @@ buildscript {
if (isPlay) {
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'
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.bugsnag:bugsnag-android-gradle-plugin:5+'
}
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

View File

@ -8,7 +8,8 @@ async function navigateToWorkspace(server = data.server) {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${ server }\n`);
await element(by.id('new-server-view-input')).replaceText(`${ server }`);
await element(by.text('Connect')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await expect(element(by.id('workspace-view'))).toBeVisible();
}
@ -57,7 +58,7 @@ async function logout() {
async function mockMessage(message, isThread = false) {
const input = isThread ? 'messagebox-input-thread' : 'messagebox-input';
await element(by.id(input)).tap();
await element(by.id(input)).typeText(`${ data.random }${ message }`);
await element(by.id(input)).replaceText(`${ data.random }${ message }`);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.text(`${ data.random }${ message }`))).toExist().withTimeout(60000);
await expect(element(by.text(`${ data.random }${ message }`))).toExist();
@ -95,7 +96,7 @@ async function dismissReviewNag() {
async function mockMessageWithNag(message, isThread = false) {
const input = isThread ? 'messagebox-input-thread' : 'messagebox-input';
await element(by.id(input)).tap();
await element(by.id(input)).typeText(`${ data.random }${ message }`);
await element(by.id(input)).replaceText(`${ data.random }${ message }`);
await element(by.id('messagebox-send-message')).tap();
await dismissReviewNag();
await waitFor(element(by.text(`${ data.random }${ message }`))).toExist().withTimeout(60000);
@ -115,7 +116,7 @@ async function searchRoom(room) {
await element(by.id('rooms-list-view-search')).tap();
await expect(element(by.id('rooms-list-view-search-input'))).toExist();
await waitFor(element(by.id('rooms-list-view-search-input'))).toExist().withTimeout(5000);
await element(by.id('rooms-list-view-search-input')).typeText(room);
await element(by.id('rooms-list-view-search-input')).replaceText(room);
await sleep(300);
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
}
@ -144,12 +145,6 @@ const checkServer = async(server) => {
await element(by.id('sidebar-close-drawer')).tap();
};
async function closeKeyboard() {
if (device.getPlatform() === 'android') {
await device.goBack();
}
}
module.exports = {
navigateToWorkspace,
navigateToLogin,
@ -165,6 +160,5 @@ module.exports = {
searchRoom,
tryTapping,
checkServer,
closeKeyboard,
mockMessageWithNag
};

View File

@ -4,8 +4,6 @@ const {
const platformTypes = require('../../helpers/platformTypes');
const { closeKeyboardAndroid } = require('../../helpers/platformFunctions');
const data = require('../../data');
const testuser = data.users.regular;
@ -143,7 +141,7 @@ describe('E2E Encryption', () => {
describe('Change password', () => {
it('should change password', async() => {
await element(by.id('e2e-encryption-security-view-password')).typeText(newPassword);
await element(by.id('e2e-encryption-security-view-password')).replaceText(newPassword);
await element(by.id('e2e-encryption-security-view-change-password')).tap();
await waitFor(element(by.text('Are you sure?'))).toExist().withTimeout(2000);
await expect(element(by.text('Make sure you\'ve saved it carefully somewhere else.'))).toExist();
@ -182,7 +180,7 @@ describe('E2E Encryption', () => {
await waitFor(element(by.id('listheader-encryption').withDescendant(by.text('Enter Your E2E Password')))).toBeVisible().withTimeout(2000);
await element(by.id('listheader-encryption').withDescendant(by.text('Enter Your E2E Password'))).tap();
await waitFor(element(by.id('e2e-enter-your-password-view'))).toBeVisible().withTimeout(2000);
await element(by.id('e2e-enter-your-password-view-password')).typeText(newPassword);
await element(by.id('e2e-enter-your-password-view-password')).replaceText(newPassword);
await element(by.id('e2e-enter-your-password-view-confirm')).tap();
await waitFor(element(by.id('listheader-encryption'))).not.toExist().withTimeout(10000);
await navigateToRoom(room);
@ -227,7 +225,8 @@ describe('E2E Encryption', () => {
// TODO: refactor
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await element(by.id('new-server-view-input')).replaceText(`${ data.alternateServer }`);
await element(by.text('Connect')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
@ -236,8 +235,7 @@ describe('E2E Encryption', () => {
await element(by.id('register-view-name')).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-password')).typeText(data.registeringUser.password);
await closeKeyboardAndroid();
await element(by.id('register-view-password')).replaceText(data.registeringUser.password);
element(by.type(scrollViewType)).atIndex(1).scrollTo('bottom');
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);

View File

@ -2,7 +2,6 @@ const { navigateToLogin, login, sleep } = require('../../helpers/app');
const data = require('../../data');
const platformTypes = require('../../helpers/platformTypes');
const { closeKeyboardAndroid } = require('../../helpers/platformFunctions');
const profileChangeUser = data.users.profileChanges;
@ -81,8 +80,7 @@ describe('Profile screen', () => {
describe('Usage', () => {
it('should change name and username', async() => {
await element(by.id('profile-view-name')).replaceText(`${ profileChangeUser.username }new`);
await element(by.id('profile-view-username')).typeText(`${ profileChangeUser.username }new`);
await closeKeyboardAndroid();
await element(by.id('profile-view-username')).replaceText(`${ profileChangeUser.username }new`);
await element(by.type(scrollViewType)).atIndex(1).swipe('up');
await element(by.id('profile-view-submit')).tap();
await waitForToast();
@ -92,11 +90,8 @@ describe('Profile screen', () => {
await element(by.id('profile-view-email')).replaceText(`mobile+profileChangesNew${ data.random }@rocket.chat`);
await element(by.id('profile-view-new-password')).replaceText(`${ profileChangeUser.password }new`);
await element(by.id('profile-view-submit')).tap();
await element(by.type(textInputType)).typeText(`${ profileChangeUser.password }\n`);
// TODO: Check if this is fine on iOS
if (device.getPlatform() === 'android') {
await element(by.text('SAVE')).tap();
}
await element(by.type(textInputType)).replaceText(`${ profileChangeUser.password }`);
await element(by.text('SAVE')).tap();
await waitForToast();
});

View File

@ -39,7 +39,7 @@ describe('Status screen', () => {
});
it('should change status text', async() => {
await element(by.id('status-view-input')).typeText('status-text-new');
await element(by.id('status-view-input')).replaceText('status-text-new');
await element(by.id('status-view-submit')).tap();
await waitForToast();
await waitFor(element(by.text('status-text-new').withAncestor(by.id('sidebar-custom-status')))).toExist().withTimeout(2000);

View File

@ -22,7 +22,8 @@ describe('Change server', () => {
await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(6000);
await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await element(by.id('new-server-view-input')).replaceText(`${ data.alternateServer }`);
await element(by.text('Connect')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
await reopenAndCheckServer(data.server);
});

View File

@ -10,7 +10,7 @@ const { joinCode } = data.channels.detoxpublicprotected;
async function navigateToRoom() {
await searchRoom(room);
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 openJoinCode() {

View File

@ -26,7 +26,8 @@ describe('Delete server', () => {
await element(by.id('rooms-list-header-server-add')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(10000);
await element(by.id('new-server-view-input')).typeText(`${ data.alternateServer }\n`);
await element(by.id('new-server-view-input')).replaceText(`${ data.alternateServer }`);
await element(by.text('Connect')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(10000);
await element(by.id('workspace-view-register')).tap();
await waitFor(element(by.id('register-view'))).toBeVisible().withTimeout(2000);
@ -35,7 +36,7 @@ describe('Delete server', () => {
await element(by.id('register-view-name')).replaceText(data.registeringUser3.username);
await element(by.id('register-view-username')).replaceText(data.registeringUser3.username);
await element(by.id('register-view-email')).replaceText(data.registeringUser3.email);
await element(by.id('register-view-password')).typeText(data.registeringUser3.password);
await element(by.id('register-view-password')).replaceText(data.registeringUser3.password);
await element(by.type(scrollViewType)).atIndex(0).swipe('up');
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(60000);

View File

@ -2,7 +2,6 @@ const data = require('../../data');
const { tapBack, checkServer, navigateToRegister } = require('../../helpers/app');
const { get, login } = require('../../helpers/data_setup');
const platformTypes = require('../../helpers/platformTypes');
const { closeKeyboardAndroid } = require('../../helpers/platformFunctions');
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
@ -34,7 +33,7 @@ describe('Deep linking', () => {
delete: true,
url: getDeepLink(DEEPLINK_METHODS.AUTH, data.server, `userId=123${ amp }token=abc`)
});
await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(10000); // TODO: we need to improve this message
await waitFor(element(by.text('You\'ve been logged out by the server. Please log in again.'))).toExist().withTimeout(20000); // TODO: we need to improve this message
});
const authAndNavigate = async() => {
@ -60,8 +59,7 @@ describe('Deep linking', () => {
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);
await element(by.id('register-view-password')).typeText(data.registeringUser4.password);
await closeKeyboardAndroid();
await element(by.id('register-view-password')).replaceText(data.registeringUser4.password);
await element(by.type(scrollViewType)).atIndex(0).scrollTo('bottom');
await element(by.id('register-view-submit')).tap();
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(10000);

View File

@ -31,7 +31,8 @@ describe('Onboarding', () => {
});
it('should enter an invalid server and get error', async() => {
await element(by.id('new-server-view-input')).typeText('invalidtest\n');
await element(by.id('new-server-view-input')).replaceText('invalidtest');
await element(by.text('Connect')).tap();
const errorText = 'Oops!';
await waitFor(element(by.text(errorText))).toBeVisible().withTimeout(60000);
await element(by.text('OK')).tap();
@ -47,7 +48,8 @@ describe('Onboarding', () => {
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(2000);
await element(by.id('join-workspace')).tap();
await waitFor(element(by.id('new-server-view'))).toBeVisible().withTimeout(60000);
await element(by.id('new-server-view-input')).typeText(`${ data.server }\n`);
await element(by.id('new-server-view-input')).replaceText(`${ data.server }`);
await element(by.text('Connect')).tap();
await waitFor(element(by.id('workspace-view'))).toBeVisible().withTimeout(60000);
});
});

View File

@ -93,7 +93,7 @@ describe('Create room screen', () => {
describe('Usage', () => {
it('should get invalid room', async() => {
await element(by.id('create-channel-name')).typeText('general');
await element(by.id('create-channel-name')).replaceText('general');
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.text('A channel with name general exists'))).toExist().withTimeout(60000);
await expect(element(by.text('A channel with name general exists'))).toExist();
@ -103,7 +103,7 @@ describe('Create room screen', () => {
it('should create public room', async() => {
const room = `public${ data.random }`;
await element(by.id('create-channel-name')).replaceText('');
await element(by.id('create-channel-name')).typeText(room);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-type')).tap();
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(6000);
@ -127,7 +127,7 @@ describe('Create room screen', () => {
await waitFor(element(by.id('selected-user-rocket.cat'))).toExist().withTimeout(5000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(5000);
await element(by.id('create-channel-name')).typeText(room);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await expect(element(by.id('room-view'))).toExist();
@ -149,7 +149,7 @@ describe('Create room screen', () => {
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(5000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
await element(by.id('create-channel-name')).typeText(room);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await expect(element(by.id('room-view'))).toExist();

View File

@ -93,7 +93,7 @@ describe('Room screen', () => {
it('should show and tap on emoji autocomplete', async() => {
await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).replaceText(':');
await element(by.id('messagebox-input')).typeText(':');
await element(by.id('messagebox-input')).typeText('joy'); // workaround for number keyboard
await waitFor(element(by.id('messagebox-container'))).toExist().withTimeout(10000);
await element(by.id('mention-item-joy')).tap();
@ -103,7 +103,7 @@ describe('Room screen', () => {
it('should not show emoji autocomplete on semicolon in middle of a string', async() => {
await element(by.id('messagebox-input')).tap();
// await element(by.id('messagebox-input')).replaceText(':');
// await element(by.id('messagebox-input')).typeText(':');
await element(by.id('messagebox-input')).typeText('name:is');
await waitFor(element(by.id('messagebox-container'))).toNotExist().withTimeout(20000);
await element(by.id('messagebox-input')).clearText();
@ -148,7 +148,7 @@ describe('Room screen', () => {
});
it('should draft message', async() => {
await element(by.id('messagebox-input')).tap();
await element(by.id('messagebox-input')).typeText(`${ data.random }draft`);
await element(by.id('messagebox-input')).replaceText(`${ data.random }draft`);
await tapBack();
await navigateToRoom(mainRoom);
@ -249,7 +249,7 @@ describe('Room screen', () => {
await element(by.text('Edit')).atIndex(0).tap();
await element(by.id('messagebox-input')).replaceText(`${ data.random }edited`);
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.text(`${ data.random }edited (edited)`)).atIndex(0)).toExist().withTimeout(60000);
await waitFor(element(by.text(`${ data.random }edited (edited)`)).atIndex(0)).toExist().withTimeout(60000); // Failing on android
});
it('should quote message', async() => {
@ -259,7 +259,7 @@ describe('Room screen', () => {
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.text('Quote')).atIndex(0).tap();
await element(by.id('messagebox-input')).typeText(`${ data.random }quoted`);
await element(by.id('messagebox-input')).replaceText(`${ data.random }quoted`);
await element(by.id('messagebox-send-message')).tap();
// TODO: test if quote was sent
@ -270,7 +270,7 @@ describe('Room screen', () => {
await pinMessage('pin');
await waitFor(element(by.text(`${ data.random }pin`)).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.text(`${ data.users.regular.username } Message pinned`)).atIndex(0)).toExist().withTimeout(5000);
await waitFor(element(by.text(`${ data.users.regular.username } Message pinned`)).atIndex(0)).toExist().withTimeout(5000); // Failing on android
await element(by.text(`${ data.random }pin`)).atIndex(0).longPress();
await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(1000);
await expect(element(by.id('action-sheet-handle'))).toBeVisible();

View File

@ -72,7 +72,7 @@ describe('Threads', () => {
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
await element(by.id('action-sheet-handle')).swipe('up', 'fast', 0.5);
await element(by.label('Reply in Thread')).atIndex(0).tap();
await element(by.id('messagebox-input')).typeText('replied');
await element(by.id('messagebox-input')).replaceText('replied');
await element(by.id('messagebox-send-message')).tap();
await waitFor(element(by.id(`message-thread-button-${ thread }`))).toExist().withTimeout(5000);
await expect(element(by.id(`message-thread-button-${ thread }`))).toExist();
@ -113,7 +113,7 @@ describe('Threads', () => {
const messageText = 'sendToChannel';
await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id('messagebox-input-thread'))).toExist().withTimeout(5000);
await element(by.id('messagebox-input-thread')).typeText(messageText);
await element(by.id('messagebox-input-thread')).replaceText(messageText);
await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap();
await tapBack();
@ -128,7 +128,7 @@ describe('Threads', () => {
await mockMessageWithNag('dummymessagebetweenthethread');
await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id('messagebox-input-thread'))).toExist().withTimeout(5000);
await element(by.id('messagebox-input-thread')).typeText(messageText);
await element(by.id('messagebox-input-thread')).replaceText(messageText);
await element(by.id('messagebox-send-to-channel')).tap();
await element(by.id('messagebox-send-message')).tap();
await tapBack();
@ -158,7 +158,7 @@ describe('Threads', () => {
it('should draft thread message', async() => {
await element(by.id(`message-thread-button-${ thread }`)).tap();
await waitFor(element(by.id(`room-view-title-${ thread }`))).toExist().withTimeout(5000);
await element(by.id('messagebox-input-thread')).typeText(`${ thread }draft`);
await element(by.id('messagebox-input-thread')).replaceText(`${ thread }draft`);
await tapBack();
await element(by.id(`message-thread-button-${ thread }`)).tap();

View File

@ -91,7 +91,7 @@ describe('Room', () => {
await navigateToRoom('jumping');
await element(by.id('room-view-search')).tap();
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')).replaceText('30');
await waitFor(element(by.text('30')).atIndex(1)).toExist().withTimeout(5000);
await element(by.text('30')).atIndex(1).tap();
await waitForLoading();
@ -166,7 +166,7 @@ describe('Threads', () => {
await waitFor(element(by.id('room-view-title-jumping-thread'))).toExist().withTimeout(5000);
await element(by.id('room-view-search')).atIndex(0).tap();
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')).replaceText('to be searched');
await waitFor(element(by.text('to be searched')).atIndex(1)).toExist().withTimeout(5000);
await element(by.text('to be searched')).atIndex(1).tap();
await expectThreadMessages('to be searched');

View File

@ -35,7 +35,7 @@ describe('Create team screen', () => {
describe('Create Team', () => {
describe('Usage', () => {
it('should get invalid team name', async() => {
await element(by.id('create-channel-name')).typeText(`${ data.teams.private.name }`);
await element(by.id('create-channel-name')).replaceText(`${ data.teams.private.name }`);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.text('OK'))).toBeVisible().withTimeout(5000);
await element(by.text('OK')).tap();
@ -43,7 +43,7 @@ describe('Create team screen', () => {
it('should create private team', async() => {
await element(by.id('create-channel-name')).replaceText('');
await element(by.id('create-channel-name')).typeText(teamName);
await element(by.id('create-channel-name')).replaceText(teamName);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);
await expect(element(by.id('room-view'))).toExist();

View File

@ -132,7 +132,7 @@ describe('Team', () => {
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
await element(by.id('create-channel-name')).replaceText('');
await element(by.id('create-channel-name')).typeText(room);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(20000);

View File

@ -13,7 +13,7 @@ const createChannel = async(room) => {
await waitFor(element(by.id('select-users-view'))).toExist().withTimeout(5000);
await element(by.id('selected-users-view-submit')).tap();
await waitFor(element(by.id('create-channel-view'))).toExist().withTimeout(10000);
await element(by.id('create-channel-name')).typeText(room);
await element(by.id('create-channel-name')).replaceText(room);
await element(by.id('create-channel-submit')).tap();
await waitFor(element(by.id('room-view'))).toExist().withTimeout(60000);
await waitFor(element(by.id(`room-view-title-${ room }`))).toExist().withTimeout(60000);