2021-06-23 19:06:55 +00:00
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|
2021-06-23 19:06:55 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:47:57 +00:00
|
|
|
// 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
|
|
|
|
};
|