| 22 | } from '../../snapshot/snapshot-quality.ts'; |
| 23 | |
| 24 | export function createAppleInteractor( |
| 25 | device: DeviceInfo, |
| 26 | runnerContext: RunnerContext, |
| 27 | ): Interactor { |
| 28 | // watchOS unsupported sentinel: XCUITest cannot drive watchOS UI (no |
| 29 | // XCUIApplication), so a watchOS device has no runner backend. Reject it |
| 30 | // explicitly here rather than letting `appleOs: 'watchos'` silently fall |
| 31 | // through to the iOS runner profile (see resolveRunnerPlatformNameForAppleOs). |
| 32 | if (device.appleOs === 'watchos') { |
| 33 | throw new AppError( |
| 34 | 'UNSUPPORTED_PLATFORM', |
| 35 | 'watchOS is not supported: XCUITest cannot drive watchOS UI, so this device has no runner backend.', |
| 36 | ); |
| 37 | } |
| 38 | const { overrides, runnerOpts } = iosRunnerOverrides(device, runnerContext); |
| 39 | return { |
| 40 | open: (app, options) => |
| 41 | openIosApp(device, app, { |
| 42 | appBundleId: options?.appBundleId, |
| 43 | launchConsole: options?.launchConsole, |
| 44 | launchArgs: options?.launchArgs, |
| 45 | terminateRunningApp: options?.terminateRunningApp, |
| 46 | url: options?.url, |
| 47 | }), |
| 48 | openDevice: () => openIosDevice(device), |
| 49 | close: (app) => closeIosApp(device, app), |
| 50 | screenshot: async (outPath, options) => { |
| 51 | if (isMacOs(device) && options?.surface && options.surface !== 'app') { |
| 52 | await runMacOsScreenshotAction(outPath, { |
| 53 | surface: options.surface, |
| 54 | fullscreen: options.fullscreen, |
| 55 | }); |
| 56 | return; |
| 57 | } |
| 58 | await screenshotIos(device, outPath, { |
| 59 | appBundleId: options?.appBundleId, |
| 60 | fullscreen: options?.fullscreen, |
| 61 | runnerOptions: runnerOpts, |
| 62 | normalizeStatusBar: options?.normalizeStatusBar, |
| 63 | skipIosSimulatorBootCheck: options?.skipIosSimulatorBootCheck, |
| 64 | }); |
| 65 | }, |
| 66 | snapshot: async (options) => { |
| 67 | const result = readAppleSnapshotResult( |
| 68 | await withDiagnosticTimer( |
| 69 | 'snapshot_capture', |
| 70 | async () => |
| 71 | await runAppleRunnerCommand( |
| 72 | device, |
| 73 | { |
| 74 | command: 'snapshot', |
| 75 | appBundleId: options?.appBundleId, |
| 76 | interactiveOnly: options?.interactiveOnly, |
| 77 | depth: options?.depth, |
| 78 | scope: options?.scope, |
| 79 | raw: options?.raw, |
| 80 | }, |
| 81 | runnerOpts, |