fix(android-e2e): wait for the Home/Recents surface change before pixel assertions

Merged
TH
9d ago
+695-47

Summary

Closes #4710.

The Android emulator smoke scenario (smoke:automation-system) took one screenshot immediately after home and after app-switcher and asserted it differed from the previous surface. When the launcher or the Recents transition had not drawn yet, the capture still showed the previous surface, so the identical-image assertion failed intermittently on main and on unrelated PRs (e.g. #4297).

assertHomeAndRecentsRestoration now waits at that observation seam with the bounded waitForSurfaceChange helper (test/integration/android-emulator-e2e/live-surface-transition.ts, same contract as the existing waitForImeWindow): re-capture every 250 ms until the screenshot differs from the baseline, within a 10 s deadline. Each attempt removes and overwrites the artifact, so the final observed image is kept and a failed capture cannot leave a stale one; the default capture is bounded by the remaining deadline (5 s per-attempt cap, failure evidence deferred to the deadline verdict); a capture resolving after the deadline is rejected as late. The Home foreground-package proof and both assertFilesDiffer pixel comparisons are retained unchanged; the wait fails at the deadline if navigation never produces the change. No fixed blanket sleep, no smoke-test retry, no weakened assertion, no production change, no workflow/runner change (#4712 untouched).

Regression coverage runs the lane through the harness entry: createAndroidLiveHarness({ runCli }) (the harness-owned runner injection) + createAndroidLiveAssertions(harness) + createHomeAndRecentsRestorationScenario(steps) executed via runScenario, with a scripted CLI double that observes and enforces the forwarded capture timeout. Tests cover: delayed Home/Recents captures passing only via the wait (single-capture route fails them), timeout negatives at the 10 s deadline, wedged captures cut at the forwarded remaining timeout (removing the timeoutMs from the default capture fails these tests — verified by mutant), and late-observation rejection.

Validation

  • Final head: 55f5b877e31a676107f47d5457d2d5179a317b83 after pnpm install --frozen-lockfile && pnpm build. pnpm check:affected --run --head 55f5b877e31a676107f47d5457d2d5179a317b83 (receipt .tmp/validation/run-S084nc, exactCommit=true): format, lint, typecheck, fallow, layering, di-seams, build, package, integration-node, macos-coverage, vitest-related all passed; unit passed 20613/20627 with only known host-load 5 s-timeout flakes in scripts/__tests__/release-publish.test.ts / test/repo-guards/release-assets.test.ts (pass solo; same failures on unchanged origin/main under the same host load). Focused: 27/27 across the four android-emulator-e2e suites (9 new tests), live-device-e2e-runtime 14/14; pnpm typecheck, pnpm format, oxlint, fallow audit clean.
  • Hosted Android validation: workflow run 44406428798 at head_sha 55f5b877e31a676107f47d5457d2d5179a317b83 — the Smoke Tests job passed on the initial run plus ten consecutive reruns at the unchanged head (11 executions, all success; job attempts 135162841640, 135166033700, 135169807283, 135173730913, 135177643973, 135180726313, 135184007531, 135187535422, 135190285281, 135193942664, 135197493388). Per-attempt logs + android-artifacts retained (/tmp/ad-smoke-55f5b877/01..11): each shows ✔ live Android emulator fixture E2E pass 1/fail 0, step-history capture Android Home surface (attempt N) and capture Android Recents surface (attempt N) status 0 (both transition waits passed their pixel comparisons; three distinct PNG md5s per attempt), and home-recents-restoration in coverage-report.json (fixture restoration). This satisfies #4710's ten-consecutive-passes criterion at the final head.