Skip to content

test: split the Android platform test aggregation and share the scripted adb stub#1103

Open
thymikee wants to merge 1 commit into
mainfrom
claude/android-test-split
Open

test: split the Android platform test aggregation and share the scripted adb stub#1103
thymikee wants to merge 1 commit into
mainfrom
claude/android-test-split

Conversation

@thymikee

@thymikee thymikee commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

Companion to #1102, for the Android offender AGENTS.md names directly ("platform index.test.ts … shrink opportunistically"). The 2,735-line src/platforms/android/__tests__/index.test.ts splits along its already well-factored source modules — every test moved verbatim, 92 tests before and after:

File Tests Mirrors
ui-hierarchy.test.ts 22 ui-hierarchy.ts
app-lifecycle-install.test.ts 13 app-lifecycle.ts (install/resolve/infer/component parsing)
app-lifecycle-open.test.ts 19 app-lifecycle.ts (open/close, deep links, launch args, TV, fallback resolve-activity)
input-actions.test.ts 11 input-actions.ts (type/fill/swipe/scroll/rotate)
settings.test.ts 14 settings.ts
notifications.test.ts / app-parsers.test.ts 2 / 1 notifications.ts / app-parsers.ts
appended to existing device-input-state.test.ts 10 device-input-state.ts (keyboard state/dismiss)

adb-mock consistency fix folded in: the monolith carried a local withMockedAdb fork because it needs scripted per-subcommand adb responses, which the shared arg-recorder helper can't express. That fork now lives in src/__tests__/test-utils/mocked-binaries.ts as withScriptedAdb, next to the recorder withMockedAdb, and hands each callback a fresh copy of the shared ANDROID_EMULATOR fixture (which the local fork had duplicated field-for-field).

The fresh copy is load-bearing, and the split caught a real latent hazard: the Android TV test mutated the callback's device (device.target = 'tv'). The old per-call object literal absorbed that silently; with a shared fixture the mutation leaked into the following test and flipped its launch to LEANBACK. The helper now clones per call and the TV test builds { ...device, target: 'tv' } instead of mutating.

Per the discussion: no new e2e scenario — the real-emulator Android workflow (settings replay + snapshot-helper smoke) stays the e2e layer, and these integration tests keep covering install/fill flows against scripted stubs.

Touched files: 10 (1 deleted, 7 created, device-input-state.test.ts extended, mocked-binaries.ts).

Validation

All 92 relocated tests pass in their new homes (including the previously-leaking LEANBACK/fallback pair, which now passes in both orderings), and the full suites are green: 349 test files / 3248 unit tests, smoke 13/13, check:quick (oxlint + tsgo) clean, fallow audit vs origin/main clean. Blocks were moved verbatim except the one withMockedAdbwithScriptedAdb rename and the TV-test mutation fix described above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FqeW8sA2ZnvnftdvpCqFMS


Generated by Claude Code

…ted adb stub

AGENTS.md names the platform index.test.ts aggregations as offenders to
shrink opportunistically; this splits the 2,735-line Android one along
its (already well-factored) source modules, every test moved verbatim
(92 tests before and after):

- ui-hierarchy.test.ts (22): parseUiHierarchy/androidUiNodes
- app-lifecycle-install.test.ts (13): install/resolve/infer/launch
  component parsing
- app-lifecycle-open.test.ts (19): open/close, deep links, launch args,
  TV category, fallback resolve-activity
- input-actions.test.ts (11): type/fill/swipe/scroll/rotate
- settings.test.ts (14): appearance/clear-app-state/fingerprint/
  permissions
- notifications.test.ts (2), app-parsers.test.ts (1)
- keyboard state/dismiss tests (10) appended to the existing
  device-input-state.test.ts

Consistency fix folded in: the file carried a local withMockedAdb fork
because it needs scripted per-subcommand adb responses, which the shared
arg-recorder helper cannot express. The fork now lives in
src/__tests__/test-utils/mocked-binaries.ts as withScriptedAdb next to
withMockedAdb, and hands each call a fresh copy of the shared
ANDROID_EMULATOR fixture.

The copy matters: the Android TV test mutated the callback's device
(device.target = 'tv'), which the old per-call object literal absorbed
silently. With a shared fixture that mutation leaked into the next test
and flipped its launch to LEANBACK. The helper now clones per call and
the TV test builds { ...device, target: 'tv' } instead of mutating.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FqeW8sA2ZnvnftdvpCqFMS
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.5 MB 1.5 MB 0 B
JS gzip 491.3 kB 491.3 kB 0 B
npm tarball 590.3 kB 590.3 kB 0 B
npm unpacked 2.1 MB 2.1 MB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.9 ms 27.0 ms +0.1 ms
CLI --help 51.2 ms 51.6 ms +0.4 ms

Top changed chunks: no changes in the largest emitted chunks.

@thymikee

thymikee commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

Blocking review finding: the split lets the scripted-adb tests run in parallel across files while they still mutate global process state (PATH and AGENT_DEVICE_TEST_ARGS_FILE). That makes the new files interfere with each other when run together.

Repro from the PR branch:

pnpm exec vitest run src/platforms/android/__tests__/app-lifecycle-install.test.ts src/platforms/android/__tests__/app-lifecycle-open.test.ts src/platforms/android/__tests__/app-parsers.test.ts src/platforms/android/__tests__/device-input-state.test.ts src/platforms/android/__tests__/input-actions.test.ts src/platforms/android/__tests__/notifications.test.ts src/platforms/android/__tests__/settings.test.ts src/platforms/android/__tests__/ui-hierarchy.test.ts

That run failed 10 tests with adb exit/timeouts. Running one of the failing files alone passes:

pnpm exec vitest run src/platforms/android/__tests__/app-lifecycle-open.test.ts

So the monolith split changed execution semantics: the old single file effectively serialized the env-mutating adb stubs, but the new file split allows concurrent mutation. Please make the scripted-adb helper/tests safe under Vitest's file parallelism, or explicitly serialize this group if that is the intended contract, then rerun the grouped command above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants