Skip to content

Commit 0e49f39

Browse files
committed
chore: consolidate makeSnapshotState into capture-kit, rename fixtures file
An adversarial review of the #2402 fixture-hoisting change found a third copy of makeSnapshotState in packages/capture-kit/src/snapshot-state.fixtures.ts, predating PR #2397. Since @agent-device/selectors already depends on capture-kit, make capture-kit's copy canonical (exported as ./snapshot-state-fixtures) and have the selectors package's fixtures module re-export it instead of duplicating it a third time. Also rename packages/selectors/src/test-fixtures.ts to snapshot-geometry.fixtures.ts (subpath ./snapshot-geometry-fixtures) to match every other test-fixture module's *.fixtures.ts convention in this repo, which lets it fall under .fallowrc.json's existing blanket **/*.fixtures.ts dead-code exemption instead of needing a bespoke per-symbol entry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01USabYbQjD16A2UkkvMpf5x
1 parent dcf10c9 commit 0e49f39

45 files changed

Lines changed: 63 additions & 84 deletions

Some content is hidden

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

.fallowrc.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,16 +305,6 @@
305305
"createAppLogLiveHandle"
306306
]
307307
},
308-
{
309-
"comment": "#2402: PROPERTY_RUNS, scrollingContainerTypeArb, distinctRectPairArb, and interactionTouchPointScenarioArb are the canonical snapshot/geometry fast-check fixtures both root and this package's tests build on; every consumer (packages/selectors/src/interaction-targeting.test.ts, interaction-touch-point.test.ts, internal/parse.test.ts, and root's wait-positionals.test.ts, kernel/snapshot-ref-grammar.test.ts, commands/replay/ad-script-round-trip.test.ts) is a test-tree file outside --production analysis. makeSnapshotState from the same module is not listed here — its *.fixtures.ts consumers keep it visible to --production analysis already.",
310-
"file": "packages/selectors/src/test-fixtures.ts",
311-
"exports": [
312-
"PROPERTY_RUNS",
313-
"scrollingContainerTypeArb",
314-
"distinctRectPairArb",
315-
"interactionTouchPointScenarioArb"
316-
]
317-
},
318308
{
319309
"comment": "Android mechanics facet: the package exports the complete named implementation seam for root/core/SDK consumers and package-owned tests; Fallow's production graph does not follow workspace subpath imports through the package exports map.",
320310
"file": "packages/platform-android/src/mechanics.ts",

docs/agents/testing.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ Before creating fixtures, look in `src/__tests__/test-utils/`. Import named buil
6969
that defines them (`session-factories.ts`, `device-fixtures.ts`, `store-factory.ts`); avoid importing
7070
unrelated helpers through a barrel. Shared `DeviceInfo`, session, snapshot, store, runtime-fact,
7171
and mocked-binary values belong in a sibling fixture module, not in repeated test literals.
72-
`makeSnapshotState`, `PROPERTY_RUNS`, and the interaction touch-point/rect arbitraries live in
73-
`@agent-device/selectors/test-fixtures` — the canonical location root tests and the selectors
74-
package both build on — not in `src/__tests__/test-utils/`.
72+
`PROPERTY_RUNS` and the interaction touch-point/rect arbitraries live in
73+
`@agent-device/selectors/snapshot-geometry-fixtures` — the canonical location root tests and the
74+
selectors package both build on — not in `src/__tests__/test-utils/`. `makeSnapshotState` itself
75+
canonically lives in `@agent-device/capture-kit/snapshot-state-fixtures`, re-exported from there.
7576

7677
Use `mkdtempForTest` or `mkdtempForTestSync`. Global setup redirects `TMPDIR` for the run and
7778
removes it after every worker exits — skip per-test cleanup. An interrupted run may leave a

packages/capture-kit/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@
182182
"types": "./src/snapshot-state.ts",
183183
"default": "./src/snapshot-state.ts"
184184
},
185+
"./snapshot-state-fixtures": {
186+
"types": "./src/snapshot-state.fixtures.ts",
187+
"default": "./src/snapshot-state.fixtures.ts"
188+
},
185189
"./snapshot-timeout-policy": {
186190
"types": "./src/snapshot/snapshot-timeout-policy.ts",
187191
"default": "./src/snapshot/snapshot-timeout-policy.ts"

packages/selectors/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"sideEffects": false,
66
"type": "module",
7-
"description": "Shared selector matching, argument, and replay semantics for agent-device. `.` is string-only; `./ast` is the published parser surface behind `agent-device/selectors`; `./engine` is the resolve/list surface reserved for the selector-pipeline owner (R19); `./parameterized-recorded-fill` parameterizes recorded fill payloads against their selectors; the interaction-resolution subpaths (`./selector-pipeline`, `./interaction-targeting`, `./interaction-touch-point`, `./press-retarget`, `./absence-observation*`, …) host the engine execution surface owned by the pipeline; `./test-fixtures` is the canonical home for snapshot/geometry test fixtures this package and root tests both build on.",
7+
"description": "Shared selector matching, argument, and replay semantics for agent-device. `.` is string-only; `./ast` is the published parser surface behind `agent-device/selectors`; `./engine` is the resolve/list surface reserved for the selector-pipeline owner (R19); `./parameterized-recorded-fill` parameterizes recorded fill payloads against their selectors; the interaction-resolution subpaths (`./selector-pipeline`, `./interaction-targeting`, `./interaction-touch-point`, `./press-retarget`, `./absence-observation*`, …) host the engine execution surface owned by the pipeline; `./snapshot-geometry-fixtures` is the canonical home for the geometry/touch-point test fixtures this package and root tests both build on (it re-exports `makeSnapshotState` from `@agent-device/capture-kit/snapshot-state-fixtures`, its own canonical home).",
88
"dependencies": {
99
"@agent-device/ad-script": "workspace:*",
1010
"@agent-device/capture-kit": "workspace:*",
@@ -72,9 +72,9 @@
7272
"types": "./src/selector-pipeline-policy.ts",
7373
"default": "./src/selector-pipeline-policy.ts"
7474
},
75-
"./test-fixtures": {
76-
"types": "./src/test-fixtures.ts",
77-
"default": "./src/test-fixtures.ts"
75+
"./snapshot-geometry-fixtures": {
76+
"types": "./src/snapshot-geometry.fixtures.ts",
77+
"default": "./src/snapshot-geometry.fixtures.ts"
7878
},
7979
"./touch-semantics": {
8080
"types": "./src/touch-semantics.ts",

packages/selectors/src/absence-observation.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import assert from 'node:assert/strict';
22
import { test } from 'vitest';
3-
import { makeSnapshotState } from './test-fixtures.ts';
3+
import { makeSnapshotState } from './snapshot-geometry.fixtures.ts';
44
import {
55
absenceCaptureOptionMessage,
66
absenceCaptureOptionRefusal,

packages/selectors/src/interaction-targeting.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
makeSnapshotState,
77
PROPERTY_RUNS,
88
scrollingContainerTypeArb,
9-
} from './test-fixtures.ts';
9+
} from './snapshot-geometry.fixtures.ts';
1010
import {
1111
classifyActionableTouchCandidates,
1212
createActionableTouchResolver,

packages/selectors/src/interaction-touch-point.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
interactionTouchPointScenarioArb,
77
makeSnapshotState,
88
PROPERTY_RUNS,
9-
} from './test-fixtures.ts';
9+
} from './snapshot-geometry.fixtures.ts';
1010
import { resolveInteractionTouchPoint } from './interaction-touch-point.ts';
1111

1212
function containsPoint(rect: Rect, point: Point): boolean {

packages/selectors/src/internal/parse.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
formatSelectorChainExpression,
66
selectorChainArb,
77
} from './__tests__/property-arbitraries.ts';
8-
import { PROPERTY_RUNS } from '../test-fixtures.ts';
8+
import { PROPERTY_RUNS } from '../snapshot-geometry.fixtures.ts';
99
import { parseSelectorChain } from './parse.ts';
1010
import type { SelectorTerm } from './parse.ts';
1111

packages/selectors/src/selector-pipeline.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
22
import { test } from 'vitest';
33
import type { RawSnapshotNode, SnapshotNode } from '@agent-device/kernel/snapshot';
44
import { SELECTOR_RESOLUTION_POLICIES } from '@agent-device/selectors';
5-
import { makeSnapshotState } from './test-fixtures.ts';
5+
import { makeSnapshotState } from './snapshot-geometry.fixtures.ts';
66
import {
77
listSelectorPipelineMatches,
88
resolveSelectorPipeline,

packages/selectors/src/test-fixtures.ts renamed to packages/selectors/src/snapshot-geometry.fixtures.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import fc from 'fast-check';
2-
import {
3-
attachRefs,
4-
type Rect,
5-
type RawSnapshotNode,
6-
type SnapshotNode,
7-
type SnapshotState,
8-
type SnapshotStateProvenance,
9-
} from '@agent-device/kernel/snapshot';
2+
import { attachRefs, type Rect, type SnapshotNode } from '@agent-device/kernel/snapshot';
3+
4+
export { makeSnapshotState } from '@agent-device/capture-kit/snapshot-state-fixtures';
105

116
/**
127
* Run budget for every property in the unit suite. Properties share the unit
@@ -16,19 +11,6 @@ import {
1611
*/
1712
export const PROPERTY_RUNS = 100;
1813

19-
export function makeSnapshotState(
20-
raw: RawSnapshotNode[],
21-
// The provenance pair stays correlated: overrides carry it as one value, never as two
22-
// independently typed fields.
23-
overrides?: Omit<Partial<SnapshotState>, 'backend' | 'producer'> & SnapshotStateProvenance,
24-
): SnapshotState {
25-
return {
26-
nodes: attachRefs(raw),
27-
createdAt: Date.now(),
28-
...overrides,
29-
};
30-
}
31-
3214
// ---------------------------------------------------------------------------
3315
// Rects / viewports
3416
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)