Skip to content

Commit 9c06cd2

Browse files
thymikeeclaude
andauthored
refactor(daemon): relocate the interaction touch tests by what they assert (#3672)
* test(daemon): add the interactor-resolution fixture and the touch command surface fake The interactor-resolution fixture replaces the snapshot-interactor-capture module mock: captures reach one spy through the installed InteractorResolution. The touch surface fake dispatches resolved targets through the runtime config's backend and reads the session through its store, so daemon suites pin admission, bound-operation wiring, response shaping, and capture wiring without the real command family. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): place the touch router ownership tests beside the interaction handler interaction-touch.test.ts is (a) daemon logic: router claims press/click/longpress/hover/fill, single inspect/bind, macOS surface refusals, hover capability refusal. All 12 tests move to execution/interaction/internal/interaction-touch-routing.test.ts on the touch surface fake. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): split press admission and press target tests by what each asserts interaction-touch-press-admission.test.ts: (a) 12 tests move to the daemon package on the touch surface fake; the #1654 provenance-mismatch test is (c) and moves to src/commands/interaction/runtime/interactions-preresolved-target.test.ts. interaction-touch-press.test.ts: (a) secondary-button projection, the find pre-resolved wiring (adopt, control, no lookup) and read-after-press capture stay in the daemon package; the macOS menubar wrapper promotion, hittable-ancestor promotion, full-screen non-promotion (interactions- target-promotion.test.ts) and the pre-resolved adopt/control/no-lookup/shared-guard cases (interactions-preresolved-target.test.ts) are (c) and run against the real command runtime. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): split fill and runtime-dispatch tests by what each asserts interaction-touch-fill.test.ts: (a) expired-frame rejection, pinned stale/current ref, and the find-internal fill without a stale-ref warning move to the daemon package (plus one new test that the resolved point, typing delay and recorded ref reach the bound fill). The off-screen refusal, invalid-bounds refusal and editable-node retention are (c): interactions-ref-frame-evidence.test.ts and interactions-target-promotion.test.ts. interaction-touch-runtime.test.ts: (a) the resolved-point tap/record test and the #1542 rescue hook wiring (hook present iff the owner advertises querySelector) move to the daemon package; the invalid-bounds, off-screen refusal and in-frame label recovery cases are (c) in interactions-ref-frame-evidence.test.ts (the missing-rect refusal is already ref-target-resolution.test.ts). Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): place touch response, payload and prepare tests beside their modules interaction-touch-response.test.ts (6), interaction-touch-payload.test.ts (7) and interaction-touch-prepare.test.ts (5) are (a) daemon logic: evidence rides the response allowlist only when --verify ran, recording/visualization payloads and reference frames, and the settle observation capture the request admitted. They move to execution/interaction/internal/ on the touch surface fake, the interactor-resolution fixture and daemonPlatformServicesFixture. The --verify evidence computation itself stays covered by the real-runtime tests in src/commands/interaction/runtime/interactions.test.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): place the Android freshness and readiness tests beside their modules interaction-touch-android-freshness.test.ts (4) and interaction-touch-android-readiness.test.ts (7) are (a) daemon logic: the freshness refresh may not retarget an admitted ref, the escape and permission-prompt outcomes, and recovery aborting an admitted ref. They move to execution/interaction/internal/. The readiness suite now mocks the exact android-system-dialog module the handler imports. interaction-touch-android-readiness-spawns.test.ts is (a): the two-checks-per-tap dumpsys budget is pinned through the real Android observation adapter over a counting runAdb host port instead of the root adb provider and host binding. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): place the direct-iOS selector tap tests beside the press handler interaction-touch-direct-ios.test.ts (6) and interaction-touch-direct-ios-eligibility.test.ts (4) are (a) daemon logic: the Maestro-only direct selector route, its error passthrough, the fused ref-frame seam, and the maestro-direct dispatch-disclosure rows. They move to execution/interaction/internal/. The dispatch-disclosure driver owner and the boundary-fault-matrix evidence path follow the moved driver file. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): place the iOS tap outcome and drag tests beside their modules interaction-ios-tap-outcome.test.ts (22) and interaction-gesture-drag.test.ts (2) are (a) daemon logic: same-scope corroboration of a failed iOS tap, the recorded drag with both endpoint identities, one inspect/bind per drag, and frame expiry. They move to execution/interaction/internal/ on the touch surface fake (which now answers a target-authored drag through one backend plan). The drag endpoint resolution and disclosure stay covered by src/commands/interaction/runtime/gestures.test.ts. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(daemon): split the get and is read tests by what each asserts interaction-get.test.ts: (a) the 9 get tests (bound read expansion, no live read, retired direct selector, frame-tree @ref reads and their warnings) move to execution/selector-runtime-get-reads .test.ts and the 5 is tests that pin capture wiring and the Android foreground blocker move to execution/selector-runtime-is-reads.test.ts. The two predicate-semantics tests (is visible inheriting ancestor viewport visibility, is visible failing outside the viewport) are (c) in src/commands/interaction/runtime/selector-is-visibility.test.ts, and the same-label disambiguation read is (c) in selector-read-disambiguation.test.ts. Nothing imports the root interaction-touch-runner helper any more, so it is deleted. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(daemon): delete the touch routing test the package copy replaces Co-Authored-By: Claude Opus 5.5 <[email protected]> * test: assert typed refusal details, count captures, and make the touch fake's drag and ref routes follow production Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(daemon): reuse the shared contextFromFlags in the touch runner and say which fake values are fake-supplied Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(test): say that only selector reads capture in the touch fake Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent d000e71 commit 9c06cd2

33 files changed

Lines changed: 2381 additions & 2251 deletions

‎packages/contracts/src/dispatch-disclosure.fixtures.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const DISPATCH_DISCLOSURE_DRIVER_OWNERS: Readonly<Record<string, string>>
5656
'web-agent-browser.':
5757
'packages/platform-web/src/__tests__/agent-browser-provider-dispatch-disclosure.test.ts',
5858
'maestro-direct.':
59-
'src/__tests__/daemon-composition/interaction/interaction-touch-direct-ios.test.ts',
59+
'packages/daemon/src/execution/interaction/internal/interaction-touch-direct-ios.test.ts',
6060
};
6161

6262
/** The per-row driving loop every driver file carries. */

‎packages/daemon/package.json‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
"types": "./src/execution/__tests__/interaction-get-runtime-fixture.ts",
5757
"default": "./src/execution/__tests__/interaction-get-runtime-fixture.ts"
5858
},
59-
"./testing/__tests__/ios-comparison-key-fixture": {
60-
"types": "./src/core/__tests__/ios-comparison-key-fixture.ts",
61-
"default": "./src/core/__tests__/ios-comparison-key-fixture.ts"
62-
},
6359
"./testing/__tests__/legacy-snapshot-capture-fixture": {
6460
"types": "./src/__tests__/support/legacy-snapshot-capture-fixture.ts",
6561
"default": "./src/__tests__/support/legacy-snapshot-capture-fixture.ts"
@@ -68,10 +64,6 @@
6864
"types": "./src/__tests__/support/platform-services-fixture.ts",
6965
"default": "./src/__tests__/support/platform-services-fixture.ts"
7066
},
71-
"./testing/__tests__/replay-runtime/replay-command-fixture": {
72-
"types": "./src/sessions/__tests__/replay-runtime/replay-command-fixture.ts",
73-
"default": "./src/sessions/__tests__/replay-runtime/replay-command-fixture.ts"
74-
},
7567
"./testing/__tests__/request-router-dispatch-mocks": {
7668
"types": "./src/__tests__/support/request-router-dispatch-mocks.ts",
7769
"default": "./src/__tests__/support/request-router-dispatch-mocks.ts"
@@ -196,14 +188,6 @@
196188
"types": "./src/execution/interaction/internal/interaction-android-escape.ts",
197189
"default": "./src/execution/interaction/internal/interaction-android-escape.ts"
198190
},
199-
"./testing/interaction/internal/interaction-ios-tap-outcome": {
200-
"types": "./src/execution/interaction/internal/interaction-ios-tap-outcome.ts",
201-
"default": "./src/execution/interaction/internal/interaction-ios-tap-outcome.ts"
202-
},
203-
"./testing/interaction/internal/interaction-touch-android-readiness": {
204-
"types": "./src/execution/interaction/internal/interaction-touch-android-readiness.ts",
205-
"default": "./src/execution/interaction/internal/interaction-touch-android-readiness.ts"
206-
},
207191
"./testing/interaction/internal/interaction-touch-response": {
208192
"types": "./src/execution/interaction/internal/interaction-touch-response.ts",
209193
"default": "./src/execution/interaction/internal/interaction-touch-response.ts"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { vi } from 'vitest';
2+
import type {
3+
Interactor,
4+
RunnerContext,
5+
SnapshotOptions,
6+
SnapshotResult,
7+
} from '@agent-device/contracts/interactor-types';
8+
import type { DeviceInfo } from '@agent-device/kernel/device';
9+
import { installInteractorResolution } from '../../core/interactor-resolution.ts';
10+
11+
type InteractorSnapshotCall = Readonly<{
12+
device: DeviceInfo;
13+
runnerContext: RunnerContext;
14+
options: SnapshotOptions;
15+
}>;
16+
17+
/**
18+
* The snapshot the resolved interactor answers with. Every capture that falls back to
19+
* `captureSnapshotWithInteractor` lands here with the `{ device, runnerContext, options }` the
20+
* production seam hands the interactor, so a suite configures captures and reads their call
21+
* arguments from one spy.
22+
*/
23+
export const mockInteractorSnapshot = vi.fn<
24+
(call: InteractorSnapshotCall) => Promise<SnapshotResult>
25+
>(async () => ({
26+
nodes: [],
27+
backend: 'xctest',
28+
producer: 'apple-runner',
29+
}));
30+
31+
/**
32+
* Installs an interactor resolution whose interactor snapshots through
33+
* {@link mockInteractorSnapshot}. Call from `beforeEach`; the spy keeps its configuration until the
34+
* suite resets it.
35+
*/
36+
export function installInteractorSnapshotResolution(): void {
37+
installInteractorResolution({
38+
resolve: async (device, runnerContext) =>
39+
({
40+
snapshot: async (options: SnapshotOptions) =>
41+
await mockInteractorSnapshot({ device, runnerContext, options }),
42+
}) as unknown as Interactor,
43+
});
44+
}

0 commit comments

Comments
 (0)