Code Cleaning
This commit is contained in:
parent
b6ad070ce6
commit
3e029e4b7f
|
@ -1,8 +1,24 @@
|
||||||
const {
|
const {
|
||||||
expect, element, by, waitFor
|
expect, element, by, waitFor
|
||||||
} = require('detox');
|
} = require('detox');
|
||||||
|
const { exec } = require('child_process');
|
||||||
const data = require('../data');
|
const data = require('../data');
|
||||||
const platformTypes = require('./platformTypes');
|
|
||||||
|
const platformTypes = {
|
||||||
|
android: {
|
||||||
|
// Android types
|
||||||
|
alertButtonType: 'android.widget.Button',
|
||||||
|
scrollViewType: 'android.widget.ScrollView',
|
||||||
|
textInputType: 'android.widget.EditText'
|
||||||
|
},
|
||||||
|
ios: {
|
||||||
|
// iOS types
|
||||||
|
alertButtonType: '_UIAlertControllerActionView',
|
||||||
|
scrollViewType: 'UIScrollView',
|
||||||
|
textInputType: '_UIAlertControllerTextField'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
async function navigateToWorkspace(server = data.server) {
|
async function navigateToWorkspace(server = data.server) {
|
||||||
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
await waitFor(element(by.id('onboarding-view'))).toBeVisible().withTimeout(10000);
|
||||||
|
@ -145,6 +161,29 @@ const checkServer = async(server) => {
|
||||||
await element(by.id('sidebar-close-drawer')).tap();
|
await element(by.id('sidebar-close-drawer')).tap();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function runCommand(command) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(new Error(`exec error: ${ stderr }`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function prepareAndroid() {
|
||||||
|
if (device.getPlatform() !== 'android') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await runCommand('adb shell settings put secure spell_checker_enabled 0');
|
||||||
|
await runCommand('adb shell settings put secure autofill_service null');
|
||||||
|
await runCommand('adb shell settings put global window_animation_scale 0.0');
|
||||||
|
await runCommand('adb shell settings put global transition_animation_scale 0.0');
|
||||||
|
await runCommand('adb shell settings put global animator_duration_scale 0.0');
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
navigateToWorkspace,
|
navigateToWorkspace,
|
||||||
navigateToLogin,
|
navigateToLogin,
|
||||||
|
@ -160,5 +199,7 @@ module.exports = {
|
||||||
searchRoom,
|
searchRoom,
|
||||||
tryTapping,
|
tryTapping,
|
||||||
checkServer,
|
checkServer,
|
||||||
mockMessageWithNag
|
mockMessageWithNag,
|
||||||
|
platformTypes,
|
||||||
|
prepareAndroid
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
const { exec } = require('child_process');
|
|
||||||
const { device } = require('detox');
|
|
||||||
|
|
||||||
function runCommand(command) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
exec(command, (error, stdout, stderr) => {
|
|
||||||
if (error) {
|
|
||||||
reject(new Error(`exec error: ${ stderr }`));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// The Spell Checker and the autofill service introduce additional flakiness, and appear over other elements.
|
|
||||||
// So, we disable them before running the tests.
|
|
||||||
exports.prepareAndroid = async() => {
|
|
||||||
if (device.getPlatform() !== 'android') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await runCommand('adb shell settings put secure spell_checker_enabled 0');
|
|
||||||
await runCommand('adb shell settings put secure autofill_service null');
|
|
||||||
await runCommand('adb shell settings put global window_animation_scale 0.0');
|
|
||||||
await runCommand('adb shell settings put global transition_animation_scale 0.0');
|
|
||||||
await runCommand('adb shell settings put global animator_duration_scale 0.0');
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.closeKeyboardAndroid = async() => {
|
|
||||||
await device.pressBack(); // Android-only
|
|
||||||
};
|
|
|
@ -1,13 +0,0 @@
|
||||||
exports.android = {
|
|
||||||
// Android types
|
|
||||||
alertButtonType: 'android.widget.Button',
|
|
||||||
scrollViewType: 'android.widget.ScrollView',
|
|
||||||
textInputType: 'android.widget.EditText'
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.ios = {
|
|
||||||
// iOS types
|
|
||||||
alertButtonType: '_UIAlertControllerActionView',
|
|
||||||
scrollViewType: 'UIScrollView',
|
|
||||||
textInputType: '_UIAlertControllerTextField'
|
|
||||||
};
|
|
|
@ -1,9 +1,7 @@
|
||||||
const {
|
const {
|
||||||
navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout
|
navigateToLogin, login, sleep, tapBack, mockMessage, searchRoom, logout, platformTypes
|
||||||
} = require('../../helpers/app');
|
} = require('../../helpers/app');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
|
|
||||||
const testuser = data.users.regular;
|
const testuser = data.users.regular;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
const { navigateToLogin, login, sleep } = require('../../helpers/app');
|
const {
|
||||||
|
navigateToLogin,
|
||||||
|
login,
|
||||||
|
sleep,
|
||||||
|
platformTypes
|
||||||
|
} = require('../../helpers/app');
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
const profileChangeUser = data.users.profileChanges;
|
const profileChangeUser = data.users.profileChanges;
|
||||||
|
|
||||||
const scrollDown = 200;
|
const scrollDown = 200;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const { navigateToLogin, login } = require('../../helpers/app');
|
const { navigateToLogin, login, platformTypes } = require('../../helpers/app');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
const {
|
const {
|
||||||
navigateToLogin, login, mockMessage, tapBack, searchRoom
|
navigateToLogin, login, mockMessage, tapBack, searchRoom, platformTypes
|
||||||
} = require('../../helpers/app');
|
} = require('../../helpers/app');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
const testuser = data.users.regular;
|
const testuser = data.users.regular;
|
||||||
const room = data.channels.detoxpublic.name;
|
const room = data.channels.detoxpublic.name;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
const {
|
const {
|
||||||
sleep, navigateToLogin, login, checkServer
|
sleep, navigateToLogin, login, checkServer, platformTypes
|
||||||
} = require('../../helpers/app');
|
} = require('../../helpers/app');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
describe('Delete server', () => {
|
describe('Delete server', () => {
|
||||||
let scrollViewType;
|
let scrollViewType;
|
||||||
let alertButtonType;
|
let alertButtonType;
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
const { tapBack, checkServer, navigateToRegister } = require('../../helpers/app');
|
const {
|
||||||
|
tapBack,
|
||||||
|
checkServer,
|
||||||
|
navigateToRegister,
|
||||||
|
platformTypes
|
||||||
|
} = require('../../helpers/app');
|
||||||
const { get, login } = require('../../helpers/data_setup');
|
const { get, login } = require('../../helpers/data_setup');
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
|
const DEEPLINK_METHODS = { AUTH: 'auth', ROOM: 'room' };
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ const detox = require('detox');
|
||||||
const adapter = require('detox/runners/mocha/adapter');
|
const adapter = require('detox/runners/mocha/adapter');
|
||||||
const config = require('../../package.json').detox;
|
const config = require('../../package.json').detox;
|
||||||
const { setup } = require('../helpers/data_setup');
|
const { setup } = require('../helpers/data_setup');
|
||||||
const { prepareAndroid } = require('../helpers/platformFunctions');
|
const { prepareAndroid } = require('../helpers/app');
|
||||||
|
|
||||||
before(async() => {
|
before(async() => {
|
||||||
await Promise.all([setup(), detox.init(config, { launchApp: false })]);
|
await Promise.all([setup(), detox.init(config, { launchApp: false })]);
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
const {
|
const {
|
||||||
navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage
|
navigateToLogin, login, tapBack, sleep, searchRoom, mockMessage, starMessage, pinMessage, platformTypes
|
||||||
} = require('../../helpers/app');
|
} = require('../../helpers/app');
|
||||||
const { sendMessage } = require('../../helpers/data_setup');
|
const { sendMessage } = require('../../helpers/data_setup');
|
||||||
|
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
async function navigateToRoomActions(type) {
|
async function navigateToRoomActions(type) {
|
||||||
let room;
|
let room;
|
||||||
if (type === 'd') {
|
if (type === 'd') {
|
||||||
|
@ -376,11 +374,19 @@ describe('Room actions screen', () => {
|
||||||
|
|
||||||
const openActionSheet = async(username) => {
|
const openActionSheet = async(username) => {
|
||||||
await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);
|
await waitFor(element(by.id(`room-members-view-item-${ username }`))).toExist().withTimeout(5000);
|
||||||
await element(by.id(`room-members-view-item-${ username }`)).tap();
|
let n = 0;
|
||||||
await sleep(300);
|
while (n < 3) {
|
||||||
await expect(element(by.id('action-sheet'))).toExist();
|
// Max tries three times, in case it does not register the click
|
||||||
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
|
try {
|
||||||
await element(by.id('action-sheet-handle')).swipe('up');
|
await element(by.id(`room-members-view-item-${ username }`)).tap();
|
||||||
|
await waitFor(element(by.id('action-sheet'))).toExist().withTimeout(5000);
|
||||||
|
await expect(element(by.id('action-sheet-handle'))).toBeVisible();
|
||||||
|
await element(by.id('action-sheet-handle')).swipe('up');
|
||||||
|
return;
|
||||||
|
} catch (e) {
|
||||||
|
n += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeActionSheet = async() => {
|
const closeActionSheet = async() => {
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
const data = require('../../data');
|
const data = require('../../data');
|
||||||
const {
|
const {
|
||||||
navigateToLogin, tapBack, login, searchRoom, sleep
|
navigateToLogin, tapBack, login, searchRoom, sleep, platformTypes
|
||||||
} = require('../../helpers/app');
|
} = require('../../helpers/app');
|
||||||
const platformTypes = require('../../helpers/platformTypes');
|
|
||||||
|
|
||||||
async function navigateToRoom(roomName) {
|
async function navigateToRoom(roomName) {
|
||||||
await searchRoom(`${ roomName }`);
|
await searchRoom(`${ roomName }`);
|
||||||
|
|
Loading…
Reference in New Issue