test: improve test cleanup with selective deletion

- Replace deleteMany({}) with selective deletion by username/email/slug in:
  - events.test.js (target specific test users/events only)
  - matches.test.js (target specific test users/events only)
  - csrf.test.js (target csrftest user only)
- Replace delete() with deleteMany() for resilient cleanup:
  - matches.test.js (2 inline cleanups)
  - socket-webrtc.test.js (1 inline cleanup)
- Update TODO.md with test status and future UX/UI improvements

Test improvement: 189/223 passing (84.8%), up from 145/223 (65%)
This commit is contained in:
Radosław Gierwiało
2025-11-20 00:05:24 +01:00
parent d6f3eafeb2
commit fd0dcdf77f
5 changed files with 200 additions and 23 deletions

View File

@@ -11,6 +11,75 @@
**Also Completed:** 1.6 (Competition Heats System - Backend & Frontend) - ✅ COMPLETED
**Progress:** ~72% complete
### 🔧 CURRENT STATUS - Backend Tests (2025-11-20)
**Test Status:** 189/223 passing (84.8%) - ✅ Significant improvement!
- **Before:** 145/223 (65%)
- **After fixes:** 189/223 (84.8%)
- **Improvement:** +44 tests (+19.8%)
**✅ Fixed:**
1. Test cleanup - replaced `deleteMany({})` with selective deletion:
- `backend/src/__tests__/events.test.js` - selective deletion by username/email/slug
- `backend/src/__tests__/matches.test.js` - selective deletion by username/email/slug
- `backend/src/__tests__/csrf.test.js` - selective deletion by username/email
2. Cleanup resilience - replaced `delete()` with `deleteMany()`:
- `backend/src/__tests__/socket.test.js` - all afterAll + inline cleanup
- `backend/src/__tests__/matches.test.js` - inline cleanup (2 locations)
- `backend/src/__tests__/socket-webrtc.test.js` - inline cleanup
3. Socket tests fixes:
- Changed `eventId``slug` in socket event handlers
- Added `EventParticipant` creation before join_event_room
- Added safety checks before creating FK relationships
4. Auth tests fixes:
- `app.test.js` - CORS origin localhost:8080
- `security.js` - added localhost:3000 to allowed origins (dev)
- `auth-phase1.5.test.js` - fixed error message expectations
**❌ Remaining issues (34 failing tests in 3 test suites):**
- `users.test.js` - ??? (unknown errors, needs analysis)
- `events.test.js` - ??? (unknown errors, despite cleanup fixes)
- `matches.test.js` - PASS individually, FAIL in suite (race conditions?)
**⏳ TODO:**
1. Check detailed errors in `users.test.js`
2. Check detailed errors in `events.test.js`
3. Investigate race conditions in `matches.test.js`
4. Potentially add test isolation (beforeEach cleanup)
5. Consider using transactions in tests
**Commits made:**
- `test: fix socket.test.js cleanup and event room parameters`
- `test: improve test cleanup - selective deletion instead of wiping tables`
### 📋 FUTURE UX/UI IMPROVEMENTS
**Dashboard Page (Post-Login):**
- [ ] Create `/dashboard` route as default landing page after login
- [ ] Show current user information (profile summary, stats)
- [ ] Quick access buttons to active chats (event rooms, match chats)
- [ ] Display ongoing discussions/conversations
- [ ] Show upcoming events user is registered for
- [ ] Recent activity feed (new matches, messages, ratings)
- [ ] Navigation shortcuts to key features
**Event Chat Sidebar Enhancements:**
- [ ] Add competitor number display for each user in sidebar
- [ ] Show user nationality (flag + country code)
- [ ] Expand user info cards in sidebar:
- Competition heats (already implemented)
- Competitor number
- Country/nationality
- User role/level
- Years of experience (if available in profile)
- Average rating (if rated)
- [ ] Consider expandable user cards (click to see more details)
- [ ] Add filtering options:
- By nationality
- By division/level
- By competitor number range
- [ ] Improve mobile responsiveness for extended sidebar info
### ✅ Completed
- Phase 0: Frontend mockup with all views
- Phase 1: Backend Foundation