Skip to content

Commit 0b8d701

Browse files
thymikeeclaude
andcommitted
test(android): run the field value golden through the ADB adapter
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent af8f1b1 commit 0b8d701

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎packages/platform-android/src/__tests__/ui-hierarchy-field-metadata.test.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from 'node:fs';
12
import { expect, test } from 'vitest';
23
import { buildUiHierarchySnapshot, parseUiHierarchyTree } from '../ui-hierarchy.ts';
34

@@ -75,3 +76,42 @@ test('ADB parses native field evidence and hint state before assigning values',
7576
[undefined, undefined, undefined],
7677
]);
7778
});
79+
80+
const fieldValues = JSON.parse(
81+
readFileSync(
82+
new URL('../../../../contracts/fixtures/android-field-values.json', import.meta.url),
83+
'utf8',
84+
),
85+
) as {
86+
cases: {
87+
name: string;
88+
input: {
89+
type: string;
90+
text?: string;
91+
editable?: boolean;
92+
password?: boolean;
93+
hintShowing?: boolean;
94+
};
95+
value: string | null;
96+
}[];
97+
};
98+
99+
test.each(fieldValues.cases)(
100+
'ADB adapter applies the field value contract: $name',
101+
({ input, value }) => {
102+
const attrs = [
103+
`class="${input.type}"`,
104+
input.text === undefined ? '' : `text="${input.text}"`,
105+
input.editable === undefined ? '' : `editable="${input.editable}"`,
106+
input.password === undefined ? '' : `password="${input.password}"`,
107+
input.hintShowing === undefined ? '' : `hint-showing="${input.hintShowing}"`,
108+
].join(' ');
109+
const tree = parseUiHierarchyTree(
110+
`<hierarchy><node ${attrs} resource-id="field" bounds="[0,0][200,100]" /></hierarchy>`,
111+
);
112+
const { nodes } = buildUiHierarchySnapshot(tree, undefined, { raw: true });
113+
const node = nodes.find((candidate) => candidate.identifier === 'field');
114+
expect(node).toBeDefined();
115+
expect(node?.value).toBe(value ?? undefined);
116+
},
117+
);

0 commit comments

Comments
 (0)