Skip to content

Commit b500319

Browse files
committed
refactor(daemon): one owner each for the inventory fake and the replay source collector
Owner review on #3517: the two daemon-side fakes restated logic that already had owners. Both are replaced by single importable owners: - The device-selection test fake becomes the one inventory-gateways fixture: moved to packages/device-selection/src/inventory-gateways.fixtures.ts and exported as ./inventory-gateways-fixtures (with findInstalledApp already in its options and createTestDeviceInventoryGatewaysFromProvider now exported). The daemon copy, the root fake, and its pin (the real composer's fail-closed contract is pinned in platform-runtime-device-inventory.test.ts) are deleted; daemon, root, device-selection, and integration consumers all import the owner. - The real client collector moves into its package: script-source-bundle and source-discovery move from src/commands/replay into replay-port (own exports ./script-source-bundle, ./source-discovery). The bundle helpers live once in packages/replay-port/src/daemon-port/replay-script-source.fixtures.ts (./replay-script-source-fixtures), typed on DaemonWireRequest; both test trees import it and run the same globs, size cap, AppErrors and ranking. - The Android capture fixtures move to platform-android test-only entries (./snapshot-capture-fixtures, ./ui-hierarchy-fixtures) so no test tree reaches sideways; the archived raw JSONs move with them.
1 parent 2a4b52e commit b500319

111 files changed

Lines changed: 197 additions & 563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎packages/device-selection/package.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
"./open-target": {
2727
"types": "./src/open-target.ts",
2828
"default": "./src/open-target.ts"
29+
},
30+
"./inventory-gateways-fixtures": {
31+
"types": "./src/inventory-gateways.fixtures.ts",
32+
"default": "./src/inventory-gateways.fixtures.ts"
2933
}
3034
}
3135
}

‎packages/device-selection/src/__tests__/device-selection-resolver.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
resolveExistingSessionDeviceSelection,
88
resolveInventoryDeviceSelection,
99
} from '../device-selection-resolver.ts';
10-
import { withTestDeviceInventory } from './test-utils/device-inventory-gateways.ts';
10+
import { withTestDeviceInventory } from '../inventory-gateways.fixtures.ts';
1111
import {
1212
ANDROID_EMULATOR,
1313
IOS_SIMULATOR,

‎packages/device-selection/src/__tests__/dispatch-resolve.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import {
1212
withTestDeviceInventory,
1313
withTestDeviceInventoryProvider as withDeviceInventoryProvider,
14-
} from './test-utils/device-inventory-gateways.ts';
14+
} from '../inventory-gateways.fixtures.ts';
1515
import type { DeviceInfo } from '@agent-device/kernel/device';
1616
import type { DeviceInventoryRequest } from '@agent-device/contracts/device';
1717
import { AppError } from '@agent-device/kernel/errors';

‎packages/device-selection/src/__tests__/test-utils/device-inventory-gateways.ts‎

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/daemon/__tests__/support/device-inventory-gateways.ts renamed to packages/device-selection/src/inventory-gateways.fixtures.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
// Daemon-side fake for the composed device-inventory gateway port. The root
2-
// `src/__tests__/test-utils/device-inventory-gateways.ts` builds through the real
3-
// `createComposedDeviceInventoryGateways` composition (platform-runtime-device-inventory);
4-
// daemon policy tests only need the port's behavior, so this fixture composes the same
5-
// package-owned rules (contracts projection + provider request scoping) without reaching
6-
// into root composition.
71
import {
82
filterDeviceInventoryProjection,
93
LOCAL_DEVICE_INVENTORY_PLATFORM_SELECTORS,
@@ -15,6 +9,7 @@ import {
159
import type {
1610
ComposedDeviceInventoryGateways,
1711
DeviceInventoryGateway,
12+
InstalledAppProbe,
1813
ProviderAwareDeviceInventoryGateway,
1914
} from '@agent-device/contracts/platform-module';
2015
import type { PlatformRequestScope } from '@agent-device/contracts/platform-runtime-host';
@@ -24,11 +19,12 @@ import {
2419
type Platform,
2520
type PlatformSelector,
2621
} from '@agent-device/kernel/device';
27-
import { withDeviceInventoryContext } from '@agent-device/device-selection/device-inventory-context';
22+
import { withDeviceInventoryContext } from './device-inventory-context.ts';
2823

2924
export type TestDeviceInventoryOptions = Readonly<{
3025
provider?: ProviderDeviceInventorySource;
3126
local?: (request: Readonly<DeviceInventoryRequest>) => Promise<readonly DeviceInfo[]>;
27+
findInstalledApp?: InstalledAppProbe;
3228
}>;
3329

3430
const testRequestScope: PlatformRequestScope = Object.freeze({
@@ -113,7 +109,21 @@ export function createTestDeviceInventoryGateways(
113109
discover: async (request, scope) => (await discoverWithSource(request, scope)).devices,
114110
discoverWithSource,
115111
});
116-
return Object.freeze({ providerFirst, localOnly });
112+
return Object.freeze({
113+
providerFirst,
114+
localOnly,
115+
findInstalledApp: options.findInstalledApp,
116+
});
117+
}
118+
119+
export async function withTestDeviceInventory<T>(
120+
options: TestDeviceInventoryOptions,
121+
task: () => Promise<T>,
122+
): Promise<T> {
123+
return await withDeviceInventoryContext(
124+
{ ...createTestDeviceInventoryGateways(options), requestScope: testRequestScope },
125+
task,
126+
);
117127
}
118128

119129
/** Test-only bridge for fixtures that still implement the public nullable provider port. */
@@ -133,16 +143,6 @@ export function createTestDeviceInventoryGatewaysFromProvider(
133143
});
134144
}
135145

136-
export async function withTestDeviceInventory<T>(
137-
options: TestDeviceInventoryOptions,
138-
task: () => Promise<T>,
139-
): Promise<T> {
140-
return await withDeviceInventoryContext(
141-
{ ...createTestDeviceInventoryGateways(options), requestScope: testRequestScope },
142-
task,
143-
);
144-
}
145-
146146
export async function withTestDeviceInventoryProvider<T>(
147147
provider: DeviceInventoryProvider,
148148
task: () => Promise<T>,

‎packages/platform-android/package.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
"./mechanics": {
3232
"types": "./src/mechanics.ts",
3333
"default": "./src/mechanics.ts"
34+
},
35+
"./snapshot-capture-fixtures": {
36+
"types": "./src/snapshot-capture.fixtures.ts",
37+
"default": "./src/snapshot-capture.fixtures.ts"
38+
},
39+
"./ui-hierarchy-fixtures": {
40+
"types": "./src/ui-hierarchy.fixtures.ts",
41+
"default": "./src/ui-hierarchy-fixtures.ts"
3442
}
3543
}
3644
}

src/daemon/__tests__/support/android-ime-capture.raw.json renamed to packages/platform-android/src/android-ime-capture.raw.json

File renamed without changes.

src/daemon/__tests__/support/android-qs-shade-capture.raw.json renamed to packages/platform-android/src/android-qs-shade-capture.raw.json

File renamed without changes.

src/daemon/__tests__/support/android-snapshot-capture.ts renamed to packages/platform-android/src/snapshot-capture.fixtures.ts

File renamed without changes.

src/daemon/__tests__/support/android-ui-hierarchy-fixtures.ts renamed to packages/platform-android/src/ui-hierarchy.fixtures.ts

File renamed without changes.

0 commit comments

Comments
 (0)