Skip to content

Commit ce6ccfb

Browse files
committed
fix(snapshot): compare iOS value interpretation eligibility
1 parent 6b4d76a commit ce6ccfb

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' },
@@ -100,8 +104,6 @@ test.each<Partial<SnapshotNode>>([
100104
});
101105

102106
test.each<Partial<SnapshotNode>>([
103-
{ editable: true },
104-
{ password: true },
105107
{ hintShowing: true },
106108
{ selectionStart: 2 },
107109
{ selectionEnd: 3 },
@@ -326,3 +328,28 @@ test('force-full and raw snapshots do not emit unchanged metadata', () => {
326328
buildUnchangedSnapshotMetadata({ previous, current, options: { raw: true } }),
327329
).toBeUndefined();
328330
});
331+
332+
test.each([{ editable: true }, { password: true }])(
333+
'unchanged metadata detects RN interpretation eligibility changes: %j',
334+
(change) => {
335+
const node = {
336+
index: 0,
337+
depth: 0,
338+
type: 'Other',
339+
role: 'RCTViewComponentView',
340+
label: 'Preferences',
341+
value: 'checkbox, checked',
342+
checked: false,
343+
};
344+
const previous = snapshot('Preferences', {
345+
nodes: attachRefs([interpretIosReactNativeValue(node)]),
346+
});
347+
const current = snapshot('Preferences', {
348+
nodes: attachRefs([interpretIosReactNativeValue({ ...node, ...change })]),
349+
});
350+
expect(previous.nodes[0]?.iosValueSemantics?.checked).toBe(true);
351+
expect(current.nodes[0]?.iosValueSemantics).toBeUndefined();
352+
expect(current.nodes[0]?.checked).toBe(previous.nodes[0]?.checked);
353+
expect(buildUnchangedSnapshotMetadata({ previous, current, options: {} })).toBeUndefined();
354+
},
355+
);

‎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)