From 6211bfc3f15789fbb8cf5fd5907d399a7dd58d54 Mon Sep 17 00:00:00 2001 From: Thiago Brezinski Date: Sun, 6 Sep 2026 22:32:31 +0100 Subject: [PATCH] test(android): reveal smoke canaries by visibility --- .../android-emulator-e2e/live-assertions.ts | 31 +++++++++++++++++++ .../live-automation-scenario.ts | 11 +++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/test/integration/android-emulator-e2e/live-assertions.ts b/test/integration/android-emulator-e2e/live-assertions.ts index cb6ff84bc2..0e8cd19464 100644 --- a/test/integration/android-emulator-e2e/live-assertions.ts +++ b/test/integration/android-emulator-e2e/live-assertions.ts @@ -22,6 +22,37 @@ export const { assertElementText, assertWaitSelector, assertWaitText, capturePng PUBLIC_COMMANDS.wait, ); +export async function scrollToVisibleSelector( + context: LiveContext, + selector: string, +): Promise { + for (let attempt = 0; attempt < 6; attempt += 1) { + const result = await runStep( + context, + `check ${selector} visibility (${attempt + 1})`, + ['is', 'visible', selector], + { allowFailure: true }, + ); + if (result.status === 0) { + assert.equal(result.json?.data?.pass, true, JSON.stringify(result.json)); + return; + } + const reason = result.json?.error?.details?.reason; + assert.ok( + reason === 'selector_not_found' || reason === 'predicate_failed', + `could not observe ${selector}: ${JSON.stringify(result.json)}`, + ); + if (attempt < 5) { + await runStep(context, `scroll toward ${selector} (${attempt + 1})`, [ + 'scroll', + 'down', + '0.25', + ]); + } + } + assert.fail(`${selector} did not become visible after five scrolls`); +} + export function assertDiffLine( result: CliJsonResult, kind: SnapshotDiffLine['kind'], diff --git a/test/integration/android-emulator-e2e/live-automation-scenario.ts b/test/integration/android-emulator-e2e/live-automation-scenario.ts index 0dddb2824e..358e1630c9 100644 --- a/test/integration/android-emulator-e2e/live-automation-scenario.ts +++ b/test/integration/android-emulator-e2e/live-automation-scenario.ts @@ -12,6 +12,7 @@ import { assertWaitText, capturePng, requireAndroidResourceId, + scrollToVisibleSelector, } from './live-assertions.ts'; import { type LiveContext, runStep, verifyBehavior, verifyCommand } from './live-harness.ts'; @@ -126,19 +127,24 @@ export async function assertAutomationSystem(context: LiveContext): Promise