-
Notifications
You must be signed in to change notification settings - Fork 0
Add unit tests to UpLine codebase #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add comprehensive unit tests for: - src/lib/voteConfig.ts: 20 tests covering VOTE_CONFIG structure, getVoteConfig, and getVoteValue functions - src/lib/constants/stages.ts: 6 tests for DEFAULT_STAGE_COLOR constant All tests passing (50/50). Phase 1 of the unit testing plan is now complete.
Set up React Testing Library and add comprehensive unit tests for: - Component tests (87 new tests): - GenreBadge.tsx: 9 tests with mocked useGenres hook - StageBadge.tsx: 11 tests for rendering and styling - StagePin.tsx: 9 tests with mocked useStageQuery hook - ui/badge.tsx: 10 tests for variants and props - ui/button.tsx: 20 tests for variants, sizes, and interactions - ui/card.tsx: 28 tests for all card components Infrastructure: - Added @testing-library/react, @testing-library/jest-dom, @testing-library/user-event - Created test setup file (src/test/setup.ts) for jest-dom matchers - Updated vite.config.test.ts to include setupFiles Total: 137 tests passing (Phase 1 + Phase 2)
Add comprehensive unit tests for custom hooks: - use-mobile.tsx: 10 tests for responsive breakpoint detection - useOnlineStatus.ts: 10 tests for online/offline status tracking - useScrollVisibility.ts: 14 tests for IntersectionObserver wrapper - use-toast.ts: 17 tests for toast state management with reducer - useCookieConsent.ts: 16 tests for GDPR consent management All hooks tests include: - State initialization - Event listener setup and cleanup - State updates and transitions - Edge cases and error handling - Mock implementations for browser APIs Total: 204 tests passing (Phases 1-3 combined)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Add comprehensive unit tests for core utility functions: - utils.ts: 12 tests for cn() function (class name merging with Tailwind) - stageUtils.ts: 11 tests for sortStagesByOrder() sorting algorithm - markdown.ts: 21 tests for parseMarkdown() with GFM support - timeUtils.ts: 44 tests for time formatting and timezone conversion functions - formatTimeRange, formatDateTime, formatTimeOnly - toDatetimeLocal, toISOString - combineDateAndTime, convertLocalTimeToUTC All utilities tests include: - Edge cases and null/undefined handling - Format validation - Timezone conversions - Complex data scenarios Total: 292 tests passing (Phases 1-4 combined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR establishes a comprehensive unit testing foundation for the UpLine codebase by adding Vitest and React Testing Library. The changes include test infrastructure setup and extensive test coverage across utility functions, custom React hooks, and UI components.
Key Changes:
- Added testing dependencies (@testing-library/jest-dom, @testing-library/react, @testing-library/user-event) and configured Vitest with jsdom environment
- Created 320+ unit tests covering 15 test files across utilities, hooks, and components
- Established consistent testing patterns including browser API mocking and data-fetching hook mocking
Reviewed changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vite.config.test.ts | Added test setup file configuration to load jest-dom matchers |
| src/test/setup.ts | Test setup file importing @testing-library/jest-dom/vitest for extended matchers |
| src/lib/constants/tests/stages.test.ts | Tests for DEFAULT_STAGE_COLOR constant (some redundancy noted) |
| src/lib/tests/voteConfig.test.ts | Comprehensive tests for vote configuration utilities including type mappings |
| src/lib/tests/utils.test.ts | Tests for cn utility covering class merging and Tailwind conflict resolution |
| src/lib/tests/timeUtils.test.ts | Tests for time formatting functions (test naming issues noted) |
| src/lib/tests/stageUtils.test.ts | Tests for stage sorting logic including null/undefined handling |
| src/lib/tests/markdown.test.ts | Tests for markdown parsing covering GFM features and error handling |
| src/hooks/tests/useScrollVisibility.test.ts | Tests for scroll visibility hook with IntersectionObserver mocking |
| src/hooks/tests/useOnlineStatus.test.ts | Tests for online status hook with navigator.onLine mocking |
| src/hooks/tests/useCookieConsent.test.ts | Tests for cookie consent management with cross-domain storage mocking |
| src/hooks/tests/use-toast.test.ts | Tests for toast notification hook including toast lifecycle |
| src/hooks/tests/use-mobile.test.tsx | Tests for mobile detection hook with matchMedia mocking |
| src/components/ui/tests/card.test.tsx | Tests for Card component family verifying styling and ref forwarding |
| src/components/ui/tests/button.test.tsx | Tests for Button component covering variants, sizes, and interactions |
| src/components/ui/tests/badge.test.tsx | Tests for Badge component covering variants and styling |
| src/components/tests/StagePin.test.tsx | Tests for StagePin component with useStageQuery mocking |
| src/components/tests/StageBadge.test.tsx | Tests for StageBadge component with size and color variations |
| src/components/tests/GenreBadge.test.tsx | Tests for GenreBadge component with useGenres mocking (negative assertion issue noted) |
| package.json | Added testing library dependencies to devDependencies |
| pnpm-lock.yaml | Updated lockfile with new testing dependencies and their transitive deps |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| { initialProps: { threshold: 0 } }, | ||
| ); | ||
|
|
||
| const firstObserver = global.IntersectionObserver; |
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable firstObserver.
| const firstObserver = global.IntersectionObserver; | |
| // Removed unused variable firstObserver |
Add GitHub Actions workflow to run Vitest unit tests: - Runs on push to main/develop and on PRs - Executes all 292 unit tests - Generates coverage report on PRs - Uploads coverage artifacts for review This provides fast feedback (~20s) compared to E2E tests.
No description provided.