|
1 | 1 | import { expect, test } from 'vitest'; |
2 | | -import { attachRefs, type RawSnapshotNode } from '@agent-device/kernel/snapshot'; |
3 | | -import { presentIosInteractiveSnapshot } from './index.ts'; |
| 2 | +import type { RawSnapshotNode } from '@agent-device/kernel/snapshot'; |
| 3 | +import { buildSnapshotState } from '../../handlers/snapshot-capture.ts'; |
4 | 4 |
|
5 | 5 | // End-to-end publication-membership contract for the acquire/present design (#1797, external |
6 | | -// review pass 4 finding 1). Runner presentation owns ELIGIBILITY (which nodes may appear at |
7 | | -// all); this daemon compaction layer owns PUBLICATION membership (what agents actually see). |
8 | | -// The four semantic-content cases pin the declared policy: |
9 | | -// - label content -> published (any type: a labeled image is meaningful content) |
10 | | -// - value content -> published |
11 | | -// - interactive -> published |
| 6 | +// review pass 4 finding 1), exercised through the PRODUCTION interface: buildSnapshotState owns |
| 7 | +// the real ordering of normalization, group pruning, scope, iOS compaction, occlusion |
| 8 | +// annotation, and refs. Runner presentation owns ELIGIBILITY (which nodes may appear at all); |
| 9 | +// this pipeline owns PUBLICATION membership (what agents actually see). |
| 10 | +// |
| 11 | +// The semantic-content cases pin the declared policy: |
| 12 | +// - label content -> published (any type: a labeled image is meaningful content) |
| 13 | +// - value content -> published |
| 14 | +// - interactive-only -> published (a bare hittable Button with NO label/identifier/value, |
| 15 | +// so its survival proves the interactive branch, not content) |
12 | 16 | // - identifier-only STRUCTURAL `Other` (non-hittable, no label/value) -> ELIGIBLE but |
13 | 17 | // SUPPRESSED at publication, deliberately: this is the React Native testID-wrapper shape |
14 | | -// (see collectIosStructuralIdentifierSuppression in noise.ts), which would otherwise spam |
15 | | -// agent output with non-actionable wrappers. Identifier-only nodes of other shapes are NOT |
16 | | -// covered by that suppression and must survive. |
| 18 | +// (collectIosStructuralIdentifierSuppression in noise.ts), which would otherwise spam agent |
| 19 | +// output with non-actionable wrappers. Identifier-only nodes outside that shape survive. |
| 20 | +// |
| 21 | +// Non-vacuity (regression-test rule): with the collectIosStructuralIdentifierSuppression call |
| 22 | +// disabled in noise.ts, the suppression test below FAILS ('promo-banner' is published); it |
| 23 | +// passes only because the production suppression fires. |
17 | 24 | function publish(nodes: RawSnapshotNode[]) { |
18 | | - return attachRefs(presentIosInteractiveSnapshot(nodes)); |
| 25 | + return buildSnapshotState({ nodes, backend: 'xctest' }, { snapshotInteractiveOnly: true }).nodes; |
19 | 26 | } |
20 | 27 |
|
21 | 28 | const screen: RawSnapshotNode[] = [ |
@@ -44,23 +51,26 @@ const screen: RawSnapshotNode[] = [ |
44 | 51 | identifier: 'promo-banner', |
45 | 52 | rect: { x: 110, y: 130, width: 180, height: 44 }, |
46 | 53 | }, |
| 54 | + // Interactive-only: no label, no identifier, no value — survival proves the interactive branch. |
47 | 55 | { |
48 | 56 | index: 4, |
49 | 57 | depth: 1, |
50 | 58 | parentIndex: 0, |
51 | 59 | type: 'Button', |
52 | | - label: 'Pay $42.00', |
53 | 60 | hittable: true, |
54 | 61 | rect: { x: 16, y: 696, width: 370, height: 56 }, |
55 | 62 | }, |
56 | 63 | ]; |
57 | 64 |
|
58 | | -test('publication keeps label content, value content, and interactive nodes', () => { |
| 65 | +test('publication keeps label content, value content, and bare interactive nodes', () => { |
59 | 66 | const published = publish(screen); |
60 | | - const labels = published.map((node) => node.label ?? node.value ?? node.identifier); |
61 | | - expect(labels).toContain('Red sneakers product photo'); |
62 | | - expect(labels).toContain('3 items'); |
63 | | - expect(labels).toContain('Pay $42.00'); |
| 67 | + expect(published.some((node) => node.label === 'Red sneakers product photo')).toBe(true); |
| 68 | + expect(published.some((node) => node.value === '3 items')).toBe(true); |
| 69 | + expect( |
| 70 | + published.some( |
| 71 | + (node) => node.type === 'Button' && !node.label && !node.identifier && !node.value, |
| 72 | + ), |
| 73 | + ).toBe(true); |
64 | 74 | }); |
65 | 75 |
|
66 | 76 | test('publication suppresses identifier-only structural Other wrappers, by declared policy', () => { |
|
0 commit comments