Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test/integration/ios-simulator-e2e-deep-link-confirmation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ const READABLE_TIMEOUT = result(1, {
details: { reason: WAIT_REASONS.deadlineExceeded, readableCaptures: 5, captureTruncated: true },
},
});
const READINESS_TIMEOUT = result(1, {
error: {
code: 'COMMAND_FAILED',
details: {
reason: WAIT_REASONS.readinessExhausted,
readinessPhase: 'target-discovery',
readableCaptures: 0,
},
},
});
const RUNNER_START_TIMEOUT = result(1, {
error: {
code: 'COMMAND_FAILED',
details: {
reason: WAIT_REASONS.readinessExhausted,
readinessPhase: 'runner-start',
readableCaptures: 0,
},
},
});
const OPEN_PROMPT = result(0, {
data: { message: 'Open in “Agent Device Tester”?', items: ['Cancel', 'Open'] },
});
Expand Down Expand Up @@ -79,6 +99,27 @@ test('a readable destination timeout still answers a real Open confirmation', as
]);
});

test('target discovery exhaustion still answers a deep-link confirmation', async () => {
const { device, log } = simulator([READINESS_TIMEOUT, LANDED]);

await answerDeepLinkConfirmation(device);

assert.deepEqual(log, [
'wait for the deep-link destination (1/5)',
'alert get',
'alert accept',
'wait for the deep-link destination (2/5)',
]);
});

test('runner startup exhaustion returns without probing for a deep-link confirmation', async () => {
const { device, log } = simulator([RUNNER_START_TIMEOUT]);

await answerDeepLinkConfirmation(device);

assert.deepEqual(log, ['wait for the deep-link destination (1/5)']);
});

test('a readable no-match that answers Open waits for the released launch', async () => {
const { device, log } = simulator([WRONG_ROUTE, LAUNCH_PENDING, LANDED]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function acceptDeepLinkConfirmationIfPresent(

/**
* A readable destination timeout can still leave the launch behind a system confirmation. Probe
* once per miss until it is answered; a truncated or stalled capture then gets another bounded
* once per miss until it is answered; interrupted readiness or capture then gets another bounded
* wait, while a readable wrong-route miss without a prompt goes to the caller's assertion.
*/
export async function answerDeepLinkConfirmation(
Expand All @@ -71,9 +71,12 @@ export async function answerDeepLinkConfirmation(
const reason = details?.reason;
const readableMiss =
reason === WAIT_REASONS.targetAbsent || reason === WAIT_REASONS.deadlineExceeded;
const interruptedCapture =
reason === WAIT_REASONS.captureStalled || reason === WAIT_REASONS.runnerRestartExhausted;
if (!launchPending && !readableMiss && !interruptedCapture) return;
const interruptedObservation =
reason === WAIT_REASONS.captureStalled ||
(reason === WAIT_REASONS.readinessExhausted &&
details?.readinessPhase === 'target-discovery') ||
reason === WAIT_REASONS.runnerRestartExhausted;
if (!launchPending && !readableMiss && !interruptedObservation) return;
if (!answered) answered = await acceptOpenConfirmation(device);
if (!answered && reason === WAIT_REASONS.targetAbsent) return;
}
Expand Down
Loading