Skip to content

Commit 5f5b1ee

Browse files
committed
fix(ios): cover visible-depth frontier through public snapshot
1 parent 267f2df commit 5f5b1ee

8 files changed

Lines changed: 261 additions & 2 deletions

File tree

‎examples/test-app/app/_layout.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function RootLayoutContent() {
2626
<Stack.Screen name="accessory-setup" />
2727
<Stack.Screen name="automation" options={{ headerShown: true, title: 'Automation' }} />
2828
<Stack.Screen name="inert" options={{ presentation: 'fullScreenModal' }} />
29+
<Stack.Screen name="snapshot-depth" />
2930
<Stack.Screen name="product/[productId]" />
3031
<Stack.Screen name="webview" />
3132
</Stack>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { VisibleDepthScreen } from '../src/screens/VisibleDepthScreen';
2+
3+
export default function SnapshotDepthRoute() {
4+
return <VisibleDepthScreen />;
5+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { Pressable, StyleSheet, Text, View } from 'react-native';
2+
3+
import { AppFrame } from '../components';
4+
import { useAppColors, type AppColors } from '../theme';
5+
6+
/**
7+
* Keeps the structural wrapper outside the viewport while its independent child projects into
8+
* it. The wrapper must stay an `Other` node in XCTest: it is semantic enough to be acquisition-
9+
* eligible, but it is not a scroll/container type that owns descendant visibility.
10+
*/
11+
export function VisibleDepthScreen() {
12+
const colors = useAppColors();
13+
const styles = createStyles(colors);
14+
15+
return (
16+
<AppFrame>
17+
<Text style={[styles.title, styles.titleSpacing]} testID="visible-depth-title">
18+
Regular visible depth frontier
19+
</Text>
20+
<Text style={styles.body}>
21+
The projected child remains visible when its clipped structural parent is collapsed.
22+
</Text>
23+
<View
24+
accessible={false}
25+
accessibilityLabel="Clipped structural parent"
26+
style={styles.clippedParent}
27+
testID="visible-depth-clipped-parent"
28+
>
29+
<Pressable
30+
accessibilityLabel="Projected child"
31+
accessibilityRole="button"
32+
style={styles.projectedChild}
33+
testID="visible-depth-projected-child"
34+
>
35+
<Text style={styles.projectedChildLabel}>Projected child</Text>
36+
</Pressable>
37+
</View>
38+
</AppFrame>
39+
);
40+
}
41+
42+
function createStyles(colors: AppColors) {
43+
return StyleSheet.create({
44+
body: {
45+
color: colors.textSoft,
46+
fontSize: 16,
47+
lineHeight: 23,
48+
},
49+
clippedParent: {
50+
height: 64,
51+
left: -96,
52+
overflow: 'visible',
53+
position: 'absolute',
54+
top: 164,
55+
width: 64,
56+
},
57+
projectedChild: {
58+
alignItems: 'center',
59+
backgroundColor: colors.accent,
60+
borderRadius: 6,
61+
left: 112,
62+
minHeight: 52,
63+
paddingHorizontal: 18,
64+
paddingVertical: 14,
65+
position: 'absolute',
66+
top: 0,
67+
width: 220,
68+
},
69+
projectedChildLabel: {
70+
color: '#ffffff',
71+
fontSize: 16,
72+
fontWeight: '700',
73+
},
74+
title: {
75+
color: colors.text,
76+
fontSize: 28,
77+
fontWeight: '700',
78+
lineHeight: 34,
79+
},
80+
titleSpacing: {
81+
marginBottom: 16,
82+
},
83+
});
84+
}

‎test/integration/ios-simulator-e2e/behavior-coverage.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type IosSimulatorBehaviorId =
66
| 'long-list-scroll-recovery'
77
| 'modal-open-close'
88
| 'permission-state-recovery'
9+
| 'regular-visible-depth-frontier'
910
| 'text-entry-keyboard-lifecycle';
1011

1112
type BehaviorCoverageEntry =
@@ -54,6 +55,12 @@ export const IOS_SIMULATOR_BEHAVIOR_COVERAGE = {
5455
level: 'live',
5556
owner: 'full:lifecycle-system',
5657
},
58+
'regular-visible-depth-frontier': {
59+
assertion:
60+
'regular depth 1 retains an independently projected child after its clipped structural parent is removed, while raw depth remains traversal-bounded',
61+
level: 'live',
62+
owner: 'smoke:regular-visible-depth-frontier',
63+
},
5764
'interrupted-system-ui-flow': {
5865
assertion: 'Home and app switcher expose distinct system pixels before fixture restoration',
5966
level: 'live',

‎test/integration/ios-simulator-e2e/live-automation-scenario.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ async function assertClearStateLaunchUrl(context: LiveContext): Promise<void> {
237237
await assertElementText(context, 'id="automation-event-payload"', '{"source":"deep-link"}');
238238
}
239239

240-
async function acceptDeepLinkConfirmationIfPresent(context: LiveContext): Promise<void> {
240+
export async function acceptDeepLinkConfirmationIfPresent(context: LiveContext): Promise<void> {
241241
const destination = await runStep(
242242
context,
243243
'wait for deep-link destination before inspecting system UI',

‎test/integration/ios-simulator-e2e/live-runner.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from './live-assertions.ts';
1717
import { assertAutomationInput } from './live-automation-scenario.ts';
1818
import { assertDeviceLifecycle } from './live-device-lifecycle.ts';
19+
import { assertRegularVisibleDepthFrontier } from './live-snapshot-depth-frontier.ts';
1920
import {
2021
assertLifecycleAndSystem,
2122
assertObservabilityAndArtifacts,
@@ -75,6 +76,7 @@ const LIVE_SCENARIOS = bindIosSimulatorScenarios<LiveContext>({
7576
inventoryInstall: assertInventoryAndInstall,
7677
lifecycleSystem: assertLifecycleAndSystem,
7778
observabilityArtifacts: assertObservabilityAndArtifacts,
79+
snapshotDepthFrontier: assertRegularVisibleDepthFrontier,
7880
});
7981

8082
export async function runIosSimulatorE2E(): Promise<void> {
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import assert from 'node:assert/strict';
2+
3+
import { assertWaitText } from './live-assertions.ts';
4+
import { acceptDeepLinkConfirmationIfPresent } from './live-automation-scenario.ts';
5+
import { type LiveContext, runStep, verifyBehavior } from './live-harness.ts';
6+
7+
const VISIBLE_DEPTH_DEEP_LINK = 'agent-device-test-app:///snapshot-depth';
8+
const TITLE_ID = 'visible-depth-title';
9+
const PARENT_ID = 'visible-depth-clipped-parent';
10+
const CHILD_ID = 'visible-depth-projected-child';
11+
12+
type SnapshotNode = {
13+
depth?: unknown;
14+
identifier?: unknown;
15+
index?: unknown;
16+
label?: unknown;
17+
parentIndex?: unknown;
18+
};
19+
20+
export async function assertRegularVisibleDepthFrontier(context: LiveContext): Promise<void> {
21+
await runStep(context, 'open regular visible-depth fixture', [
22+
'open',
23+
context.appId,
24+
'--relaunch',
25+
'--launch-url',
26+
VISIBLE_DEPTH_DEEP_LINK,
27+
]);
28+
await acceptDeepLinkConfirmationIfPresent(context);
29+
await assertWaitText(context, 'Regular visible depth frontier');
30+
31+
const regular = await runStep(context, 'capture regular visible-depth frontier', [
32+
'snapshot',
33+
'--depth',
34+
'1',
35+
]);
36+
assertSnapshotBackend(regular, 'regular depth-1 snapshot');
37+
const regularNodes = snapshotNodes(regular);
38+
const regularRoot = requireRoot(regularNodes, 'regular depth-1 snapshot');
39+
const regularTitle = requireIdentifier(regularNodes, TITLE_ID, 'regular depth-1 snapshot');
40+
const projectedChild = requireIdentifier(regularNodes, CHILD_ID, 'regular depth-1 snapshot');
41+
assert.equal(
42+
regularTitle.label,
43+
'Regular visible depth frontier',
44+
`regular title should remain observable: ${JSON.stringify(regular)}`,
45+
);
46+
assert.equal(
47+
regularNodes.some((node) => node.identifier === PARENT_ID),
48+
false,
49+
`clipped structural parent must be absent from regular presentation: ${JSON.stringify(regular)}`,
50+
);
51+
assert.equal(
52+
projectedChild.depth,
53+
1,
54+
`projected child should occupy presented depth 1: ${JSON.stringify(regular)}`,
55+
);
56+
assert.equal(
57+
projectedChild.parentIndex,
58+
regularRoot.index,
59+
`projected child should be reparented to the presented root: ${JSON.stringify(regular)}`,
60+
);
61+
assert.ok(
62+
regularNodes.every((node) => numericDepth(node) <= 1),
63+
`regular --depth 1 exceeded the presented frontier: ${JSON.stringify(regular)}`,
64+
);
65+
66+
const rawFull = await runStep(context, 'capture full raw visible-depth tree', [
67+
'snapshot',
68+
'--raw',
69+
]);
70+
assertSnapshotBackend(rawFull, 'full raw visible-depth snapshot');
71+
const rawFullNodes = snapshotNodes(rawFull);
72+
const rawParent = requireIdentifier(rawFullNodes, PARENT_ID, 'full raw visible-depth snapshot');
73+
const rawChild = requireIdentifier(rawFullNodes, CHILD_ID, 'full raw visible-depth snapshot');
74+
assert.ok(
75+
numericDepth(rawChild) > 1,
76+
`raw projected child must remain below traversal depth 1: ${JSON.stringify(rawFull)}`,
77+
);
78+
assert.equal(
79+
rawChild.parentIndex,
80+
rawParent.index,
81+
`raw tree must retain the structural parent relationship: ${JSON.stringify(rawFull)}`,
82+
);
83+
84+
const rawDepthOne = await runStep(context, 'capture raw depth-bounded visible-depth tree', [
85+
'snapshot',
86+
'--raw',
87+
'--depth',
88+
'1',
89+
]);
90+
assertSnapshotBackend(rawDepthOne, 'raw depth-1 visible-depth snapshot');
91+
const rawDepthOneNodes = snapshotNodes(rawDepthOne);
92+
assert.equal(
93+
rawDepthOneNodes.some((node) => node.identifier === CHILD_ID),
94+
false,
95+
`raw --depth 1 must omit the raw depth-2 child: ${JSON.stringify(rawDepthOne)}`,
96+
);
97+
assert.ok(
98+
rawDepthOneNodes.every((node) => numericDepth(node) <= 1),
99+
`raw --depth 1 exceeded the acquisition frontier: ${JSON.stringify(rawDepthOne)}`,
100+
);
101+
102+
await runStep(context, 'restore fixture home after visible-depth capture', [
103+
'open',
104+
context.appId,
105+
'--relaunch',
106+
]);
107+
await assertWaitText(context, 'Agent Device Tester');
108+
verifyBehavior(
109+
context,
110+
'regular-visible-depth-frontier',
111+
'public regular depth 1 keeps an independently projected child after removing its clipped structural parent while raw depth remains traversal-bounded',
112+
);
113+
}
114+
115+
function snapshotNodes(result: { json?: any }): SnapshotNode[] {
116+
const nodes = result.json?.data?.nodes;
117+
assert.ok(
118+
Array.isArray(nodes),
119+
`snapshot response did not contain nodes: ${JSON.stringify(result)}`,
120+
);
121+
return nodes as SnapshotNode[];
122+
}
123+
124+
function requireIdentifier(nodes: SnapshotNode[], identifier: string, description: string) {
125+
const node = nodes.find((candidate) => candidate.identifier === identifier);
126+
assert.ok(node, `${description} missing ${identifier}: ${JSON.stringify(nodes)}`);
127+
return node;
128+
}
129+
130+
function requireRoot(nodes: SnapshotNode[], description: string) {
131+
const root = nodes.find(
132+
(node) =>
133+
numericDepth(node) === 0 && (node.parentIndex === undefined || node.parentIndex === null),
134+
);
135+
assert.ok(root, `${description} missing a presented root: ${JSON.stringify(nodes)}`);
136+
return root;
137+
}
138+
139+
function numericDepth(node: SnapshotNode): number {
140+
assert.equal(
141+
typeof node.depth,
142+
'number',
143+
`snapshot node has no numeric depth: ${JSON.stringify(node)}`,
144+
);
145+
return node.depth as number;
146+
}
147+
148+
function assertSnapshotBackend(result: { json?: any }, description: string): void {
149+
assert.equal(
150+
result.json?.data?.snapshotQuality?.backend,
151+
'tree',
152+
`${description} must exercise the recursive tree backend: ${JSON.stringify(result)}`,
153+
);
154+
}

‎test/integration/ios-simulator-e2e/scenarios.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ type ScenarioRunnerKey =
1111
| 'formInput'
1212
| 'inventoryInstall'
1313
| 'lifecycleSystem'
14-
| 'observabilityArtifacts';
14+
| 'observabilityArtifacts'
15+
| 'snapshotDepthFrontier';
1516

1617
type ScenarioDefinition = IosSimulatorScenario & {
1718
runner: ScenarioRunnerKey;
@@ -21,6 +22,11 @@ const SCENARIO_DEFINITIONS: readonly ScenarioDefinition[] = [
2122
{ id: 'smoke:inventory-install', runner: 'inventoryInstall', tier: 'smoke' },
2223
{ id: 'smoke:automation-input', runner: 'automationInput', tier: 'smoke' },
2324
{ id: 'smoke:form-input', runner: 'formInput', tier: 'smoke' },
25+
{
26+
id: 'smoke:regular-visible-depth-frontier',
27+
runner: 'snapshotDepthFrontier',
28+
tier: 'smoke',
29+
},
2430
{ id: 'smoke:capture-close', runner: 'captureClose', tier: 'smoke' },
2531
{ id: 'full:lifecycle-system', runner: 'lifecycleSystem', tier: 'full' },
2632
{

0 commit comments

Comments
 (0)