|
| 1 | +import { IOS_SYSTEM_SURFACE_HOSTS } from '@agent-device/contracts/ios-system-surface'; |
1 | 2 | import { beforeEach, expect, test, vi } from 'vitest'; |
2 | 3 | import type { AppleRunnerProvider, RunnerCommand } from '@agent-device/apple-runner'; |
3 | 4 | import type { CaptureSnapshotInput } from '@agent-device/contracts/snapshot-runtime'; |
@@ -38,7 +39,8 @@ type RunnerProcess = { pid: number; processStartTime: string }; |
38 | 39 | * foreground process, and `describe` reads it unless the host planned another process, or answers |
39 | 40 | * the refusal `refuseDescribe` names. A describe given `holdNextDescribe` reads until that promise |
40 | 41 | * settles, and, like the runner, it keeps reading after the daemon stops waiting: a describe that |
41 | | - * arrives meanwhile is refused as `bridge-read-in-flight`. |
| 42 | + * arrives meanwhile is refused as `bridge-read-in-flight`. A describe that names surface hosts is |
| 43 | + * refused as `system-surface-host-unverified`, as a sandbox that refuses the process table does. |
42 | 44 | */ |
43 | 45 | function bridgeRunner(state: { |
44 | 46 | process: RunnerProcess; |
@@ -84,6 +86,8 @@ function bridgeRunner(state: { |
84 | 86 | ) { |
85 | 87 | return refusal('stale_target', 'target-process-changed'); |
86 | 88 | } |
| 89 | + if (request.surfaceHostExecutables) |
| 90 | + return refusal('unsupported', 'system-surface-host-unverified'); |
87 | 91 | if (state.refuseDescribe) return refusal('application_not_responding', state.refuseDescribe); |
88 | 92 | if (reading) return refusal('application_not_responding', 'bridge-read-in-flight'); |
89 | 93 | const hold = state.holdNextDescribe; |
@@ -159,10 +163,7 @@ function bridgeRoute(provider: AppleRunnerProvider) { |
159 | 163 | isDiscoveryPending: () => false, |
160 | 164 | targetFreshness: 'cached', |
161 | 165 | }, |
162 | | - { |
163 | | - systemSurfacePresent: async () => 'unknown', |
164 | | - systemSurfaceForeground: async () => 'background', |
165 | | - }, |
| 166 | + async () => 'background', |
166 | 167 | ); |
167 | 168 | const snapshot = (signal = new AbortController().signal) => |
168 | 169 | route.capture( |
@@ -408,20 +409,23 @@ test('the runner runtime reads a remote Simulator through the bridge once its fo |
408 | 409 | expect(verbs(sent)).toEqual(['target', 'describe']); |
409 | 410 | }); |
410 | 411 |
|
411 | | -test('a runner whose foreground read cannot answer sends the capture to XCTest without a bridge read', async () => { |
| 412 | +test('a runner whose foreground read cannot answer asks the bridge read to check the surface hosts', async () => { |
412 | 413 | const { provider, sent } = bridgeRunner({ |
413 | 414 | process: { pid: 41, processStartTime: '1700000000.000001' }, |
414 | 415 | }); |
415 | 416 | const { snapshot, fallbacks } = runtimeSnapshots(withHostStates(provider, undefined)); |
416 | 417 |
|
417 | 418 | const captured = await snapshot(); |
418 | 419 |
|
419 | | - // The host cannot read a remote Simulator's processes, so nothing else can prove absence. |
| 420 | + const describe = sent.find((command) => command.snapshotBridge?.verb === 'describe'); |
| 421 | + expect(describe?.snapshotBridge?.surfaceHostExecutables).toEqual( |
| 422 | + IOS_SYSTEM_SURFACE_HOSTS.map((host) => host.processExecutable), |
| 423 | + ); |
| 424 | + // The runner could not place a host process, so the capture goes to XCTest and says why. |
420 | 425 | expect(fallbacks).toHaveLength(1); |
421 | 426 | expect(captured.warnings).toEqual([ |
422 | | - 'Simulator AX snapshot unavailable (system-surface-probe-unavailable); used XCTest for an unverified app generation.', |
| 427 | + 'Simulator AX snapshot unavailable (system-surface-host-unverified); used XCTest for this app generation.', |
423 | 428 | ]); |
424 | | - expect(verbs(sent)).not.toContain('describe'); |
425 | 429 | }); |
426 | 430 |
|
427 | 431 | test('the foreground proof starts the runner when none is live, then reads only that session', async () => { |
|
0 commit comments