feat: Add comprehensive testing infrastructure (Phase 1)#48
Open
moonejon wants to merge 2 commits into
Open
Conversation
Implement testing foundation following Kent C. Dodds' Testing Trophy approach: - Configure Vitest for Next.js 15 + React 19 with path aliases - Add Testing Library, MSW for component and API testing - Create database helpers (reset, seed, transaction utilities) - Create test factories for User, Book, ReadingList with valid ISBN generation - Add Clerk authentication mocks (server and client) - Add ISBNdb API mocks with error scenarios - Write 101 unit tests for validation and permissions - Fix CreateReadingListModal for accessibility (PUBLIC default, ARIA labels) Test Results: 137 tests passing across 3 test suites 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Server Action Integration Tests: - books.test.ts: 48 tests for importBooks, fetchBooks, updateBook, etc. - reading-lists.test.ts: 34 tests for CRUD operations and book management - favorites.test.ts: 45 tests for FAVORITES_ALL and FAVORITES_YEAR Component Integration Tests: - TextSearch.test.tsx: 21 tests for library title search - ISBNSearch.test.tsx: 31 tests for ISBN search and import flow - AutoCompleteSearch.test.tsx: 42 tests for author/subject filters Component Fixes: - textSearch.tsx: Added screen reader accessible label - search.tsx: Fixed validation and case-sensitive error matching Test Results: 189 tests passing (excludes DB-dependent tests) Note: Server action tests require PostgreSQL test database to run. See test/README.md for database setup instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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
This PR establishes a robust testing infrastructure following Kent C. Dodds' Testing Trophy approach, prioritizing integration tests over unit tests and focusing on testing user behavior rather than implementation details.
What's Included
Test Configuration:
Test Helpers & Factories:
resetDatabase(),seedTestUser(),withTransaction()Mock Utilities:
mockClerkUser(),mockUnauthenticated()Unit Tests (101 tests):
Component Fixes:
Test Results
Test Commands
Documentation
docs/TESTING_STRATEGY.md- Comprehensive testing philosophy and approachtest/README.md- Test infrastructure guidetest/QUICK_START.md- Quick reference for writing testsTest plan
🤖 Generated with Claude Code