fix(android): carry the content description beside the label on the snapshot node

Merged
OK
2mo ago
+37-1

Summary

An Android node is labelled by its text and falls back to the content description only when it has none (ui-hierarchy.ts, label: text || desc), so an accessibility label set beside visible text never reached the wire: a labelled text view was named by its content, a filled field by its value, an empty field by its hint, a filled password field by its dots. TalkBack reads the content description in each case.

The parser already read content-desc; the hierarchy node now carries it as contentDescription whenever it is not already the label, through the raw snapshot node, the unchanged-snapshot comparison, and the find/get digest. label is unchanged, so nothing that keys on it moves. 7 files, +37/-1.

agent-device snapshot --json --platform android
# {"type":"android.widget.EditText","label":"Ada Lovelace","contentDescription":"Name field","identifier":"name-input"}

Validation

Tested at c6dbc8a49; the test-only follow-up d5ddd3923 passed the same gate.

  • pnpm check:quick and pnpm check:affected --run --base a363a0239: all runnable checks passed (format, lint, typecheck, layering, fallow, build, 852 test files).
  • src/__tests__/android-ui-hierarchy.test.ts: 39 tests, one new for text beside a description, a description equal to the label (not repeated), and a hinted empty field.
  • Live on an Android emulator (API 36, tester-army/e2e's mobile benchmark app, helper 0.21.13): the header and three text fields carry their accessibilityLabel as contentDescription; the status-bar clock carries its spoken time beside its label. Text presentation unchanged.
  • Risk: none identified; additive, absent without a distinct description. The text snapshot does not show it yet (follow-up).

Motivation: tester-army/e2e#500.