Skip to content

Commit a56adca

Browse files
committed
refactor(move): root-own the daemon composition tests
Relocate 34 tests that deliberately exercise the real root composition (real createDaemonRuntimeDeps boot, real platform-runtime gateway and provider resolvers, real command-surface/interactor/CLI-output code, real credential fingerprints) plus their private daemon-runtime-fixture into src/__tests__/daemon-composition/, preserving subtrees. Every relative specifier, vi.mock target, and source-reading URL/import.meta path is rebased to the new depth; content is otherwise unchanged except replay-coordinator-ownership's scan roots, which now also walk packages/daemon/src (tolerating its absence) so the guard keeps seeing the daemon after the package move.
1 parent 38d2569 commit a56adca

39 files changed

Lines changed: 235 additions & 204 deletions

File tree

‎packages/replay-port/src/daemon-port/native-command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { errorResponse, type DaemonResponse } from '@agent-device/kernel/contrac
4141
* loop returns and never touches the step runtime itself.
4242
*
4343
* Coordinator ownership is unchanged by this split: `createReplayCoordinator` is still called
44-
* here, and only here — see `src/daemon/__tests__/replay-coordinator-ownership.test.ts` — every
44+
* here, and only here — see `src/__tests__/daemon-composition/replay-coordinator-ownership.test.ts` — every
4545
* extracted module receives the already-constructed `ReplayCoordinator` as a parameter instead of
4646
* constructing its own.
4747
*/

‎src/__tests__/daemon-composition-assembly.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolu
66
import { WEB_DESKTOP_DEVICE } from '@agent-device/test-kit/device-fixtures';
77
import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir';
88
import { createDaemonRuntimeDeps } from '../daemon-composition.ts';
9-
import { startDaemonRuntimeFixture } from '../daemon/__tests__/daemon-runtime-fixture.ts';
9+
import { startDaemonRuntimeFixture } from './daemon-composition/daemon-runtime-fixture.ts';
1010
import type { DaemonRuntimeDepsInput } from '../daemon/server/daemon-runtime.ts';
1111

1212
// The server builds its own store, so capture that instance the same way the shutdown tests do:

src/daemon/__tests__/android-dialog-readiness.test.ts renamed to src/__tests__/daemon-composition/android-dialog-readiness.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => {
3232
};
3333
});
3434

35-
import { makeAndroidSession } from './support/session-factories.ts';
36-
import { withFakeAdb, type FakeAdbScript } from '../../__tests__/test-utils/fake-adb.ts';
35+
import { makeAndroidSession } from '../../daemon/__tests__/support/session-factories.ts';
36+
import { withFakeAdb, type FakeAdbScript } from '../test-utils/fake-adb.ts';
3737
import {
3838
countDiagnosticEventsByPhase,
3939
withDiagnosticsScope,
4040
} from '@agent-device/host-kit/diagnostics';
41-
import { ensureAndroidBlockingSystemDialogReady as ensureOwnedAndroidBlockingSystemDialogReady } from '../android-system-dialog.ts';
41+
import { ensureAndroidBlockingSystemDialogReady as ensureOwnedAndroidBlockingSystemDialogReady } from '../../daemon/android-system-dialog.ts';
4242
import { androidObservation } from '../../platform-runtime.ts';
4343

4444
const ensureAndroidBlockingSystemDialogReady = (

src/daemon/app-event-delivery.test.ts renamed to src/__tests__/daemon-composition/app-event-delivery.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { promises as fs } from 'node:fs';
44
import path from 'node:path';
55
import { bindAdmittedLocalInteractorOperations } from '@agent-device/contracts/interactor-operation-catalog';
66
import type { DeviceInfo } from '@agent-device/kernel/device';
7-
import { parseTriggerAppEventArgs, resolveAppEventUrl } from './app-events.ts';
8-
import { getInteractor } from '../core/interactors.ts';
7+
import { parseTriggerAppEventArgs, resolveAppEventUrl } from '../../daemon/app-events.ts';
8+
import { getInteractor } from '../../core/interactors.ts';
99
import { AppError } from '@agent-device/kernel/errors';
1010
import { ANDROID_EMULATOR, IOS_DEVICE, MACOS_DEVICE } from '@agent-device/test-kit/device-fixtures';
1111
import { mkdtempForTest } from '@agent-device/test-kit/tmp-dir';

src/daemon/__tests__/daemon-runtime-fixture.ts renamed to src/__tests__/daemon-composition/daemon-runtime-fixture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
startDaemonRuntime,
44
type ComposeDaemonRuntimeDeps,
55
type DaemonRuntimeController,
6-
} from '../server/daemon-runtime.ts';
6+
} from '../../daemon/server/daemon-runtime.ts';
77

88
type WritableOutput = { write: (chunk: string) => unknown };
99

src/daemon/__tests__/gesture-admission-parity.test.ts renamed to src/__tests__/daemon-composition/gesture-admission-parity.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { daemonPlatformServicesFixture } from './platform-services-fixture.ts';
1+
import { daemonPlatformServicesFixture } from '../../daemon/__tests__/platform-services-fixture.ts';
22
import { expect, test } from 'vitest';
33
import type {
44
GestureCommandInput,
@@ -10,9 +10,9 @@ import {
1010
} from '@agent-device/contracts/gesture-normalization';
1111
import type { DeviceInfo } from '@agent-device/kernel/device';
1212
import { createPlatformRuntimeGateway } from '../../platform-runtime.ts';
13-
import { createRequestRuntimeBindings } from '../request-runtime-binding.ts';
14-
import { createRequestDispatchLedger } from '../request-dispatch-ledger.ts';
15-
import { resolveBoundGestureRuntime } from '../gesture-runtime.ts';
13+
import { createRequestRuntimeBindings } from '../../daemon/request-runtime-binding.ts';
14+
import { createRequestDispatchLedger } from '../../daemon/request-dispatch-ledger.ts';
15+
import { resolveBoundGestureRuntime } from '../../daemon/gesture-runtime.ts';
1616

1717
/**
1818
* The parity artifact for R42/R44 (ADR 0019 §6).

src/daemon/handlers/__tests__/snapshot-alert-android-occlusion.test.ts renamed to src/__tests__/daemon-composition/handlers/snapshot-alert-android-occlusion.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ vi.mock('@agent-device/platform-android/mechanics', async (importOriginal) => {
1313
import { pressAndroid, snapshotAndroid } from '@agent-device/platform-android/mechanics';
1414
import { ANDROID_EMULATOR } from '@agent-device/test-kit/device-fixtures';
1515
import { createAndroidInteractor } from '../../../core/interactors/android.ts';
16-
import { makeAndroidSnapshotCapture } from '../../../__tests__/test-utils/android-snapshot-capture.ts';
16+
import { makeAndroidSnapshotCapture } from '../../test-utils/android-snapshot-capture.ts';
1717

1818
// R59 moved the alert legs onto the Android interactor, which is where the occlusion reading
1919
// they depend on lives: the legs capture through the same presentation pass `snapshot` publishes,

src/daemon/handlers/__tests__/snapshot-handler-freshness.test.ts renamed to src/__tests__/daemon-composition/handlers/snapshot-handler-freshness.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { daemonPlatformServicesFixture } from '../../__tests__/platform-services-fixture.ts';
1+
import { daemonPlatformServicesFixture } from '../../../daemon/__tests__/platform-services-fixture.ts';
22
import { test, expect, vi, afterEach, beforeEach } from 'vitest';
3-
import { legacyDispatchCapture } from '../../__tests__/legacy-snapshot-capture-fixture.ts';
4-
import { resetGetRuntimeFixture } from '../../__tests__/interaction-get-runtime-fixture.ts';
3+
import { legacyDispatchCapture } from '../../../daemon/__tests__/legacy-snapshot-capture-fixture.ts';
4+
import { resetGetRuntimeFixture } from '../../../daemon/__tests__/interaction-get-runtime-fixture.ts';
55
import fs from 'node:fs';
6-
import { captureSnapshot } from '../../snapshot-capture.ts';
7-
import { SessionStore } from '../../session-store.ts';
6+
import { captureSnapshot } from '../../../daemon/snapshot-capture.ts';
7+
import { SessionStore } from '../../../daemon/session-store.ts';
88
import {
99
isActiveProviderDevice,
1010
setActiveProviderDeviceRuntimes,
1111
} from '../../../provider-device-runtime.ts';
12-
import { installProviderDeviceAdmission } from '../../provider-device-admission.ts';
13-
import { testCreateCommandSurface } from '../../__tests__/command-surface-fixture.ts';
12+
import { installProviderDeviceAdmission } from '../../../daemon/provider-device-admission.ts';
13+
import { testCreateCommandSurface } from '../../../daemon/__tests__/command-surface-fixture.ts';
1414

1515
// The daemon reads provider ownership through its own typed admission seam; production
1616
// installs it from root composition, and these tests compose it the same way.
@@ -23,7 +23,7 @@ import { buildNodes } from '@agent-device/test-kit/snapshot-builders';
2323
import {
2424
fixtureScreenshotCaptures,
2525
resetSnapshotRuntimeFixture,
26-
} from '../../__tests__/snapshot-runtime-fixture.ts';
26+
} from '../../../daemon/__tests__/snapshot-runtime-fixture.ts';
2727
import {
2828
androidCapture,
2929
androidDevice,
@@ -36,10 +36,10 @@ import {
3636
makeSession,
3737
makeSessionStore,
3838
snapshotRequest,
39-
} from './snapshot-handler.fixtures.ts';
39+
} from '../../../daemon/handlers/__tests__/snapshot-handler.fixtures.ts';
4040

41-
vi.mock('../../snapshot-interactor-capture.ts', async () => {
42-
const fixture = await import('../../__tests__/legacy-snapshot-capture-fixture.ts');
41+
vi.mock('../../../daemon/snapshot-interactor-capture.ts', async () => {
42+
const fixture = await import('../../../daemon/__tests__/legacy-snapshot-capture-fixture.ts');
4343
return { captureSnapshotWithInteractor: fixture.captureSnapshotThroughLegacyDispatchFixture };
4444
});
4545
vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal) => {
@@ -52,12 +52,12 @@ vi.mock('@agent-device/platform-apple/runner/operations', async (importOriginal)
5252
// unambiguous environment; that live-probe logic is covered by
5353
// ios-app-session-hint.test.ts. Stubbed here so this suite stays hermetic and
5454
// fast — defaults to "no enrichment", matching the current-behavior fallback.
55-
vi.mock('../../ios-app-session-hint.ts', () => ({
55+
vi.mock('../../../daemon/ios-app-session-hint.ts', () => ({
5656
buildIosOpenCommandHint: vi.fn(async () => undefined),
5757
}));
5858

5959
import { runAppleRunnerCommand } from '@agent-device/platform-apple/runner/operations';
60-
import { buildIosOpenCommandHint } from '../../ios-app-session-hint.ts';
60+
import { buildIosOpenCommandHint } from '../../../daemon/ios-app-session-hint.ts';
6161

6262
const mockRunnerCommand = vi.mocked(runAppleRunnerCommand);
6363
const mockBuildIosOpenCommandHint = vi.mocked(buildIosOpenCommandHint);

src/daemon/__tests__/http-server-limrun-uploaded-apps.test.ts renamed to src/__tests__/daemon-composition/http-server-limrun-uploaded-apps.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import path from 'node:path';
44
import { test, vi } from 'vitest';
55
import { createLimrunRuntime } from '@agent-device/provider-limrun';
66
import { createProviderDeviceRuntimeRequestProviders } from '../../provider-device-runtime.ts';
7-
import { createTestDeviceInventoryGateways } from '../../__tests__/test-utils/device-inventory-gateways.ts';
7+
import { createTestDeviceInventoryGateways } from '../test-utils/device-inventory-gateways.ts';
88
import {
99
closeLoopbackServer,
1010
listenOnLoopback,
1111
skipWhenLoopbackUnavailable,
1212
} from '@agent-device/test-kit/loopback';
13-
import { makeSessionStore } from './support/store-factory.ts';
13+
import { makeSessionStore } from '../../daemon/__tests__/support/store-factory.ts';
1414
import { limrunTestDependencies } from '../../platform-runtime-gateway.fixtures.ts';
1515
import {
1616
DAEMON_HTTP_NETWORK_ACCESS_HEADER,
1717
DAEMON_HTTP_PUBLIC_NETWORK_ACCESS,
1818
} from '@agent-device/contracts/daemon-http';
19-
import { LeaseRegistry } from '../lease-registry.ts';
20-
import { createDaemonHttpServer } from '../server/http-server.ts';
21-
import { createRequestHandler } from './test-device-runtime-gateway.ts';
19+
import { LeaseRegistry } from '../../daemon/lease-registry.ts';
20+
import { createDaemonHttpServer } from '../../daemon/server/http-server.ts';
21+
import { createRequestHandler } from '../../daemon/__tests__/test-device-runtime-gateway.ts';
2222
import { mkdtempForTestSync } from '@agent-device/test-kit/tmp-dir';
23-
import { testCreateCommandSurface } from './command-surface-fixture.ts';
23+
import { testCreateCommandSurface } from '../../daemon/__tests__/command-surface-fixture.ts';
2424

2525
const limrunIo = vi.hoisted(() => ({
2626
listAssets: vi.fn(),

src/daemon/interaction/internal/__tests__/interaction-settle-private-ax-route.test.ts renamed to src/__tests__/daemon-composition/interaction/interaction-settle-private-ax-route.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { beforeEach, expect, test, vi } from 'vitest';
22
import { makeSnapshotState } from '@agent-device/selectors/snapshot-geometry-fixtures';
3-
import { makeIosSession } from '../../../__tests__/support/session-factories.ts';
4-
import { makeSessionStore } from '../../../__tests__/support/store-factory.ts';
3+
import { makeIosSession } from '../../../daemon/__tests__/support/session-factories.ts';
4+
import { makeSessionStore } from '../../../daemon/__tests__/support/store-factory.ts';
55
import { withAppleRunnerProvider } from '@agent-device/platform-apple/runner';
6-
import { contextFromFlags as buildDaemonContext } from '../../../context.ts';
7-
import { handleInteractionCommands } from '../../index.ts';
8-
import { getRuntimeBindings } from '../../../__tests__/interaction-get-runtime-fixture.ts';
9-
import { getInteractor } from '../../../../core/interactors.ts';
10-
import { installInteractorResolution } from '../../../interactor-resolution.ts';
11-
import { testCreateCommandSurface } from '../../../__tests__/command-surface-fixture.ts';
6+
import { contextFromFlags as buildDaemonContext } from '../../../daemon/context.ts';
7+
import { handleInteractionCommands } from '../../../daemon/interaction/index.ts';
8+
import { getRuntimeBindings } from '../../../daemon/__tests__/interaction-get-runtime-fixture.ts';
9+
import { getInteractor } from '../../../core/interactors.ts';
10+
import { installInteractorResolution } from '../../../daemon/interactor-resolution.ts';
11+
import { testCreateCommandSurface } from '../../../daemon/__tests__/command-surface-fixture.ts';
1212

1313
// Root composition hands the daemon its interactor resolution; this test drives the real
1414
// settle capture, so it composes the real lookup the way the process root does.

0 commit comments

Comments
 (0)