Skip to content

Commit 3ee2602

Browse files
committed
test: pin end-to-end publication-membership policy for iOS snapshots (#1797)
External review pass 4 finding 1: eligibility (runner presentation) and publication membership (daemon compaction) are distinct contracts. Pins the four semantic-content cases end to end: label/value content and interactive nodes are published; identifier-only STRUCTURAL Other wrappers (the RN testID shape) are eligible but deliberately suppressed at publication; identifier-only nodes outside that shape survive. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RtLCcpyJVLCqf4qFbq7Mh7
1 parent 2536d66 commit 3ee2602

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { expect, test } from 'vitest';
2+
import { attachRefs, type RawSnapshotNode } from '@agent-device/kernel/snapshot';
3+
import { presentIosInteractiveSnapshot } from './index.ts';
4+
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
12+
// - identifier-only STRUCTURAL `Other` (non-hittable, no label/value) -> ELIGIBLE but
13+
// 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.
17+
function publish(nodes: RawSnapshotNode[]) {
18+
return attachRefs(presentIosInteractiveSnapshot(nodes));
19+
}
20+
21+
const screen: RawSnapshotNode[] = [
22+
{ index: 0, depth: 0, type: 'Application', label: 'ShopApp' },
23+
{
24+
index: 1,
25+
depth: 1,
26+
parentIndex: 0,
27+
type: 'Image',
28+
label: 'Red sneakers product photo',
29+
rect: { x: 16, y: 130, width: 80, height: 44 },
30+
},
31+
{
32+
index: 2,
33+
depth: 1,
34+
parentIndex: 0,
35+
type: 'Other',
36+
value: '3 items',
37+
rect: { x: 300, y: 130, width: 86, height: 44 },
38+
},
39+
{
40+
index: 3,
41+
depth: 1,
42+
parentIndex: 0,
43+
type: 'Other',
44+
identifier: 'promo-banner',
45+
rect: { x: 110, y: 130, width: 180, height: 44 },
46+
},
47+
{
48+
index: 4,
49+
depth: 1,
50+
parentIndex: 0,
51+
type: 'Button',
52+
label: 'Pay $42.00',
53+
hittable: true,
54+
rect: { x: 16, y: 696, width: 370, height: 56 },
55+
},
56+
];
57+
58+
test('publication keeps label content, value content, and interactive nodes', () => {
59+
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');
64+
});
65+
66+
test('publication suppresses identifier-only structural Other wrappers, by declared policy', () => {
67+
const published = publish(screen);
68+
expect(published.some((node) => node.identifier === 'promo-banner')).toBe(false);
69+
});
70+
71+
test('identifier-only nodes outside the structural-Other shape survive publication', () => {
72+
const published = publish([
73+
{ index: 0, depth: 0, type: 'Application', label: 'ShopApp' },
74+
// Hittable identifier-only Other: NOT structural noise — must survive.
75+
{
76+
index: 1,
77+
depth: 1,
78+
parentIndex: 0,
79+
type: 'Other',
80+
identifier: 'submit-area',
81+
hittable: true,
82+
rect: { x: 16, y: 100, width: 370, height: 56 },
83+
},
84+
]);
85+
expect(published.some((node) => node.identifier === 'submit-area')).toBe(true);
86+
});

0 commit comments

Comments
 (0)