Skip to content

Commit 64f1511

Browse files
committed
fix: address iOS alert smoke review feedback
1 parent 93a95bf commit 64f1511

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

examples/test-app/src/screens/AutomationLabScreen.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export function AutomationLabScreen(props: {
8686

8787
function showAutomationAlert() {
8888
setAlertResult('opened');
89-
requestAnimationFrame(() => {
89+
setTimeout(() => {
90+
// The opened canary proves JS ran; the smoke step separately waits for native presentation.
9091
Alert.alert('Automation confirmation', 'Choose either result to update the visible canary.', [
9192
{
9293
style: 'cancel',

test/integration/ios-simulator-e2e/live-automation-scenario.ts

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import assert from 'node:assert/strict';
22
import fs from 'node:fs';
33
import path from 'node:path';
44

5+
import { DEFAULT_ALERT_TIMEOUT_MS } from '@agent-device/contracts/interaction';
6+
57
import { PUBLIC_COMMANDS } from '../../../src/command-catalog.ts';
68
import {
79
assertElementText,
@@ -13,6 +15,7 @@ import { clearStateLaunchUrlMaestroFlow } from './live-fixtures.ts';
1315
import { type LiveContext, runStep, verifyBehavior, verifyCommand } from './live-harness.ts';
1416

1517
const C = PUBLIC_COMMANDS;
18+
const ALERT_WAIT_TIMEOUT = String(DEFAULT_ALERT_TIMEOUT_MS);
1619
const FIXTURE_HOME_TITLE = 'Agent Device Tester';
1720
const AUTOMATION_DEEP_LINK =
1821
'agent-device-test-app:///automation?event=cold.start&payload=%7B%22source%22%3A%22deep-link%22%7D';
@@ -33,6 +36,22 @@ async function observeFixtureHome(context: LiveContext) {
3336
return snapshot;
3437
}
3538

39+
async function assertAutomationAlertTriggerVisible(context: LiveContext): Promise<void> {
40+
const visible = await runStep(context, 'assert automation-open-alert is visible', [
41+
'is',
42+
'visible',
43+
'id="automation-open-alert"',
44+
]);
45+
assert.equal(visible.json?.data?.pass, true, JSON.stringify(visible.json));
46+
}
47+
48+
async function openNativeAlert(context: LiveContext, step: string): Promise<void> {
49+
await assertAutomationAlertTriggerVisible(context);
50+
await runStep(context, step, ['click', 'id="automation-open-alert"']);
51+
// The canary proves JS ran and the state update is observable; alert wait proves native presentation.
52+
await assertWaitText(context, 'Alert result: opened');
53+
}
54+
3655
export async function assertAutomationInput(context: LiveContext): Promise<void> {
3756
const opened = await runStep(context, 'cold launch fixture', [
3857
'open',
@@ -153,15 +172,28 @@ export async function assertAutomationInput(context: LiveContext): Promise<void>
153172
'id="automation-open-alert"',
154173
'Open automation alert',
155174
);
156-
await runStep(context, 'open native alert', ['click', 'id="automation-open-alert"']);
157-
await assertWaitText(context, 'Alert result: opened');
158-
const alert = await runStep(context, 'wait for native alert', ['alert', 'wait', '10000']);
175+
await openNativeAlert(context, 'open native alert');
176+
const alert = await runStep(context, 'wait for native alert', [
177+
'alert',
178+
'wait',
179+
ALERT_WAIT_TIMEOUT,
180+
]);
159181
assertJsonContains(alert, 'Automation confirmation', 'alert wait should return fixture alert');
160182
await runStep(context, 'inspect native alert', ['alert', 'get']);
161183
await runStep(context, 'dismiss native alert', ['alert', 'dismiss']);
162184
await assertWaitText(context, 'Alert result: cancelled');
163185

164-
await runStep(context, 'reopen native alert', ['click', 'id="automation-open-alert"']);
186+
await openNativeAlert(context, 'reopen native alert');
187+
const reopenedAlert = await runStep(context, 'wait for reopened native alert', [
188+
'alert',
189+
'wait',
190+
ALERT_WAIT_TIMEOUT,
191+
]);
192+
assertJsonContains(
193+
reopenedAlert,
194+
'Automation confirmation',
195+
'alert wait should return the reopened fixture alert',
196+
);
165197
await runStep(context, 'accept native alert', ['alert', 'accept']);
166198
await assertWaitText(context, 'Alert result: accepted');
167199
verifyCommand(context, C.alert, 'alert wait/get/dismiss/accept produce both fixture outcomes');

0 commit comments

Comments
 (0)