|
1 | 1 | 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'; |
2 | 4 | import fc from 'fast-check'; |
3 | 5 | import { |
4 | 6 | buildUnchangedSnapshotMetadata, |
@@ -63,6 +65,8 @@ test('unchanged metadata detects visible label changes', () => { |
63 | 65 |
|
64 | 66 | test.each<Partial<SnapshotNode>>([ |
65 | 67 | { index: 1 }, |
| 68 | + { editable: true }, |
| 69 | + { password: true }, |
66 | 70 | { depth: 1 }, |
67 | 71 | { parentIndex: 1 }, |
68 | 72 | { type: 'TextField' }, |
@@ -93,8 +97,6 @@ test.each<Partial<SnapshotNode>>([ |
93 | 97 | }); |
94 | 98 |
|
95 | 99 | test.each<Partial<SnapshotNode>>([ |
96 | | - { editable: true }, |
97 | | - { password: true }, |
98 | 100 | { hintShowing: true }, |
99 | 101 | { selectionStart: 2 }, |
100 | 102 | { selectionEnd: 3 }, |
@@ -319,3 +321,28 @@ test('force-full and raw snapshots do not emit unchanged metadata', () => { |
319 | 321 | buildUnchangedSnapshotMetadata({ previous, current, options: { raw: true } }), |
320 | 322 | ).toBeUndefined(); |
321 | 323 | }); |
| 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 | +); |
0 commit comments