fix(android): carry accessibility selected state into snapshots

Merged
TH
1mo ago
+225-16

Summary

Android never carried the accessibility selected state. The snapshot helper did not serialize it, and the host reads only the helper's XML, so no later layer could recover it: get attrs had no field, no snapshot node was marked, is selected could not match, and assertVisible {id, selected: true} failed with "Maestro visible condition did not match" on a visible element — while selected: false matched every Android node.

The helper now emits both answers, like enabled and password: an unselected control answers false, a helper older than the attribute answers nothing. Parser, Android hierarchy node, and published node carry it to get attrs, the [selected] marker, selectors, and Maestro qualifiers.

Smaller second fix: snapshot lines render [selected] on the default formatter path too. --settle/diff already compared selection, so a tab tap produced a changed pair whose two lines looked identical.

13 files. Deliberately not here: checked/checkable/long-clickable (still #1832 residue), Android focused's omitted-false encoding, and Apple's true-or-absent selected — on Apple a selected: false assertion still passes for a selected control.

Validation

Commit 602b731. pnpm check:affected --run passed (3715 selected tests + command-docs); pnpm test:unit 9753 passed; lint and typecheck clean. Regression evidence: the 5 platform selection tests, the selector-read test, and the new diff test fail with the mapping or the line marker rendered inert.

Manual device evidence, Android 16 / Pixel 7 CI AVD (not an automated lane): on the Dialer tab bar, get attrs @e31 reports "selected": true, and press 'id=…tab_call_history' --settle prints - @e40 [group] "Keypad" [selected] / + @e31 [group] "Home" [selected]. A flow asserting assertVisible {id, selected: true} passes; with a helper APK built from HEAD the same flow fails with the issue's exact message and no selected field. Provider integration and coverage remain with GitHub CI.

Closes #2462