Skip to content

Commit

Permalink
fix: clear previous field to make sure you always can type a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Nov 19, 2024
1 parent 29cbff0 commit ca40573
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/libs/E2E/tests/moneyRequestTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Performance from '@libs/Performance';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import * as NativeCommands from '../../../../tests/e2e/nativeCommands/NativeCommandsAction';

const test = (config: NativeConfig) => {
// check for login (if already logged in the action will simply resolve)
Expand Down Expand Up @@ -43,13 +44,14 @@ const test = (config: NativeConfig) => {
metric: entry.duration,
unit: 'ms',
});
setTimeout(() => {
tap('button_2');
}, 2000);
})
.then(() => E2EClient.sendNativeCommand(NativeCommands.makeClearCommand()))
.then(() => {
tap('button_2');
setTimeout(() => {
Performance.markStart(CONST.TIMING.OPEN_SUBMIT_EXPENSE_CONTACT);
tap('next-button');
}, 4000);
}, 1000);
})
.then(() => waitForEvent(CONST.TIMING.OPEN_SUBMIT_EXPENSE_CONTACT))
.then((entry) => {
Expand Down
7 changes: 6 additions & 1 deletion tests/e2e/nativeCommands/NativeCommandsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const NativeCommandsAction = {
scroll: 'scroll',
type: 'type',
backspace: 'backspace',
clear: 'clear',
} as const;

const makeTypeTextCommand = (text: string): NativeCommand => ({
Expand All @@ -17,4 +18,8 @@ const makeBackspaceCommand = (): NativeCommand => ({
actionName: NativeCommandsAction.backspace,
});

export {NativeCommandsAction, makeTypeTextCommand, makeBackspaceCommand};
const makeClearCommand = (): NativeCommand => ({
actionName: NativeCommandsAction.clear,
});

export {NativeCommandsAction, makeTypeTextCommand, makeBackspaceCommand, makeClearCommand};
16 changes: 16 additions & 0 deletions tests/e2e/nativeCommands/adbClear.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import execAsync from '../utils/execAsync';
import * as Logger from '../utils/logger';

const adbClear = (): Promise<boolean> => {
Logger.log(`🧹 Clearing the typed text`);
return execAsync(`
function clear_input() {
adb shell input keyevent KEYCODE_MOVE_END
adb shell input keyevent --longpress $(printf 'KEYCODE_DEL %.0s' {1..250})
}
clear_input
`).then(() => true);
};

export default adbClear;
3 changes: 3 additions & 0 deletions tests/e2e/nativeCommands/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {NativeCommandPayload} from '@libs/E2E/client';
import adbBackspace from './adbBackspace';
import adbClear from './adbClear';
import adbTypeText from './adbTypeText';
// eslint-disable-next-line rulesdir/prefer-import-module-contents
import {NativeCommandsAction} from './NativeCommandsAction';
Expand All @@ -12,6 +13,8 @@ const executeFromPayload = (actionName?: string, payload?: NativeCommandPayload)
return adbTypeText(payload?.text ?? '');
case NativeCommandsAction.backspace:
return adbBackspace();
case NativeCommandsAction.clear:
return adbClear();
default:
throw new Error(`Unknown action: ${actionName}`);
}
Expand Down

0 comments on commit ca40573

Please sign in to comment.