test(ratings): add comprehensive E2E test for ratings & stats flow

Add end-to-end test verifying the complete ratings and stats update flow:
- Auto match creation from suggestion acceptance
- Both users rating each other
- Stats updated exactly once (recordingsDone/recordingsReceived)
- Manual matches do NOT update stats
- Double-rating prevention (idempotency)

Test coverage (9 scenarios):
- STEP 1-3: Event creation, user enrollment, heat declaration
- STEP 4: Matching algorithm execution + saveMatchingResults fix
- STEP 5: Suggestion acceptance creates auto match (source='auto')
- STEP 6a: First rating (no stats update yet)
- STEP 6b: Second rating triggers stats update + match completion
- STEP 7: Verify duplicate rating prevention
- STEP 8: Verify manual matches don't affect fairness stats

Infrastructure:
- Add jest.setup.js to load .env.development for all tests
- Update package.json to use setupFilesAfterEnv

Documentation:
- Mark S10 (Ratings & Stats) as  IMPLEMENTED in TODO.md
- Remove from Critical Gaps section
- Add detailed implementation references

All tests passing 
This commit is contained in:
Radosław Gierwiało
2025-11-30 19:18:09 +01:00
parent 25236222de
commit 065e77fd4e
4 changed files with 512 additions and 44 deletions

View File

@@ -49,6 +49,7 @@
},
"jest": {
"testEnvironment": "node",
"setupFilesAfterEnv": ["<rootDir>/jest.setup.js"],
"coveragePathIgnorePatterns": [
"/node_modules/"
],