test: set up testing infrastructure with CI workflow and reference tests#108
Merged
TristanHourtoulle merged 12 commits intodevfrom Feb 28, 2026
Merged
test: set up testing infrastructure with CI workflow and reference tests#108TristanHourtoulle merged 12 commits intodevfrom
TristanHourtoulle merged 12 commits intodevfrom
Conversation
Create reusable data builders (user, quiz, course) and mock utilities (session, router, axios) to reduce duplication in future tests.
Remove duplicate MockEventSource from useGenerationProgress test and use the shared one from setup.ts. Add instance tracking and simulateProgressEvent helper to the shared mock.
Add GitHub Actions workflow that runs unit tests on PRs and posts a sticky coverage comment via vitest-coverage-report-action. Add json-summary reporter and expanded coverage exclusions to vitest config. Add test:ci script for non-watch CI execution.
…nd improve caching
Lucide icons inside <label> elements were polluting accessible names, preventing screen readers and Playwright from matching label text correctly.
… job - Fix selectors to match actual UI (getByRole, getByPlaceholder) - Remove conditional tests and arbitrary waits - Fix routes to match real app structure - Add E2E job to CI workflow (build + chromium + report artifact) - Move permissions to job level (SonarQube compliance) - Configure Playwright for CI (pnpm start instead of dev)
- quiz: shuffleArray immutability, shuffleQuiz answer preservation (11 tests) - subscription-helpers: getSubscriptionStatus all branches, formatSubscriptionDate (12 tests) - role-permissions: canUserModifyTicket/canUserReopenTicket per role (11 tests) - auth-utils: isTokenExpired, getCurrentUserId id/_id fallback, isAuthenticated, getAuthHeaders (15 tests)
- useUserStatistics: stats computation, score distribution, trend, streaks, weekly activity, period filtering (23 tests) - useQuizPlayer: initialization, answer submission, navigation, restart, insight creation, edge cases (17 tests)
ResizeObserver mock needed for Radix UI components in jsdom. user-event enables realistic user interaction testing in RTL.
Reference implementations for the team to follow when adding component tests: - AuthGuard: conditional rendering based on hook state (6 tests) - SigninForm: form validation, submit flow, password toggle, callbacks (11 tests) - SignupForm: registration validation, password requirements, error handling (9 tests) Each file documents the RTL pattern used (mock hooks, userEvent.setup, waitFor).
- docs/TESTING.md: architecture, patterns for each test type, commands - README.md: add test commands section with link to guide
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Missing devdeps
khalidbelk
approved these changes
Feb 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Set up the complete testing infrastructure for the project: Vitest + React Testing Library for unit/component tests, Playwright for E2E, and a CI workflow to run everything automatically. Includes reference test examples for each category (pure functions, hooks, components, E2E) to serve as a base for the team.
Type of Change
Changes Overview
Testing Configuration
@testing-library/user-eventandResizeObserverpolyfill setuptests/setup.ts)Test Infrastructure
tests/factories/) for users, courses, quizzes - reusable data builderstests/mocks/) for axios, Next.js router, NextAuth sessionMockEventSourceutilityReference Tests (examples for the team)
auth-utils,quiz,role-permissions,subscription-helpersuseUserStatistics,useQuizPlayer,useGenerationProgressSigninForm,SignupForm,AuthGuard(RTL)CI/CD
.github/workflows/test.yml- Vitest unit tests + Playwright E2EDocumentation
docs/TESTING.md- testing guide for the teamTechnical Details
Files Changed: ~42 files
Main Areas:
tests/- all test infrastructure, factories, mocks, and reference tests.github/workflows/- CI workflowvitest.config.ts,playwright.config.ts- test runner configsdocs/TESTING.md- team documentationTesting
Breaking Changes
None
Deployment Notes
No special steps required. New dev dependencies added (
@testing-library/user-event).