Skip to content

test: add hover/focus parity tests for PrimaryButton (Closes #1433) - #1621

Open
waterWang wants to merge 2 commits into
Remitwise-Org:mainfrom
waterWang:test/primary-button-hover-focus-1433
Open

test: add hover/focus parity tests for PrimaryButton (Closes #1433)#1621
waterWang wants to merge 2 commits into
Remitwise-Org:mainfrom
waterWang:test/primary-button-hover-focus-1433

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Summary

Adds a comprehensive test suite for the PrimaryButton component covering hover/focus parity and related behavior.

What's covered (17 tests)

  • Rendering — renders text and complex children
  • Default styling — base layout/brand/sizing/transition classes
  • Hoverhover:bg-brand.redHover present
  • Focusfocus:outline-none focus:ring-2 focus:ring-brand.red focus:ring-offset-2 present
  • Disableddisabled attribute, aria-disabled="true", click prevention, disabled visual classes
  • className merging — custom classes merged with defaults
  • forwardRef — ref forwards to the real <button>
  • Attributestype, aria-label, data-* passthrough
  • Interaction parity — hover class persists when the button is focused (no hover/focus conflict)

Implementation notes

  • Test file lives at components/ui/PrimaryButton.test.tsx (matches existing component test convention, e.g. ChipList.test.tsx, ShortcutTooltip.test.tsx).
  • Uses @testing-library/react + @testing-library/user-event, consistent with the rest of the repo.
  • Verified with NODE_ENV=development (production React build rejects act()).

Closes #1433

Closes Remitwise-Org#1421)

Collapse the three identical Tailwind classnames helpers into a single
canonical implementation in lib/utils/cn.ts. lib/utils.ts and
lib/utils/index.ts now re-export from it instead of duplicating the
same twMerge(clsx(...)) logic.

Runtime behavior is unchanged; all cn-related tests pass.
…e-Org#1433)

Add 17 tests covering:
- Rendering with children (text and complex)
- Default visual classes (layout, brand, sizing, transition)
- Hover classes (hover:bg-brand.redHover)
- Focus classes (focus:ring-2, focus:ring-brand.red)
- Disabled state (disabled attribute, ARIA, click prevention)
- Custom className merging with defaults
- forwardRef support
- HTML button attributes (type, aria-label, data-*)
- Interaction parity: hover + focus coexistence
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.

Add tests for hover/focus parity on the primary button

1 participant