Skip to content

Commit 86759f1

Browse files
committed
test(ios): stabilize permission prompt lifecycle
1 parent 2cd3b7a commit 86759f1

2 files changed

Lines changed: 37 additions & 28 deletions

File tree

‎test/integration/ios-simulator-e2e/live-full-scenarios.ts‎

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,13 @@ export async function assertLifecycleAndSystem(context: LiveContext): Promise<vo
4343
);
4444
verifyCommand(context, C.triggerAppEvent, 'deep event name and JSON payload render exactly');
4545

46-
await runStep(context, 'reset microphone permission before prompt recovery', [
47-
'settings',
48-
'permission',
49-
'reset',
50-
'microphone',
51-
]);
46+
await resetMicrophonePermissionAndRestart(context, 'initial');
5247
await clickMicrophonePermission(context, 'request microphone permission for denial');
5348
await runStep(context, 'wait for microphone permission prompt', ['alert', 'wait', '5000']);
5449
await runStep(context, 'deny microphone permission prompt', ['alert', 'dismiss']);
5550
await assertElementText(context, 'id="automation-microphone-permission"', 'denied');
5651

57-
await runStep(context, 'reset denied microphone permission', [
58-
'settings',
59-
'permission',
60-
'reset',
61-
'microphone',
62-
]);
63-
await runStep(context, 'restart fixture after permission reset', [
64-
'open',
65-
context.appId,
66-
'--relaunch',
67-
]);
68-
await runStep(context, 'restore automation route after permission reset', [
69-
'trigger-app-event',
70-
'fixture.permission.recovery',
71-
'{"source":"permission-reset"}',
72-
]);
73-
await assertWaitText(context, 'Automation lab');
74-
await assertElementText(context, 'id="automation-microphone-permission"', 'not-requested');
52+
await resetMicrophonePermissionAndRestart(context, 'recovery');
7553
await clickMicrophonePermission(context, 'request microphone permission after reset');
7654
await runStep(context, 'wait for recovered microphone permission prompt', [
7755
'alert',
@@ -168,6 +146,30 @@ export async function assertLifecycleAndSystem(context: LiveContext): Promise<vo
168146
await assertWaitText(context, 'Automation lab');
169147
}
170148

149+
async function resetMicrophonePermissionAndRestart(
150+
context: LiveContext,
151+
phase: 'initial' | 'recovery',
152+
): Promise<void> {
153+
await runStep(context, `reset microphone permission for ${phase} prompt`, [
154+
'settings',
155+
'permission',
156+
'reset',
157+
'microphone',
158+
]);
159+
await runStep(context, `restart fixture after ${phase} permission reset`, [
160+
'open',
161+
context.appId,
162+
'--relaunch',
163+
]);
164+
await runStep(context, `restore automation route after ${phase} permission reset`, [
165+
'trigger-app-event',
166+
`fixture.permission.${phase}`,
167+
`{"source":"permission-${phase}"}`,
168+
]);
169+
await assertWaitText(context, 'Automation lab');
170+
await assertElementText(context, 'id="automation-microphone-permission"', 'not-requested');
171+
}
172+
171173
async function clickMicrophonePermission(context: LiveContext, step: string): Promise<void> {
172174
for (let attempt = 0; attempt < 4; attempt += 1) {
173175
const clicked = await runStep(

‎test/integration/ios-simulator-e2e/live-harness.ts‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,17 @@ export async function cleanupSession(context: LiveContext): Promise<void> {
157157
}
158158
cleanupSteps.push(['close fixture session', ['close']]);
159159
for (const [step, args] of cleanupSteps) {
160-
try {
161-
await runStep(context, `cleanup: ${step}`, args);
162-
} catch (error) {
163-
failures.push(error);
160+
for (let attempt = 1; attempt <= 3; attempt += 1) {
161+
try {
162+
const result = await runStep(context, `cleanup: ${step} (attempt ${attempt})`, args, {
163+
allowFailure: attempt < 3,
164+
});
165+
if (result.status === 0) break;
166+
await new Promise((resolve) => setTimeout(resolve, 500));
167+
} catch (error) {
168+
failures.push(error);
169+
break;
170+
}
164171
}
165172
}
166173
if (failures.length === 0) return;

0 commit comments

Comments
 (0)