Skip to content

test: cover Switch, PasswordField and SearchField - #1330

Open
cookieark7 wants to merge 3 commits into
ClickHouse:mainfrom
cookieark7:test/switch-passwordfield-searchfield
Open

cookieark7 wants to merge 3 commits into
ClickHouse:mainfrom
cookieark7:test/switch-passwordfield-searchfield

Conversation

@cookieark7

@cookieark7 cookieark7 commented Nov 28, 2026 •

Copy link
Copy Markdown

Description

Add unit tests for three form components that had no test file:

  • Switch: accessible name from label, aria-checked, onCheckedChange, label click, disabled, custom id, ref and rest-prop forwarding.
  • PasswordField: masked input tied to its label, onChange(value, event), the visibility toggle (only shown once there is a value), disabled, ref and native attribute forwarding.
  • SearchField: search and filter icons, onChange, the clear button (default, clear={false}, disabled), focusing the input from the icon, ref forwarding.

Links and tickets

None.

Good to know

Tests only, no component code changed, so no changeset. While writing them I noticed Switch renders aria-label="undefined" when no label is passed. I left that out of this PR to keep it test-only.

Checklist

  • Breaking changes? (add migration notes in changesets)
  • Visual changes? (specify in changesets)
  • Design review needed?

Contribution

  • Sufficient research before PR
  • Self-reviewed the PR
  • Manually tested the changes (when applies - visual confirmation in Storybook)
  • build and build-storybook work locally
  • Tests and Stories are aligned with the changes

Accessibility

Skipped: no component markup, behavior or styles changed.

🤖 Generated with Claude Code


Note

Low Risk
Test-only additions with no runtime, styling, or API changes to the components under test.

Overview
Adds unit test suites for three previously untested form components: PasswordField, SearchField, and Switch. All tests use the shared renderCUI helper and Testing Library patterns consistent with other component tests.

PasswordField tests label association, masked type="password", onChange(value, event), show/hide visibility toggle only when non-empty, toggle flipping type between password and text, disabled state, ref forwarding, and passthrough of native input props.

SearchField tests label wiring, default search vs isFilter filter icon, onChange, optional clear button behavior (clear={false}, empty vs valued, clears to ''), disabled input/clear button, focusing input via icon click, and ref forwarding.

Switch tests accessible name from label, aria-checked sync with checked, onCheckedChange from switch and label clicks, disabled blocking toggles, custom id linking label and control, ref on the switch button, and className/data attribute forwarding.

No production component code is modified in this PR.

Reviewed by Cursor Bugbot for commit c9b8f61. Bugbot is set up for automated code reviews on this repo. Configure here.

Add unit tests for three form components that had none: labelling,
controlled value and change handling, disabled state, ref forwarding,
the PasswordField visibility toggle and the SearchField icon and clear
button.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 03c3df5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@XOP XOP added the infra CI, workflows, scripts label Nov 30, 2026
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Chromatic Storybook

Check Status Link
Storybook ✅ 672 stories published Open Storybook
UI Tests ✅ 672 tests unchanged Open build

Built from commit: 72cf7303d2d8f19c70e909caba25388f31d97779 · Chromatic run

Statuses as of the end of the run. The build link shows the live review state.

The icon is decorative, so these queries would break once it gets
aria-hidden. Query with hidden: true and assert the aria-label instead.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@cookieark7
cookieark7 requested a review from XOP November 30, 2026 17:58

This branch has not been deployed

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

Labels

infra CI, workflows, scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants