verdnatura-chat/e2e/helpers/platformFunctions.js

29 lines
808 B
JavaScript
Raw Normal View History

const { exec } = require('child_process');
const { device } = require('detox');
function runCommand(command) {
2021-07-15 20:59:16 +00:00
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.
2021-07-15 20:59:16 +00:00
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');
};
2021-06-23 21:00:26 +00:00
2021-07-15 20:59:16 +00:00
exports.closeKeyboardAndroid = async() => {
await device.pressBack(); // Android-only
};