Add component tests for EndRunModal, GameGrid, RulesConfiguration, Layout

33 tests covering rendering, user interactions (userEvent clicks), prop
callbacks, filter state, and conditional description text. Adds a
matchMedia stub to the vitest setup file so components importing
useTheme don't throw in jsdom. Also adds actionlint and zizmor
pre-commit hooks for GitHub Actions linting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 13:57:12 +01:00
parent 0d2f419c6a
commit 9aaa95a1c7
8 changed files with 374 additions and 20 deletions

View File

@@ -1,30 +1,21 @@
---
# nuzlocke-tracker-1guz
title: Component tests for key frontend components
status: draft
status: completed
type: task
priority: normal
created_at: 2026-02-10T09:33:45Z
updated_at: 2026-02-10T09:33:45Z
updated_at: 2026-02-21T12:53:51Z
parent: nuzlocke-tracker-yzpb
---
Write component tests for the most important frontend React components, focusing on user interactions and rendering correctness.
Write component tests for key frontend React components, focusing on user interactions and rendering correctness.
Test components with no external hook dependencies directly; mock `useTheme` where needed. Use @testing-library/user-event for interactions.
## Checklist
- [ ] Test `EncounterModal`form submission, validation, Pokemon selection
- [ ] Test `StatusChangeModal` — status transitions, confirmation flow
- [ ] Test `EndRunModal` — run completion/failure flow
- [ ] Test `GameGrid` — game selection rendering, click handling
- [ ] Test `RulesConfiguration` — rules toggle interactions, state management
- [ ] Test `Layout` — navigation rendering, responsive behavior
- [ ] Test admin form modals (GameFormModal, RouteFormModal, PokemonFormModal) — CRUD form flows
- [ ] Test `AdminTable` — sorting, filtering, action buttons
## Notes
- Focus on user-facing behavior, not implementation details
- Use @testing-library/user-event for simulating clicks, typing, etc.
- Mock API responses for components that fetch data
- Don't aim for 100% coverage — prioritise the most complex/interactive components
- Page components (RunEncounters, RunDashboard, etc.) are large and complex — consider testing their sub-components instead
- [x] Test `EndRunModal`Victory/Defeat/Cancel button callbacks, genlocke description text, disabled state
- [x] Test `GameGrid` — renders games, generation filter, region filter, onSelect callback
- [x] Test `RulesConfiguration` — renders rule sections, toggle calls onChange, type restriction toggle, reset button
- [x] Test `Layout` — nav links present, mobile menu toggle, theme toggle button

View File

@@ -25,4 +25,4 @@ Add comprehensive unit and integration test coverage to both the backend (FastAP
- [x] Backend API endpoints have integration test coverage
- [x] Frontend test infrastructure is set up (Vitest, RTL)
- [x] Frontend utilities and hooks have unit test coverage
- [ ] Frontend components have basic render/interaction tests
- [x] Frontend components have basic render/interaction tests