fix(verifier): label editable fields by hint, not the typed value

an editable field's own text is its transient content; prefer the hint
so the field is named by purpose and the label stays stable.
This commit is contained in:
pj committed 2026-07-13 08:21:49 +05:30
1 parent 9845b89173
commit b65b8373e6
2 files changed
+26

No files matched your search

+19
View File
@@ -100,6 +100,25 @@ func TestCandidatesTypingExposesInputType(t *testing.T) {
}
}
func TestCandidatesLabelsEditableFieldByHintNotTypedValue(t *testing.T) {
// A field already showing "99" must still be labeled by its purpose (the
// hint), not by its transient content, so the description stays stable.
tree := `{
"attributes": {"bounds": "[0,0,400,800]"},
"children": [
{"attributes": {"resource-id": "Amt", "class": "EditText", "hintText": "Amount", "text": "99", "bounds": "[0,0,400,100]"}, "enabled": true, "children": []}
]
}`
v := enumVerifier(t, "{kind:'builtin', verb:'typing'}", tree)
candidates := v.Candidates()
if hasCandidate(candidates, `Type into "99" (number)`) || hasCandidate(candidates, `Type into "99"`) {
t.Errorf("editable field labeled by its typed value: %v", descriptions(candidates))
}
if !hasCandidate(candidates, `Type into "Amount" (number)`) {
t.Errorf("want the field labeled by its hint, got %v", descriptions(candidates))
}
}
func TestCandidatesFoldsGesturesIntoDirectionalScrolls(t *testing.T) {
v := enumVerifier(t,
"{kind:'weighted', branches:[[1,{kind:'builtin',verb:'scrolls'}],[1,{kind:'builtin',verb:'swipes'}]]}",