Skip to content

Add label html utils - #81

Merged
bolivier merged 1 commit into
mainfrom
add-label-html-helpers
Feb 13, 2026
Merged

bolivier merged 1 commit into
mainfrom
add-label-html-helpers

Conversation

@bolivier

@bolivier bolivier commented Feb 13, 2026 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Users can now query HTML elements by their visible label text. The feature supports multiple labeling mechanisms including for attributes, wrapping label elements, aria-label attributes, and aria-labelledby references. Both single and multiple element queries are supported.
  • Tests

    • Added comprehensive test coverage for label-based element queries and edge cases.

@coderabbitai

coderabbitai Bot commented Feb 13, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces label-based element querying to the rapid-test HTML testing library. It adds a new rapid-test.html.label module with get-by-label and get-all-by-label functions, extends utilities for ID lookup and pattern matching, and updates the public API exports to include these new label-based functions alongside existing role-based queries.

Changes

Cohort / File(s) Summary
New Label Module
src/main/rapid_test/html/label.clj
Introduces label-based element query functions supporting four labeling mechanisms: for attribute, wrapping label ancestor, aria-label, and aria-labelledby. Implements get-by-label and get-all-by-label using hiccup zipper traversal.
API Exports
src/main/rapid_test/html.clj
Expands re-exports to include label-based query functions (get-by-label, get-all-by-label) from the new rapid-test.html.label module, alongside existing role-based exports.
Utility Enhancements
src/main/rapid_test/html/utils.clj
Adds find-by-id function for ID-based element lookup and text-match? for pattern/string matching; refactors matches-options? to use text-match? for name-based matching logic.
Test Coverage
test/main/rapid_test/html_test.clj
Adds get-by-label-test and get-all-by-label-test covering multiple labeling strategies, edge cases, and empty result scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Create first html testing utils #78: Extends the rapid-test.html API with label-based query functions, directly building on the existing namespace structure.
  • Html testing utils #79: Previously introduced role-based functions and utilities in rapid-test.html; this PR parallels that pattern by adding label-based alternatives.

Poem

🐰 A label-based quest, through hiccup trees we hop,
With aria and for-loops, we'll never miss a stop,
Four ways to find your elements, all bundled up so tight,
By text and ID and ARIA—your tests will shine so bright! ✨

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-label-html-helpers

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.

❤️ Share

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

@bolivier
bolivier merged commit 0e4761d into main Feb 13, 2026
1 of 2 checks passed
@bolivier
bolivier deleted the add-label-html-helpers branch February 13, 2026 22:47
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