Skip to content

Commit 4fb9cb3

Browse files
committed
refactor(daemon): observe the boot probe at the services port in the open router suite
request-router-open pinned the reboot-stale claim answers by mocking the apple simulator-boot leaf, which the daemon no longer loads; both cases now arm observeBootTimeMsFixture, the port member the claim settlement actually asks.
1 parent ee0ac3a commit 4fb9cb3

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

‎src/daemon/__tests__/request-router-open.test.ts‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createTestDeviceInventoryGateways } from '@agent-device/device-selectio
22
import {
33
daemonPlatformServicesFixture,
44
daemonClaimRecoveryGatewayFixture,
5+
observeBootTimeMsFixture,
56
} from './platform-services-fixture.ts';
67
import { legacyDispatchCapture } from './legacy-snapshot-capture-fixture.ts';
78
import { test, expect, vi, beforeEach } from 'vitest';
@@ -61,16 +62,6 @@ vi.mock('@agent-device/platform-apple/app-resolution', async (importOriginal) =>
6162
resolveIosApp: vi.fn(async (_device, app) => app),
6263
};
6364
});
64-
// The reboot-stale claim probe (#2538) must never reach the host's real process table here.
65-
const mockObserveSimulatorBoot = vi.hoisted(() =>
66-
vi.fn(async (): Promise<DeviceBootObservation> => ({
67-
observed: false,
68-
reason: 'unobserved',
69-
})),
70-
);
71-
vi.mock('@agent-device/platform-apple/simulator-boot', () => ({
72-
observeSimulatorBootTimeMs: mockObserveSimulatorBoot,
73-
}));
7465

7566
import {
7667
createRequestHandler,
@@ -86,7 +77,6 @@ import {
8677
discoverReadyAndroidEmulators,
8778
} from './application-lifecycle-runtime-fixture.ts';
8879
import type { DeviceInfo } from '@agent-device/kernel/device';
89-
import type { DeviceBootObservation } from '@agent-device/contracts/device-boot';
9080
import { AppError } from '@agent-device/kernel/errors';
9181
import { makeSessionStore } from './support/store-factory.ts';
9282
import { inspectDeviceClaims } from '../device/device-claim-inspection.ts';
@@ -103,6 +93,7 @@ const mockEnsureDeviceReady = vi.mocked(ensureDeviceReady);
10393
// The open path reaches readiness through its admitted package binding, so router-level
10494
// serialization is observed at the fixture's emulator-discovery seam.
10595
const mockDiscoverReadyAndroidEmulators = vi.mocked(discoverReadyAndroidEmulators);
96+
const mockObserveBoot = vi.mocked(observeBootTimeMsFixture);
10697
const mockAwaitFixtureReadiness = vi.mocked(awaitFixtureReadiness);
10798

10899
function createOpenHandler(
@@ -130,11 +121,8 @@ beforeEach(() => {
130121
mockAwaitFixtureReadiness.mockReset();
131122
mockAwaitFixtureReadiness.mockResolvedValue(undefined);
132123
mockDiscoverReadyAndroidEmulators.mockReset();
133-
mockObserveSimulatorBoot.mockReset();
134-
mockObserveSimulatorBoot.mockImplementation(async () => ({
135-
observed: false,
136-
reason: 'unobserved',
137-
}));
124+
mockObserveBoot.mockReset();
125+
mockObserveBoot.mockResolvedValue({ observed: false, reason: 'unobserved' });
138126
mockDiscoverReadyAndroidEmulators.mockImplementation(async (device) => [
139127
{
140128
...device,
@@ -705,10 +693,10 @@ test('an open that booted the device keeps the device against a foreign open', a
705693
// during preparation arms it here and the fake device reports that boot to every later probe.
706694
let bootedAtMs: number | undefined;
707695
let bootArmed = false;
708-
mockObserveSimulatorBoot.mockImplementation(async () =>
696+
mockObserveBoot.mockImplementation(async () =>
709697
bootedAtMs === undefined
710-
? { observed: false, reason: 'unobserved' }
711-
: { observed: true, bootedAtMs },
698+
? ({ observed: false, reason: 'unobserved' } as const)
699+
: ({ observed: true, bootedAtMs } as const),
712700
);
713701
mockAwaitFixtureReadiness.mockImplementation(async () => {
714702
if (bootArmed) {

0 commit comments

Comments
 (0)