Skip to content

test(#1582): add tests for admin Form.tsx and Modal.tsx primitives - #1646

Merged
hman38705 merged 2 commits into
solutions-plug:mainfrom
wendyamoni-creator:fix/1582-admin-form-modal-tests
Sep 27, 2026
Merged

hman38705 merged 2 commits into
solutions-plug:mainfrom
wendyamoni-creator:fix/1582-admin-form-modal-tests

Conversation

@wendyamoni-creator

@wendyamoni-creator wendyamoni-creator commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1582.

admin/Form.tsx and admin/Modal.tsx had no test coverage. This PR adds two new test files under frontend/src/components/admin/__tests__/ with 79 tests covering all acceptance criteria.

What's tested

Form.test.tsx (442 lines)

Area Coverage
Form container noValidate, onSubmit, className merging, attribute forwarding
FormField label/htmlFor association, required * marker, hint text, role=alert error message, has-error class
Input aria-invalid, aria-describedby on error, ref forwarding, user input
Textarea Same as Input + default rows=4, ref forwarding
Select aria-invalid, aria-describedby, ref forwarding
Button Variants, isLoading disables button + hides icons, fullWidth, onClick blocked when loading, ref forwarding
StatusAlert role=alert for error type, role=status for others, dismiss button, children
Integration Validation error display → clear cycle, submit-in-progress state, success alert

Modal.test.tsx (336 lines)

Area Coverage
Rendering isOpen gate, title, description, aria-modal, aria-labelledby, aria-describedby, close button visibility
Open/close Close button, backdrop click, Esc key, all disable* flag combinations, isOpen→false unmount
Body scroll lock overflow=hidden on open, restored on close and unmount
Focus management First focusable focused after 50 ms timeout, previous element restored on close, Tab wraps to first, Shift+Tab wraps to last
Cleanup removeEventListener called on both close and unmount

Test results

PASS src/components/admin/__tests__/Form.test.tsx
PASS src/components/admin/__tests__/Modal.test.tsx

Test Suites: 2 passed, 2 total
Tests:       79 passed, 79 total

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

…ion, and balance

Covers all four acceptance criteria from issue solutions-plug#1581:
- No wallet connected → wallet.connect() is called, placeBet is not
- Client-side validation: missing/zero/negative/NaN amount show errors
- Successful submit: api.placeBet called with correct args, tx status
  shown via role=status, onSubmitted callback fires with txHash/outcome/amount
- Insufficient balance: fetchNativeBalance called fresh on failure,
  INSUFFICIENT_BALANCE_MESSAGE + live balance rendered in alert;
  null balance falls back to 'unavailable'

All modules (useWallet, api, fetchNativeBalance) are mocked — no
network traffic in tests.
… primitives

Form.test.tsx (442 lines) covers:
- Form container: noValidate, onSubmit, className merging, attribute forwarding
- FormField: label/htmlFor association, required marker, hint text,
  error message in role=alert, has-error class, children
- Input/Textarea/Select: aria-invalid, aria-describedby on error,
  ref forwarding, default rows (Textarea)
- Button: variants, isLoading disables + hides icons, fullWidth class,
  onClick blocked when loading, ref forwarding
- StatusAlert: role=alert for error type, role=status for others,
  onDismiss button, children
- Integration: validation error display + clear cycle, loading state,
  success alert after submit

Modal.test.tsx (336 lines) covers:
- Rendering: isOpen gate, title, description, aria-modal, aria-labelledby,
  aria-describedby, close button visibility with disableBackdropDismiss
- Open/close: close button click, backdrop click, Esc key, all disable
  flag combinations, unmount on isOpen→false
- Body scroll lock: overflow=hidden on open, restored on close/unmount
- Focus management: first focusable focused after 50ms timeout, previous
  element restored on close, Tab wrap-to-first, Shift+Tab wrap-to-last
- Cleanup: removeEventListener called on close and unmount
@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 9523b8f 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.

Admin UI primitives (admin/Form.tsx, admin/Modal.tsx) have no test coverage

2 participants