Skip to content

Commit 9b3995e

Browse files
committed
test(ios-smoke): wait once more when the runner is still starting behind a deep link
A relaunch can restart the runner, and on a loaded CI Mac its start outlasts the first 15 s destination wait. That wait ends in runner-start readiness exhaustion, which returned without probing, so iOS's 'Open in Agent Device Tester?' confirmation stayed unanswered and the caller's wait failed on APP_NOT_RUNNING. One more wait lets the started runner see the pending launch and the helper answer it; a second runner-start timeout still returns. The miss classification moves into its own function.
1 parent 1df5a7a commit 9b3995e

2 files changed

Lines changed: 65 additions & 15 deletions

File tree

‎test/integration/ios-simulator-e2e-deep-link-confirmation.test.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,29 @@ test('target discovery exhaustion still answers a deep-link confirmation', async
112112
]);
113113
});
114114

115-
test('runner startup exhaustion returns without probing for a deep-link confirmation', async () => {
116-
const { device, log } = simulator([RUNNER_START_TIMEOUT]);
115+
test('runner startup exhaustion waits once more, then answers the confirmation the runner sees', async () => {
116+
const { device, log } = simulator([RUNNER_START_TIMEOUT, LAUNCH_PENDING, LANDED]);
117117

118118
await answerDeepLinkConfirmation(device);
119119

120-
assert.deepEqual(log, ['wait for the deep-link destination (1/5)']);
120+
assert.deepEqual(log, [
121+
'wait for the deep-link destination (1/5)',
122+
'wait for the deep-link destination (2/5)',
123+
'alert get',
124+
'alert accept',
125+
'wait for the deep-link destination (3/5)',
126+
]);
127+
});
128+
129+
test('a second runner startup exhaustion returns without probing for a deep-link confirmation', async () => {
130+
const { device, log } = simulator([RUNNER_START_TIMEOUT, RUNNER_START_TIMEOUT]);
131+
132+
await answerDeepLinkConfirmation(device);
133+
134+
assert.deepEqual(log, [
135+
'wait for the deep-link destination (1/5)',
136+
'wait for the deep-link destination (2/5)',
137+
]);
121138
});
122139

123140
test('a readable no-match that answers Open waits for the released launch', async () => {

‎test/integration/ios-simulator-e2e/live-deep-link-confirmation.ts‎

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,60 @@ export async function answerDeepLinkConfirmation(
6161
device: DeepLinkConfirmationDevice,
6262
): Promise<void> {
6363
let answered = false;
64+
let runnerStartWaited = false;
6465
for (let wait = 1; wait <= DESTINATION_WAITS; wait += 1) {
6566
const arrived = await device.waitForDestination(
6667
`wait for the deep-link destination (${wait}/${DESTINATION_WAITS})`,
6768
);
6869
if (arrived.status === 0) return;
69-
const details = arrived.json?.error?.details;
70-
const launchPending = details?.runnerErrorCode === APP_NOT_RUNNING;
71-
const reason = details?.reason;
72-
const readableMiss =
73-
reason === WAIT_REASONS.targetAbsent || reason === WAIT_REASONS.deadlineExceeded;
74-
const interruptedObservation =
75-
reason === WAIT_REASONS.captureStalled ||
76-
(reason === WAIT_REASONS.readinessExhausted &&
77-
details?.readinessPhase === 'target-discovery') ||
78-
reason === WAIT_REASONS.runnerRestartExhausted;
79-
if (!launchPending && !readableMiss && !interruptedObservation) return;
70+
const miss = classifyDestinationMiss(arrived.json?.error?.details);
71+
// A relaunch can restart the runner, and on a loaded host its start outlasts one wait; the
72+
// next wait is the first that can see the confirmation. A second start timeout is a failure.
73+
if (miss === 'runner-start' && !runnerStartWaited) {
74+
runnerStartWaited = true;
75+
continue;
76+
}
77+
if (miss === 'final' || miss === 'runner-start') return;
8078
if (!answered) answered = await acceptOpenConfirmation(device);
81-
if (!answered && reason === WAIT_REASONS.targetAbsent) return;
79+
if (!answered && miss === 'target-absent') return;
8280
}
8381
}
8482

83+
/** Why a destination wait missed, as far as the confirmation loop acts on it. */
84+
type DestinationMiss = 'probe' | 'target-absent' | 'runner-start' | 'final';
85+
86+
type DestinationMissDetails = {
87+
reason?: string;
88+
readinessPhase?: string;
89+
runnerErrorCode?: string;
90+
};
91+
92+
/** Wait failures that can leave the launch behind the confirmation: worth one `alert get`. */
93+
const PROBE_REASONS: ReadonlySet<string | undefined> = new Set([
94+
WAIT_REASONS.deadlineExceeded,
95+
WAIT_REASONS.captureStalled,
96+
WAIT_REASONS.runnerRestartExhausted,
97+
]);
98+
99+
/**
100+
* Sorts a destination wait's failure: a pending launch, a readable miss, or an interrupted
101+
* observation may hide the confirmation (`probe`, or `target-absent` for a readable no-match);
102+
* a runner still starting saw nothing yet; anything else is the caller's to assert.
103+
*/
104+
function classifyDestinationMiss(details: DestinationMissDetails | undefined): DestinationMiss {
105+
const readinessPhase = readinessExhaustedPhase(details);
106+
if (readinessPhase === 'runner-start') return 'runner-start';
107+
if (details?.reason === WAIT_REASONS.targetAbsent) return 'target-absent';
108+
if (details?.runnerErrorCode === APP_NOT_RUNNING) return 'probe';
109+
if (PROBE_REASONS.has(details?.reason) || readinessPhase === 'target-discovery') return 'probe';
110+
return 'final';
111+
}
112+
113+
/** The readiness phase a wait ran out of time in, when readiness is what it exhausted. */
114+
function readinessExhaustedPhase(details: DestinationMissDetails | undefined): string | undefined {
115+
return details?.reason === WAIT_REASONS.readinessExhausted ? details.readinessPhase : undefined;
116+
}
117+
85118
async function acceptOpenConfirmation(device: DeepLinkConfirmationDevice): Promise<boolean> {
86119
const alert = await device.inspectAlert();
87120
if (alert.status !== 0) return false;

0 commit comments

Comments
 (0)