From 081bd3db537681a74ddebf5f47dce8bfcf7bdc48 Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Mon, 16 Nov 2026 23:19:00 +0000 Subject: [PATCH 1/5] fix: clear an Android field with an empty typeText `typeText("")` cleared the field, then ran `adb shell input text` with no argument, which throws `Argument expected after "text"` on the device. Return after the clear step when the text is empty. --- src/backends/adb-backend.test.ts | 46 ++++++++++++++++++++++++++++++++ src/backends/adb-backend.ts | 5 ++++ src/tools/type-text.ts | 3 ++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/backends/adb-backend.test.ts b/src/backends/adb-backend.test.ts index 71749f6..5b1d6eb 100644 --- a/src/backends/adb-backend.test.ts +++ b/src/backends/adb-backend.test.ts @@ -737,6 +737,52 @@ describe('AdbBackend.tapElement', () => { }); }); +describe('AdbBackend.typeText', () => { + let backend: AdbBackend; + + const inputCalls = (): string[][] => + mockExecStrict.mock.calls.map(([, args]) => (args ?? []).slice(3)); + + beforeEach(() => { + vi.clearAllMocks(); + mockExecStrict.mockResolvedValue(''); + backend = new AdbBackend('emulator-5554'); + }); + + it('clears the field, then types the escaped text', async () => { + await backend.typeText('a b&c'); + + expect(inputCalls()).toStrictEqual([ + ['input', 'keyevent', 'KEYCODE_MOVE_HOME'], + [ + 'input', + 'keyevent', + '--longpress', + 'KEYCODE_SHIFT_LEFT', + 'KEYCODE_MOVE_END', + ], + ['input', 'keyevent', '67'], + ['input', 'text', 'a%sb\\&c'], + ]); + }); + + it('only clears the field for an empty string', async () => { + await backend.typeText(''); + + expect(inputCalls()).toStrictEqual([ + ['input', 'keyevent', 'KEYCODE_MOVE_HOME'], + [ + 'input', + 'keyevent', + '--longpress', + 'KEYCODE_SHIFT_LEFT', + 'KEYCODE_MOVE_END', + ], + ['input', 'keyevent', '67'], + ]); + }); +}); + describe('AdbBackend.screenshot', () => { let backend: AdbBackend; diff --git a/src/backends/adb-backend.ts b/src/backends/adb-backend.ts index 578f865..db17177 100644 --- a/src/backends/adb-backend.ts +++ b/src/backends/adb-backend.ts @@ -356,6 +356,11 @@ export class AdbBackend implements DeviceBackend { 'KEYCODE_MOVE_END', ]); await this.#adb(['shell', 'input', 'keyevent', '67']); + // `input text` with no argument throws on the device, and the field is + // already empty. + if (text.length === 0) { + return; + } // Android input text requires escaping spaces and special chars const escaped = text.replace(/ /gu, '%s').replace(/[&|;<>]/gu, '\\$&'); await this.#adb(['shell', 'input', 'text', escaped]); diff --git a/src/tools/type-text.ts b/src/tools/type-text.ts index 9e87e0d..b8fc1ee 100644 --- a/src/tools/type-text.ts +++ b/src/tools/type-text.ts @@ -15,7 +15,8 @@ export function registerTypeTool( description: 'Type text into the currently focused input field. ' + 'Tap an input element first to focus it, then call this. ' + - 'The field is cleared before typing on all backends.', + 'The field is cleared before typing on all backends. On Android ' + + '(adb), an empty string clears the field.', inputSchema: { text: z.string().describe('Text to type'), }, From 7a58f2172e2ae35c99ff0b7a6279e13d1005f4cc Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Mon, 16 Nov 2026 23:19:20 +0000 Subject: [PATCH 2/5] fix: verify that dismissKeyboard hid the Android keyboard `dismissKeyboard` sent one KEYCODE_ESCAPE and returned, so it reported success while the keyboard could stay up. Now it reads `mInputShown` from `dumpsys input_method` first and sends no key when the keyboard is hidden. Otherwise it sends ESCAPE and polls for up to 1 s, then sends BACK once (while the keyboard is shown, BACK only hides it), and throws when the keyboard is still shown. --- src/backends/adb-backend.test.ts | 117 +++++++++++++++++++++++++++++++ src/backends/adb-backend.ts | 72 ++++++++++++++++++- src/tools/dismiss-keyboard.ts | 4 +- 3 files changed, 191 insertions(+), 2 deletions(-) diff --git a/src/backends/adb-backend.test.ts b/src/backends/adb-backend.test.ts index 5b1d6eb..4079c7c 100644 --- a/src/backends/adb-backend.test.ts +++ b/src/backends/adb-backend.test.ts @@ -783,6 +783,123 @@ describe('AdbBackend.typeText', () => { }); }); +describe('AdbBackend.dismissKeyboard', () => { + let backend: AdbBackend; + + const imeDump = (shown: boolean): string => + ` mServedInputConnection=null\n mInputShown=${String(shown)}\n mShowRequested=false\n`; + + const keyEvents = (): string[] => + mockExecStrict.mock.calls + .map(([, args]) => args ?? []) + .filter((args) => args.includes('keyevent')) + .map((args) => args[args.length - 1]); + + const dumpCount = (): number => + mockExecStrict.mock.calls.filter(([, args]) => + args?.includes('input_method'), + ).length; + + /** + * Fake device: the keyboard is shown until one of `hidesOn` keycodes is + * sent, then it hides after `lag` more `dumpsys` reads. + * + * @param options - The fake's behaviour. + * @param options.shown - Whether the keyboard is shown at the start. + * @param options.hidesOn - The keycodes that hide it. + * @param options.lag - Reads that still see it shown after the key. + * @param options.dump - Overrides the dump text. + */ + const fakeDevice = ({ + shown, + hidesOn = ['111', '4'], + lag = 0, + dump, + }: { + shown: boolean; + hidesOn?: string[]; + lag?: number; + dump?: string; + }): void => { + let isShown = shown; + let reads = -1; + mockExecStrict.mockImplementation(async (_cmd, args) => { + if (args?.includes('input_method')) { + if (reads >= 0) { + reads -= 1; + if (reads < 0) { + isShown = false; + } + } + return dump ?? imeDump(isShown); + } + const key = args?.[args.length - 1] ?? ''; + if (args?.includes('keyevent') && hidesOn.includes(key) && isShown) { + reads = lag; + } + return ''; + }); + }; + + beforeEach(() => { + vi.clearAllMocks(); + backend = new AdbBackend('emulator-5554'); + }); + + it('sends no key when the keyboard is not shown', async () => { + fakeDevice({ shown: false }); + + await backend.dismissKeyboard(); + + expect(keyEvents()).toStrictEqual([]); + expect(dumpCount()).toBe(1); + }); + + it('sends ESCAPE and checks that the keyboard hid', async () => { + fakeDevice({ shown: true }); + + await backend.dismissKeyboard(); + + expect(keyEvents()).toStrictEqual(['111']); + expect(dumpCount()).toBe(2); + }); + + it('polls until the keyboard hides after ESCAPE', async () => { + fakeDevice({ shown: true, lag: 3 }); + + await withoutRetryDelay(async () => backend.dismissKeyboard()); + + expect(keyEvents()).toStrictEqual(['111']); + expect(dumpCount()).toBe(5); + }); + + it('sends BACK once when ESCAPE does not hide the keyboard', async () => { + fakeDevice({ shown: true, hidesOn: ['4'] }); + + await withoutRetryDelay(async () => backend.dismissKeyboard()); + + expect(keyEvents()).toStrictEqual(['111', '4']); + }); + + it('throws when the keyboard stays shown after ESCAPE and BACK', async () => { + fakeDevice({ shown: true, hidesOn: [] }); + + await expect( + withoutRetryDelay(async () => backend.dismissKeyboard()), + ).rejects.toThrow('Keyboard still shown after ESCAPE and BACK'); + expect(keyEvents()).toStrictEqual(['111', '4']); + }); + + it('sends only ESCAPE when the keyboard state cannot be read', async () => { + fakeDevice({ shown: true, dump: 'Can not get service input_method' }); + + await backend.dismissKeyboard(); + + expect(keyEvents()).toStrictEqual(['111']); + expect(dumpCount()).toBe(1); + }); +}); + describe('AdbBackend.screenshot', () => { let backend: AdbBackend; diff --git a/src/backends/adb-backend.ts b/src/backends/adb-backend.ts index db17177..2dde8bf 100644 --- a/src/backends/adb-backend.ts +++ b/src/backends/adb-backend.ts @@ -111,6 +111,15 @@ const HELPER_RETRY_MIN_REMAINING_MS = 1_000; // A failed capture suggests a busy screen, where each dump can waste ~11 s. const HELPER_FIRST_FALLBACK_DUMP_ATTEMPTS = 1; +const KEYCODE_ESCAPE = '111'; + +const KEYCODE_BACK = '4'; + +// How long the keyboard may take to hide after each key. +const KEYBOARD_HIDE_TIMEOUT_MS = 1_000; + +const KEYBOARD_POLL_INTERVAL_MS = 100; + /** * - `helper-first`: helper, then dump on non-trust failures (default with APK). * - `auto`: quick dump, then helper; skip later quick dumps once the helper wins. @@ -827,8 +836,69 @@ export class AdbBackend implements DeviceBackend { await this.#adb(['shell', 'input', 'keyevent', keyMap[button]]); } + /** + * Hides the software keyboard, and does nothing when no keyboard is shown. + * Sends ESCAPE, then BACK once if the keyboard stays up (while the keyboard + * is shown, BACK only hides it), and checks the result after each key. + * + * @throws When the keyboard is still shown after ESCAPE and BACK. + */ async dismissKeyboard(): Promise { - await this.#adb(['shell', 'input', 'keyevent', '111']); + const shown = await this.#isKeyboardShown(); + if (shown === false) { + return; + } + await this.#adb(['shell', 'input', 'keyevent', KEYCODE_ESCAPE]); + if (shown === undefined) { + // The state can't be read, so BACK could navigate instead. + return; + } + if (await this.#waitForKeyboardHidden()) { + return; + } + // The last poll above is the check right before BACK. + await this.#adb(['shell', 'input', 'keyevent', KEYCODE_BACK]); + if (await this.#waitForKeyboardHidden()) { + return; + } + throw new Error( + 'Keyboard still shown after ESCAPE and BACK. ' + + 'Use device_snapshot to inspect the current UI hierarchy.', + ); + } + + /** + * Whether the input method (software keyboard) is shown, from + * `dumpsys input_method`. + * + * @returns The state, or `undefined` when the dump has no `mInputShown`. + */ + async #isKeyboardShown(): Promise { + const dump = await this.#adb(['shell', 'dumpsys', 'input_method']); + const match = dump.match(/\bmInputShown=(true|false)\b/u); + return match ? match[1] === 'true' : undefined; + } + + /** + * Polls until the keyboard is hidden. A state that can't be read counts as + * hidden, so BACK is never sent blind. + * + * @returns True once it is hidden; false when it is still shown after + * {@link KEYBOARD_HIDE_TIMEOUT_MS}. + */ + async #waitForKeyboardHidden(): Promise { + const deadline = Date.now() + KEYBOARD_HIDE_TIMEOUT_MS; + for (;;) { + if ((await this.#isKeyboardShown()) !== true) { + return true; + } + if (Date.now() + KEYBOARD_POLL_INTERVAL_MS > deadline) { + return false; + } + await new Promise((resolve) => { + setTimeout(resolve, KEYBOARD_POLL_INTERVAL_MS); + }); + } } async dismissAlert(accept: boolean): Promise { diff --git a/src/tools/dismiss-keyboard.ts b/src/tools/dismiss-keyboard.ts index a39fe10..fa11ae1 100644 --- a/src/tools/dismiss-keyboard.ts +++ b/src/tools/dismiss-keyboard.ts @@ -15,7 +15,9 @@ export function registerDismissKeyboardTool( 'Hide the on-screen keyboard. Call after typing to reveal elements ' + 'that may be obscured by the keyboard. On iOS this presses Return ' + 'when a keyboard is shown (which can submit a single-field form) ' + - 'and does nothing otherwise.', + 'and does nothing otherwise. On Android it does nothing when no ' + + 'keyboard is shown, and fails when the keyboard is still shown ' + + 'after ESCAPE and BACK.', inputSchema: {}, }, async () => { From 63f84ae318bfd17497f99cfefe6556cb8d48cd05 Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Tue, 17 Nov 2026 00:43:52 +0000 Subject: [PATCH 3/5] fix: select all with Ctrl+A before clearing an Android field On API 36 the Shift + MOVE_END selection selects nothing in a React Native text field, so the clear deleted one character: typing "abc" over "zzq" gave "zzabc", and an empty typeText left "zz". Also send Ctrl+A (`input keycombination`) before DEL. `keycombination` only exists on newer Android, so a failure there is ignored. --- src/backends/adb-backend.test.ts | 24 ++++++++++++++++++++++++ src/backends/adb-backend.ts | 15 ++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/backends/adb-backend.test.ts b/src/backends/adb-backend.test.ts index 4079c7c..d762acd 100644 --- a/src/backends/adb-backend.test.ts +++ b/src/backends/adb-backend.test.ts @@ -743,12 +743,36 @@ describe('AdbBackend.typeText', () => { const inputCalls = (): string[][] => mockExecStrict.mock.calls.map(([, args]) => (args ?? []).slice(3)); + const selectAllCalls = (): string[][] => + mockExec.mock.calls.map(([, args]) => (args ?? []).slice(3)); + beforeEach(() => { vi.clearAllMocks(); mockExecStrict.mockResolvedValue(''); + mockExec.mockResolvedValue({ stdout: '', stderr: '', exitCode: 0 }); backend = new AdbBackend('emulator-5554'); }); + it('also selects all with Ctrl+A before the delete', async () => { + await backend.typeText('abc'); + + expect(selectAllCalls()).toStrictEqual([ + ['input', 'keycombination', 'KEYCODE_CTRL_LEFT', 'KEYCODE_A'], + ]); + }); + + it('still clears and types when Ctrl+A is not supported', async () => { + mockExec.mockResolvedValue({ + stdout: '', + stderr: 'Error: Unknown command: keycombination', + exitCode: 255, + }); + + await backend.typeText('abc'); + + expect(inputCalls().at(-1)).toStrictEqual(['input', 'text', 'abc']); + }); + it('clears the field, then types the escaped text', async () => { await backend.typeText('a b&c'); diff --git a/src/backends/adb-backend.ts b/src/backends/adb-backend.ts index 2dde8bf..57f12d5 100644 --- a/src/backends/adb-backend.ts +++ b/src/backends/adb-backend.ts @@ -354,7 +354,8 @@ export class AdbBackend implements DeviceBackend { } async typeText(text: string): Promise { - // Android keyevent 29+shift = Ctrl+A (select all), 67 = DEL + // Select the text (Shift + MOVE_END from the start, then Ctrl+A), then + // delete it with DEL (67). await this.#adb(['shell', 'input', 'keyevent', 'KEYCODE_MOVE_HOME']); await this.#adb([ 'shell', @@ -364,6 +365,18 @@ export class AdbBackend implements DeviceBackend { 'KEYCODE_SHIFT_LEFT', 'KEYCODE_MOVE_END', ]); + // In a React Native field (API 36) the Shift selection selects nothing, + // so DEL removed one character. `keycombination` (newer Android only) is + // best effort: without it the clear is no worse than before. + await exec('adb', [ + '-s', + this.#serial, + 'shell', + 'input', + 'keycombination', + 'KEYCODE_CTRL_LEFT', + 'KEYCODE_A', + ]); await this.#adb(['shell', 'input', 'keyevent', '67']); // `input text` with no argument throws on the device, and the field is // already empty. From c2803384817d027ac3cb7d987fd7aec85f58313b Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Tue, 17 Nov 2026 01:38:22 +0000 Subject: [PATCH 4/5] fix: read only mInputShown and re-check it before BACK in dismissKeyboard Read the keyboard state with 'dumpsys input_method | grep -m1 mInputShown' instead of the ~1 MB dump, poll up to 2 s after ESCAPE, and re-read the state right before BACK so BACK is sent only while the keyboard is still shown. Document the remaining race and the unreadable-state path (ESCAPE only, as in 0.8.0). Assert that Ctrl+A is sent before DEL. --- src/backends/adb-backend.test.ts | 68 ++++++++++++++++++++++++++++---- src/backends/adb-backend.ts | 38 +++++++++++++----- 2 files changed, 88 insertions(+), 18 deletions(-) diff --git a/src/backends/adb-backend.test.ts b/src/backends/adb-backend.test.ts index d762acd..b28749b 100644 --- a/src/backends/adb-backend.test.ts +++ b/src/backends/adb-backend.test.ts @@ -761,6 +761,19 @@ describe('AdbBackend.typeText', () => { ]); }); + it('sends Ctrl+A before the DEL', async () => { + await backend.typeText('abc'); + + const delIndex = inputCalls().findIndex( + (args) => args.join(' ') === 'input keyevent 67', + ); + const [selectAllOrder] = mockExec.mock.invocationCallOrder; + const delOrder = mockExecStrict.mock.invocationCallOrder[delIndex]; + expect(selectAllOrder).toBeDefined(); + expect(delOrder).toBeDefined(); + expect(selectAllOrder).toBeLessThan(delOrder); + }); + it('still clears and types when Ctrl+A is not supported', async () => { mockExec.mockResolvedValue({ stdout: '', @@ -810,8 +823,15 @@ describe('AdbBackend.typeText', () => { describe('AdbBackend.dismissKeyboard', () => { let backend: AdbBackend; - const imeDump = (shown: boolean): string => - ` mServedInputConnection=null\n mInputShown=${String(shown)}\n mShowRequested=false\n`; + // `grep -m1 mInputShown` prints only this line. + const imeLine = (shown: boolean): string => + ` mInputShown=${String(shown)}\n`; + + const isStateRead = (args?: string[]): boolean => + args?.some((arg) => arg.includes('input_method')) ?? false; + + // Polls in the 2 s window after a key: at 0, 100, …, 2000 ms. + const POLL_READS = 21; const keyEvents = (): string[] => mockExecStrict.mock.calls @@ -820,9 +840,7 @@ describe('AdbBackend.dismissKeyboard', () => { .map((args) => args[args.length - 1]); const dumpCount = (): number => - mockExecStrict.mock.calls.filter(([, args]) => - args?.includes('input_method'), - ).length; + mockExecStrict.mock.calls.filter(([, args]) => isStateRead(args)).length; /** * Fake device: the keyboard is shown until one of `hidesOn` keycodes is @@ -848,14 +866,14 @@ describe('AdbBackend.dismissKeyboard', () => { let isShown = shown; let reads = -1; mockExecStrict.mockImplementation(async (_cmd, args) => { - if (args?.includes('input_method')) { + if (isStateRead(args)) { if (reads >= 0) { reads -= 1; if (reads < 0) { isShown = false; } } - return dump ?? imeDump(isShown); + return dump ?? imeLine(isShown); } const key = args?.[args.length - 1] ?? ''; if (args?.includes('keyevent') && hidesOn.includes(key) && isShown) { @@ -879,6 +897,19 @@ describe('AdbBackend.dismissKeyboard', () => { expect(dumpCount()).toBe(1); }); + it('reads only the mInputShown line of the input method dump', async () => { + fakeDevice({ shown: false }); + + await backend.dismissKeyboard(); + + expect(mockExecStrict).toHaveBeenCalledWith('adb', [ + '-s', + 'emulator-5554', + 'shell', + 'dumpsys input_method | grep -m1 mInputShown || true', + ]); + }); + it('sends ESCAPE and checks that the keyboard hid', async () => { fakeDevice({ shown: true }); @@ -903,6 +934,26 @@ describe('AdbBackend.dismissKeyboard', () => { await withoutRetryDelay(async () => backend.dismissKeyboard()); expect(keyEvents()).toStrictEqual(['111', '4']); + // The first read, the polls after ESCAPE, the read right before BACK and + // the first poll after BACK. + expect(dumpCount()).toBe(1 + POLL_READS + 1 + 1); + }); + + it('waits up to 2 s for ESCAPE to hide the keyboard', async () => { + fakeDevice({ shown: true, lag: POLL_READS - 1 }); + + await withoutRetryDelay(async () => backend.dismissKeyboard()); + + expect(keyEvents()).toStrictEqual(['111']); + }); + + it('skips BACK when the read right before it sees the keyboard hidden', async () => { + fakeDevice({ shown: true, hidesOn: ['111'], lag: POLL_READS }); + + await withoutRetryDelay(async () => backend.dismissKeyboard()); + + expect(keyEvents()).toStrictEqual(['111']); + expect(dumpCount()).toBe(1 + POLL_READS + 1); }); it('throws when the keyboard stays shown after ESCAPE and BACK', async () => { @@ -915,7 +966,8 @@ describe('AdbBackend.dismissKeyboard', () => { }); it('sends only ESCAPE when the keyboard state cannot be read', async () => { - fakeDevice({ shown: true, dump: 'Can not get service input_method' }); + // grep prints nothing, for example when the service can't be dumped. + fakeDevice({ shown: true, dump: '' }); await backend.dismissKeyboard(); diff --git a/src/backends/adb-backend.ts b/src/backends/adb-backend.ts index 57f12d5..ab2dda0 100644 --- a/src/backends/adb-backend.ts +++ b/src/backends/adb-backend.ts @@ -116,10 +116,15 @@ const KEYCODE_ESCAPE = '111'; const KEYCODE_BACK = '4'; // How long the keyboard may take to hide after each key. -const KEYBOARD_HIDE_TIMEOUT_MS = 1_000; +const KEYBOARD_HIDE_TIMEOUT_MS = 2_000; const KEYBOARD_POLL_INTERVAL_MS = 100; +// Reads only the `mInputShown` line: the full dump is ~1 MB. `|| true` keeps a +// missing line from failing the command, so that state reads as unknown. +const KEYBOARD_STATE_COMMAND = + 'dumpsys input_method | grep -m1 mInputShown || true'; + /** * - `helper-first`: helper, then dump on non-trust failures (default with APK). * - `auto`: quick dump, then helper; skip later quick dumps once the helper wins. @@ -851,8 +856,19 @@ export class AdbBackend implements DeviceBackend { /** * Hides the software keyboard, and does nothing when no keyboard is shown. - * Sends ESCAPE, then BACK once if the keyboard stays up (while the keyboard - * is shown, BACK only hides it), and checks the result after each key. + * Sends ESCAPE and polls for up to {@link KEYBOARD_HIDE_TIMEOUT_MS} until the + * keyboard hides. If it is still shown, reads the state once more and sends + * BACK only when that read still sees the keyboard (while the keyboard is + * shown, BACK only hides it), then checks again. + * + * Remaining risk: if the keyboard hides between that last read and BACK + * (one adb round trip, tens of ms), BACK reaches the app and can navigate + * back. This needs ESCAPE to take more than the poll window to hide the + * keyboard and then finish within that gap. + * + * When the state can't be read (`mInputShown` is missing), this behaves + * like 0.8.0: it sends ESCAPE only and does not check the result, because + * BACK sent blind could navigate. * * @throws When the keyboard is still shown after ESCAPE and BACK. */ @@ -863,13 +879,15 @@ export class AdbBackend implements DeviceBackend { } await this.#adb(['shell', 'input', 'keyevent', KEYCODE_ESCAPE]); if (shown === undefined) { - // The state can't be read, so BACK could navigate instead. return; } if (await this.#waitForKeyboardHidden()) { return; } - // The last poll above is the check right before BACK. + // Keep the gap between the last read and BACK as small as possible. + if ((await this.#isKeyboardShown()) !== true) { + return; + } await this.#adb(['shell', 'input', 'keyevent', KEYCODE_BACK]); if (await this.#waitForKeyboardHidden()) { return; @@ -881,14 +899,14 @@ export class AdbBackend implements DeviceBackend { } /** - * Whether the input method (software keyboard) is shown, from - * `dumpsys input_method`. + * Whether the input method (software keyboard) is shown, from the + * `mInputShown` line of `dumpsys input_method`. * - * @returns The state, or `undefined` when the dump has no `mInputShown`. + * @returns The state, or `undefined` when there is no `mInputShown` line. */ async #isKeyboardShown(): Promise { - const dump = await this.#adb(['shell', 'dumpsys', 'input_method']); - const match = dump.match(/\bmInputShown=(true|false)\b/u); + const line = await this.#adb(['shell', KEYBOARD_STATE_COMMAND]); + const match = line.match(/\bmInputShown=(true|false)\b/u); return match ? match[1] === 'true' : undefined; } From 0ae604053b8957a57667450782e30b514c8f14e4 Mon Sep 17 00:00:00 2001 From: cryptotavares Date: Tue, 17 Nov 2026 08:40:08 +0000 Subject: [PATCH 5/5] refactor: drop no-op assertions from the Android typeText order test `expect(...).toBeDefined()` on the two call-order values only narrowed types that are already `number`, and the existing helper-trust test in this file asserts order the same way without them. The test still fails if either call is missing, through `toBeLessThan`. --- src/backends/adb-backend.test.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backends/adb-backend.test.ts b/src/backends/adb-backend.test.ts index b28749b..00b2d24 100644 --- a/src/backends/adb-backend.test.ts +++ b/src/backends/adb-backend.test.ts @@ -769,8 +769,6 @@ describe('AdbBackend.typeText', () => { ); const [selectAllOrder] = mockExec.mock.invocationCallOrder; const delOrder = mockExecStrict.mock.invocationCallOrder[delIndex]; - expect(selectAllOrder).toBeDefined(); - expect(delOrder).toBeDefined(); expect(selectAllOrder).toBeLessThan(delOrder); });