docs: add comprehensive testing guide with flaky test documentation

- Create docs/TESTING.md with full testing documentation
- Document 3 flaky test suites with exact locations and workarounds
- Update README.md with accurate test status (~348-349 passing)
- Add troubleshooting guide for race conditions
- Include CI/CD considerations and future improvements

Key sections:
- Running tests (commands, environment, configuration)
- Flaky tests: matching-algorithm, ratings-stats-flow, events
- Known issues & fixes applied (migrations, constraints, config)
- Debugging strategies and test isolation tips
This commit is contained in:
Radosław Gierwiało
2025-12-06 14:45:21 +01:00
parent 5599c6f72b
commit 68f8322221
2 changed files with 362 additions and 8 deletions

View File

@@ -198,20 +198,43 @@ docker compose exec backend npm run cli -- users:list --limit 20
## 📊 Test Coverage
**Backend: 351/351 tests passing - 100% ✅** (73% overall coverage)
**Backend: ~348-349 passing, ~5-6 flaky, 11 skipped** (365 total tests)
### Test Suites
- **Matching Algorithm**: 19/19 integration tests
- Fundamentals, collision detection, limits, fairness, edge cases
- **Ratings & Stats Flow**: 9/9 E2E tests
- Atomic updates, race prevention, idempotency
### Test Status
- **20/23 test suites stable** - Consistently passing
- ⚠️ **3/23 test suites flaky** - Pass individually, may fail in full suite (race conditions)
- ⏭️ **11 tests skipped** - Socket.IO server setup required (3), outdated auth tests (2), rate limiting (1)
### Stable Test Suites
- **Matching Algorithm**: 19/19 tests (flaky in full suite - run individually)
- **Ratings & Stats Flow**: 9/9 tests (flaky in full suite - run individually)
- **Matching Runs Audit**: 6/6 tests
- origin_run_id tracking, sequential runs, filtering
- **Incremental Matching**: 5/5 tests
- **Recording Stats Integration**: 6/6 tests
- **WebRTC Signaling**: 12/12 tests
- **WebRTC API**: 9/9 tests (Cloudflare TURN integration, fallbacks, authentication)
- **WebRTC API**: 9/9 tests
- **Socket.IO**: 12/12 tests
- **Authentication**: 24/24 tests
- **Dashboard**: 12/12 tests
- **Users**: 23/25 tests (2 skipped - endpoints are public)
- **Matches**: 24/24 tests
- **Events**: 55/55 tests (flaky in full suite - run individually)
- **And 7 more...**
### Flaky Tests (Known Issues)
See [docs/TESTING.md](docs/TESTING.md) for detailed analysis of:
- `matching-algorithm.test.js` - Race conditions in concurrent runs
- `ratings-stats-flow.test.js` - Database state dependencies
- `events.test.js` - Cleanup interference between tests
**Workaround:** Run flaky tests individually when needed:
```bash
docker compose exec backend npm test -- matching-algorithm.test.js # ✅ 19/19
docker compose exec backend npm test -- ratings-stats-flow.test.js # ✅ 9/9
docker compose exec backend npm test -- events.test.js # ✅ 55/55
```
**Documentation:** See [docs/TESTING.md](docs/TESTING.md) for comprehensive testing guide
- **API Routes**: Full CRUD coverage (auth, events, matches, dashboard, webrtc)
### Code Coverage Highlights
@@ -272,6 +295,7 @@ spotlightcam/
├── ARCHITECTURE.md # Technical implementation details
├── DEPLOYMENT.md # Production deployment guide
├── MONITORING.md # Operations & monitoring
├── TESTING.md # Testing guide & flaky test documentation
├── TESTING_MATCHING_RATINGS.md # Comprehensive test documentation
├── WEBRTC_TESTING_GUIDE.md # WebRTC testing guide
├── GOOGLE_ANALYTICS_SETUP.md # GA4 integration guide
@@ -371,6 +395,7 @@ docker compose exec backend npm run cli -- matches:list --limit 20 --status acce
**Main documentation:**
- `docs/TODO.md` - Active tasks, security audit, roadmap
- `docs/ARCHITECTURE.md` - Technical details, WebRTC flow, API endpoints
- `docs/TESTING.md` - **Testing guide & flaky test troubleshooting**
- `docs/TESTING_MATCHING_RATINGS.md` - Comprehensive test documentation (45 tests)
- `docs/DEPLOYMENT.md` - Production deployment guide
- `docs/MONITORING.md` - Operations and monitoring