Commit 188f97d
Add Vitest JavaScript testing framework for SPA
Set up comprehensive JavaScript testing infrastructure to ensure SPA
implementation matches traditional Rails scoring interface.
Testing Strategy:
- Backend API tests: Expand existing Rails controller tests (~150 lines)
- System tests: Browser integration with Capybara/Selenium (~200 lines)
- JavaScript unit tests: Test offline behavior with Vitest (~500 lines)
Setup:
- Initialize npm with package.json
- Install Vitest, jsdom, fake-indexeddb for testing
- Configure Vitest with jsdom environment
- Create test setup with Rails helper mocks
- Add 12 passing tests for HeatDataManager (IndexedDB operations)
Test Coverage:
- Dirty scores management (create, update, remove, clear)
- Last-write-wins for duplicate heat/slot scores
- Batch upload to server with success/failure handling
- Network error handling
- Data fetching from server
Benefits:
- Fast test execution (Vitest uses Vite transformation)
- Jest-compatible API (familiar, lots of examples)
- Native ESM support (works with Rails import maps)
- Built-in browser API mocks (IndexedDB via fake-indexeddb)
- Systematic conversion of Ruby tests to JS ensures feature parity
All tests passing:
Test Files 1 passed (1)
Tests 12 passed (12)
Duration 323ms
Updated plans/SPA_SYNC_STRATEGY.md with complete testing strategy and
CI configuration examples for GitHub Actions and GitLab CI.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 34e25af commit 188f97d
File tree
6 files changed
+2778
-0
lines changed- plans
- test/javascript
6 files changed
+2778
-0
lines changed
0 commit comments