Skip to content

Commit 54a271f

Browse files
committed
fix(snapshot): compare iOS value interpretation eligibility
1 parent 9bbe482 commit 54a271f

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

‎src/commands/capture/runtime/snapshot-unchanged.test.ts‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { expect, test } from 'vitest';
2+
import { interpretIosReactNativeValue } from '@agent-device/capture-kit/ios-react-native-value';
3+
import { attachRefs } from '@agent-device/kernel/snapshot';
24
import fc from 'fast-check';
35
import {
46
buildUnchangedSnapshotMetadata,
@@ -63,6 +65,8 @@ test('unchanged metadata detects visible label changes', () => {
6365

6466
test.each<Partial<SnapshotNode>>([
6567
{ index: 1 },
68+
{ editable: true },
69+
{ password: true },
6670
{ depth: 1 },
6771
{ parentIndex: 1 },
6872
{ type: 'TextField' },
@@ -93,8 +97,6 @@ test.each<Partial<SnapshotNode>>([
9397
});
9498

9599
test.each<Partial<SnapshotNode>>([
96-
{ editable: true },
97-
{ password: true },
98100
{ hintShowing: true },
99101
{ selectionStart: 2 },
100102
{ selectionEnd: 3 },
@@ -319,3 +321,28 @@ test('force-full and raw snapshots do not emit unchanged metadata', () => {
319321
buildUnchangedSnapshotMetadata({ previous, current, options: { raw: true } }),
320322
).toBeUndefined();
321323
});
324+
325+
test.each([{ editable: true }, { password: true }])(
326+
'unchanged metadata detects RN interpretation eligibility changes: %j',
327+
(change) => {
328+
const node = {
329+
index: 0,
330+
depth: 0,
331+
type: 'Other',
332+
role: 'RCTViewComponentView',
333+
label: 'Preferences',
334+
value: 'checkbox, checked',
335+
checked: false,
336+
};
337+
const previous = snapshot('Preferences', {
338+
nodes: attachRefs([interpretIosReactNativeValue(node)]),
339+
});
340+
const current = snapshot('Preferences', {
341+
nodes: attachRefs([interpretIosReactNativeValue({ ...node, ...change })]),
342+
});
343+
expect(previous.nodes[0]?.iosValueSemantics?.checked).toBe(true);
344+
expect(current.nodes[0]?.iosValueSemantics).toBeUndefined();
345+
expect(current.nodes[0]?.checked).toBe(previous.nodes[0]?.checked);
346+
expect(buildUnchangedSnapshotMetadata({ previous, current, options: {} })).toBeUndefined();
347+
},
348+
);

‎src/commands/capture/runtime/snapshot-unchanged.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ function areSnapshotPresentationsEquivalent(
7676
);
7777
}
7878

79-
// Native text-entry/visibility facts are not rendered; refs and process ids are volatile.
79+
// Some native text-entry/visibility facts are not rendered; refs and process ids are volatile.
8080
// Inheritance markers are output-only: this comparison runs before label deduplication.
8181
type ComparableSnapshotNode = Omit<
8282
SnapshotNode,
8383
| 'ref'
8484
| 'pid'
85-
| 'editable'
86-
| 'password'
8785
| 'hintShowing'
8886
| 'selectionStart'
8987
| 'selectionEnd'
@@ -114,6 +112,8 @@ const PRESENTATION_SCALAR_FIELDS = {
114112
contentDescription: true,
115113
identifier: true,
116114
enabled: true,
115+
editable: true,
116+
password: true,
117117
selected: true,
118118
checked: true,
119119
focused: true,

0 commit comments

Comments
 (0)