fix(android): carry an empty text on a node labelled by its content description

Merged
VZ
3d ago
+44-7

Summary

An Android node is labelled by its text, else its content description; contentDescription is published only when it differs from the label (#2912). So a view with a description and no text was published exactly like a view showing that string: get text answered saved_task for an empty view.

The node now carries text when the view's text is not already the label: an empty string on a view labelled by its description, absent elsewhere. label and contentDescription are unchanged, so text ?? label is the text the view shows. Both Android producers (ADB helper, Appium source) follow the rule; the field joins the unchanged-snapshot comparison and the find/get digest. 10 files, +44/-7. Closes #4530.

agent-device get attrs 'id="dev.retest.bench.tasks:id/saved_task"' --json
# base: {"label":"saved_task","identifier":"…:id/saved_task"}
# head: {"label":"saved_task","text":"","identifier":"…:id/saved_task"}

Validation

Tested at bfd8ce71b, base ddbfc8556.

  • pnpm check:affected --run --head bfd8ce71b: passes up to unit, where 19,762 pass and 6 fail. Base-blocked: the same 6 fail on ddbfc8556 alone (Path is a directory in symlink cases of runner-artifact-manifest, runner-toolchain-identity, code-signature; macOS 27.2, Node 24.12).
  • The new case in src/__tests__/android-ui-hierarchy.test.ts fails on base and passes on head.
  • Live, Android 15 emulator (API 35), helper 0.21.38-nightly.20261113.167: base and head snapshots, regular and raw, differ only by text: "" on description-only nodes. Once the view shows saved_task, its node has no text.
  • Not run: helper build (no helper source changed), Appium on a device, CI device lanes.
  • Risk: JSON grows by "text":"" on description-only nodes.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.