Repository navigation
feat(driver-mobilecli): surface isSelected/isChecked/isFocused from dump.ui - #252
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe mobile CLI element interface now supports optional 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The
The change is additive (three optional fields + guarded mapping), so it's a no-op until the on-device agent emits |
|
@sjy hey! thanks for the pull request! I can't believe it was missing tbh. thank you for finding this. Can you please sign your commit so I can merge? |
…ump.ui The `ViewNode` protocol already declares `isSelected` / `isChecked` / `isFocused`, and `@mobilewright/core`'s `expect` ships `toBeSelected()` / `toBeChecked()`, but `elementToViewNode` never populated them — so those matchers read `false` for every node. Map the fields through from the mobilecli element (guarded on `typeof === 'boolean'`, so they stay `undefined` when the agent omits them — no behavior change until the agent emits them). The on-device agent must still include `selected`/`checked`/`focused` (and ideally Android `stateDescription`) in each `device.dump.ui` element for these to be non-undefined; tracking that separately. Refs mobile-next#250
738b36b to
4e3eda8
Compare
|
Done — the commit is now SSH-signed and shows Verified. Ready to merge whenever you are. Thanks for the quick look! 🙏 |
|
Hi @sjy , I wonder if it's possible to get I checked enabled, but it always returns |
|
@tranvanhien187 omg. that was missing. added that, see mobile-next/mobilecli#317 . will be merged after e2e tests run. |
Android's `dump ui` reports enabled/checked/focused but not `selected`, so
single-select controls (tabs, chips, radio-style option pickers — anything
using Compose `semantics { selected = ... }` → AccessibilityNodeInfo
isSelected) can't be asserted for their selected state.
Adds `Selected *bool` (omitted when false, matching the Checked convention) to
ScreenElement, populated on both the uiautomator XML path (selected="true"
attr) and the devicekit JSON path in devices/android.go — exactly parallel to
the enabled/checked handling added in #317.
Pairs with the driver-side mapping already merged in
mobile-next/mobilewright#252 (which maps this through to ViewNode.isSelected /
expect().toBeSelected()).
Test plan:
- go build ./... ; go vet ./types/ ./devices/
- New unit tests in devices/android_elements_test.go covering selected /
unselected nodes on both the uiautomator and devicekit dump paths.
Co-authored-by: sjy <1523060+sjy@users.noreply.github.com>
Summary
ViewNodealready declaresisSelected/isChecked/isFocused, and@mobilewright/core'sexpectshipstoBeSelected()/toBeChecked()— butelementToViewNodenever populated those fields, so the matchers readfalsefor every node.This maps the three flags through from the mobilecli element. Reads are guarded on
typeof === 'boolean', so they stayundefinedwhen the agent omits them — no behavior change until the on-device agent emits them.Diff
MobilecliElement: add optionalselected/checked/focused.elementToViewNode: map them toisSelected/isChecked/isFocused.Scope / follow-up
This is the driver half only. For the values to become non-
undefined, the on-device agent must includeselected/checked/focused(fromAccessibilityNodeInfo) in eachdevice.dump.uielement — and ideally AndroidstateDescription, which Jetpack Compose populates for aselectedsemantic on non-Role.Tabnodes. Tracking that separately.Refs #250
Test
elementToViewNodeis a private function with no unit-test seam today (only the live-serverintegration.test.ts), so no unit test is added here to avoid exporting internals.tsc -bbuilds clean. Happy to add a fixture/test if you'd prefer to expose it.