|
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' }, |
@@ -100,8 +104,6 @@ test.each<Partial<SnapshotNode>>([ |
100 | 104 | }); |
101 | 105 |
|
102 | 106 | test.each<Partial<SnapshotNode>>([ |
103 | | - { editable: true }, |
104 | | - { password: true }, |
105 | 107 | { hintShowing: true }, |
106 | 108 | { selectionStart: 2 }, |
107 | 109 | { selectionEnd: 3 }, |
@@ -326,3 +328,28 @@ test('force-full and raw snapshots do not emit unchanged metadata', () => { |
326 | 328 | buildUnchangedSnapshotMetadata({ previous, current, options: { raw: true } }), |
327 | 329 | ).toBeUndefined(); |
328 | 330 | }); |
| 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 | +); |
0 commit comments