Skip to content

test(#1583): add tests for ui design-system primitives - #1647

Merged
hman38705 merged 1 commit into
solutions-plug:mainfrom
wendyamoni-creator:fix/1583-ui-primitive-tests
Sep 27, 2026
Merged

hman38705 merged 1 commit into
solutions-plug:mainfrom
wendyamoni-creator:fix/1583-ui-primitive-tests

Conversation

@wendyamoni-creator

Copy link
Copy Markdown
Contributor

Summary

Closes #1583.

Adds 134 tests across 6 new files under frontend/src/components/ui/__tests__/, one per primitive. No config changes needed — Jest picks them up automatically.

Coverage per primitive

File Tests What's covered
Button.test.tsx 25 default type=button, variant classes, isLoading (disabled + aria-busy + spinner + icons hidden), disabled prop, leftIcon/rightIcon, ref forwarding
Card.test.tsx 17 renders children, interactive / noPadding modifier classes, CardHeader / CardTitle (as prop) / CardBody / CardFooter, composition, ref forwarding
Select.test.tsx 22 label/htmlFor, auto-generated vs caller-supplied id, required asterisk, hint text, error in role=alert, aria-invalid, aria-describedby (error only / hint+error / absent), user selection, ref forwarding
TextInput.test.tsx 21 same label/hint/error pattern, ui-input--error class, user input, attribute forwarding, ref forwarding
Textarea.test.tsx 21 same pattern + rows=4 default, custom rows, ui-textarea--error class, ref forwarding
Modal.test.tsx 28 open gate, title/description/children/footer slot, aria-modal / aria-labelledby / aria-describedby, close via button / backdrop / Escape, all disable* flags, body scroll lock, first-focusable focus after setTimeout(0), previous-focus restore on close, Tab/Shift+Tab focus trap, removeEventListener cleanup

Test results

PASS src/components/ui/__tests__/Button.test.tsx
PASS src/components/ui/__tests__/Card.test.tsx
PASS src/components/ui/__tests__/Select.test.tsx
PASS src/components/ui/__tests__/TextInput.test.tsx
PASS src/components/ui/__tests__/Textarea.test.tsx
PASS src/components/ui/__tests__/Modal.test.tsx

Test Suites: 6 passed, 6 total
Tests:       134 passed, 134 total

No regressions introduced (pre-existing failures in the broader suite are unrelated vitest/module-alias issues in other files).

Adds 6 test files under frontend/src/components/ui/__tests__/:

Button.test.tsx (25 tests)
- default type=button, variant classes, primary default
- disabled prop: aria-disabled, no click
- isLoading: disabled, aria-busy, spinner shown, icons hidden
- leftIcon/rightIcon visible when not loading
- ref forwarding, className merge

Card.test.tsx (17 tests)
- renders children, base class, className merge, attribute forwarding
- interactive: ui-card--interactive class applied/absent
- noPadding: ui-card--no-padding class applied/absent
- CardHeader/CardTitle(as prop)/CardBody/CardFooter classes and rendering
- ref forwarding, full composition test

Select.test.tsx (22 tests)
- renders select + options, caller-supplied id respected
- label/htmlFor association, required asterisk, hint text
- error: role=alert, aria-invalid, aria-describedby (error only / hint+error)
- aria-describedby absent when no hint/error
- user selection interaction, ref forwarding

TextInput.test.tsx (21 tests)
- renders input, label/htmlFor, id override, required asterisk, hint
- error: role=alert, aria-invalid, ui-input--error class, aria-describedby
- hint+error both in aria-describedby, absent when neither present
- user input, attribute forwarding, ref forwarding

Textarea.test.tsx (21 tests)
- same pattern as TextInput plus rows=4 default and custom rows value
- ui-textarea--error class, ref forwarding

Modal.test.tsx (28 tests)
- returns null when open=false, renders when open=true
- title, description, children, footer slot, close button visibility
- aria-modal, aria-labelledby, aria-describedby wiring
- close via button, backdrop, Escape key; all disable* flags
- disableBackdropDismiss=true: no close on backdrop, no close button
- body scroll lock on open, restored on close and unmount
- first focusable focused after setTimeout(0); prev focus restored on close
- Tab/Shift+Tab focus trap; removeEventListener on close and unmount

All 134 tests pass. No config changes needed.
@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@wendyamoni-creator Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705
hman38705 merged commit e7f9a74 into solutions-plug:main Sep 27, 2026
15 of 62 checks passed
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.

Design-system primitives (Button, Card, Select, TextInput, Textarea, ui/Modal) are untested

2 participants