Skip to content

test(e2e): convert getByText clicks to exact getByRole - #63

Merged
iskhakovt merged 1 commit into
mainfrom
e2e-getbyrole-click-sweep
Apr 19, 2026
Merged

iskhakovt merged 1 commit into
mainfrom
e2e-getbyrole-click-sweep

Conversation

@iskhakovt

Copy link
Copy Markdown
Owner

Summary

  • Follow-up to test(e2e): use exact name matching on getByRole across all specs #61. getByText substring-matches case-insensitively, so any two DOM nodes whose text overlaps can fight over a selector — surfaced when new helper copy in feat(web): explain why we ask for body type #62 tripped a getByText("Each person") that was meant to hit a radio button.
  • Converts getByText(X).click() patterns across all e2e specs:
    • Buttons -> getByRole("button", { name: X, exact: true })
    • Radios (ToggleGroup) -> getByRole("radio", { name: X, exact: true })
    • Category rows ("Essentials", "Adventurous") render compound button text like "Essentials 0/15", so keep getByText but add exact: true — matches the pure-label span and bubbles to the parent button.
  • Three call sites on QuestionCard's back button updated to its real accessible name (aria-label="Previous question").
  • Pure-text assertions (expect(...).toBeVisible() / .toHaveCount) left alone — substring-matching there is low-risk (extra match = still visible, no-op) and occasionally convenient.

Test plan

  • pnpm -r typecheck
  • pnpm test:e2e (48/48)
  • pnpm test:visual:docker (18/18)

🤖 Generated with Claude Code

getByText substring-matches case-insensitively, so any two DOM nodes
whose text overlaps can fight over a selector (e.g. a button's "Each
person" label and a helper paragraph that mentions "each person" will
both match getByText("Each person")). Follows the direction of #61,
which tightened getByRole calls — this does the same for the getByText
clicks that slipped through.

- Buttons: getByText("X").click() -> getByRole("button", { name: "X", exact: true }).click()
- Radios (ToggleGroup): getByText("X").click() -> getByRole("radio", { name: "X", exact: true }).click()
- Category rows ("Essentials", "Adventurous") render compound button
  text ("Essentials 0/15"), so keep getByText but add exact: true —
  matches the pure-label <span> and bubbles to the parent button.
- QuestionCard's back button uses aria-label="Previous question" —
  three call sites updated to match the accessible name.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • review-ready

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f07a684-8920-404d-96af-d94aa2dfc32d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e-getbyrole-click-sweep

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

@iskhakovt
iskhakovt enabled auto-merge (squash) April 19, 2026 20:19
@iskhakovt
iskhakovt merged commit bee678f into main Apr 19, 2026
8 checks passed
@iskhakovt
iskhakovt deleted the e2e-getbyrole-click-sweep branch April 19, 2026 20:24
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant