Skip to content

fix: map android ToggleButton to switch role and fix stale locator docs - #256

Merged
gmegidish merged 2 commits into
mainfrom
fix/togglebutton-switch-role-and-docs
Jul 30, 2026
Merged

gmegidish merged 2 commits into
mainfrom
fix/togglebutton-switch-role-and-docs

Conversation

@gmegidish

Copy link
Copy Markdown
Member

Summary

  • getByRole('switch') didn't match android.widget.ToggleButton even though the locators doc claimed it did β€” ROLE_TYPE_MAP.switch had an unreachable 'toggle' entry instead of 'togglebutton'. Added the correct entry.
  • Locators doc said iOS TextView is filtered out before reaching the query engine; mobilecli's acceptedTypes (pinned at 0.3.89) already surfaces it, so the doc was stale.
  • Documented the AndroidX/Material Components subclasses (AppCompatButton, MaterialButton, FloatingActionButton, AppCompatEditText, TextInputEditText, AppCompatTextView, MaterialTextView, AppCompatImageView, ShapeableImageView) that ROLE_TYPE_MAP already recognized but the docs never listed.

Test plan

  • Added a ToggleButton case to the existing "fully-qualified native types" test suite in query-engine.test.ts, confirmed it passes: npx playwright test --config=tests/mobilewright.config.ts packages/mobilewright-core/src/query-engine.test.ts -g "switch role"
  • npm run lint passes

@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bdc2fbc3-c4a0-417f-b1b1-93bfb1a3d63f

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between d85e099 and 1e32704.

πŸ“’ Files selected for processing (1)
  • packages/mobilewright-core/src/query-engine.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/mobilewright-core/src/query-engine.ts

Walkthrough

The switch role mapping now recognizes android.widget.ToggleButton alongside existing switch types. Android query-engine fixtures and assertions were updated to verify both native types are returned. The locator guide adds AndroidX and Material Components class mappings for getByRole() and updates the iOS source-filtering note to include TextView.

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Title check βœ… Passed It clearly summarizes the main change: mapping Android ToggleButton to switch and updating stale locator docs.
Description check βœ… Passed It matches the changeset by describing the ToggleButton fix, stale iOS note, and added AndroidX/Material documentation.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/togglebutton-switch-role-and-docs

Comment @coderabbitai help to get the list of available commands.

@gmegidish
gmegidish merged commit 54b2126 into main Jul 30, 2026
7 checks passed
@gmegidish
gmegidish deleted the fix/togglebutton-switch-role-and-docs branch July 30, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant