Skip to content

Commit f008951

Browse files
committed
refactor(ios): let the observation policy own the pinned runner options
1 parent 01be1a3 commit f008951

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎packages/platform-apple/src/interactor.ts‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { appleRemotePressCommand } from './os/tvos/remote.ts';
77
import { runMacOsScreenshotAction } from './os/macos/helper.ts';
88
import { actOnAppleAlert, awaitAppleAlert, readAppleAlert } from './alert.ts';
99
import { runAppleRunnerCommand } from './core/runner-client.ts';
10+
import type { AppleRunnerCommandOptions } from './runner/runner-provider.ts';
1011
import {
1112
withAppleRunnerProvider,
1213
type AppleRunnerCommandExecutor,
@@ -246,13 +247,7 @@ async function captureAppleRunnerSnapshot(
246247
options: SnapshotOptions | undefined,
247248
runnerOpts: RunnerCallOptions,
248249
) {
249-
const { expectedRunnerSessionId, ...observationPolicy } = await snapshotObservationPolicy(
250-
device,
251-
options,
252-
runnerOpts,
253-
);
254-
const captureRunnerOpts =
255-
expectedRunnerSessionId === undefined ? runnerOpts : { ...runnerOpts, expectedRunnerSessionId };
250+
const observationPolicy = await snapshotObservationPolicy(device, options, runnerOpts);
256251
const result = readAppleSnapshotResult(
257252
await withDiagnosticTimer(
258253
'snapshot_capture',
@@ -265,12 +260,12 @@ async function captureAppleRunnerSnapshot(
265260
interactiveOnly: options?.interactiveOnly,
266261
preferredBackend: options?.preferredBackend,
267262
customActions: options?.customActions,
268-
...observationPolicy,
263+
...observationPolicy.request,
269264
depth: options?.depth,
270265
scope: options?.scope,
271266
raw: options?.raw,
272267
},
273-
mergeRunnerCallSignal(captureRunnerOpts, options?.signal),
268+
mergeRunnerCallSignal(observationPolicy.runnerOpts, options?.signal),
274269
),
275270
{ backend: 'xctest' },
276271
),
@@ -298,8 +293,11 @@ async function snapshotObservationPolicy(
298293
device: DeviceInfo,
299294
options: SnapshotOptions | undefined,
300295
runnerOpts: RunnerCallOptions,
301-
): Promise<{ observeOnly?: true; expectedRunnerSessionId?: string }> {
302-
if (options?.observeOnly !== true) return {};
296+
): Promise<{
297+
request: { observeOnly?: true };
298+
runnerOpts: RunnerCallOptions & Pick<AppleRunnerCommandOptions, 'expectedRunnerSessionId'>;
299+
}> {
300+
if (options?.observeOnly !== true) return { request: {}, runnerOpts };
303301
const capabilities = await runAppleRunnerCommand(
304302
device,
305303
{ command: 'uptime', observeOnly: true },
@@ -315,7 +313,10 @@ async function snapshotObservationPolicy(
315313
dispatched: 'no',
316314
});
317315
}
318-
return { observeOnly: true, expectedRunnerSessionId: capabilities.runnerSessionId };
316+
return {
317+
request: { observeOnly: true },
318+
runnerOpts: { ...runnerOpts, expectedRunnerSessionId: capabilities.runnerSessionId },
319+
};
319320
}
320321

321322
function assertSnapshotObservationResponse(

0 commit comments

Comments
 (0)