Files
euchre_camp/docs/TODO.md
david 861e14503b
Release / release (push) Failing after 9s
Build CI Images / build-ci-base (push) Failing after 20s
feat: SDLC database separation for CI/testing (#35)
## Summary
- Fix `isProductionDatabase()` to allow CI database (`euchre_camp_ci`)
- Add database schema reset before CI test runs
- Create `global.teardown.ts` for cleanup (CI: full reset, dev/prod: selective cleanup)
- Add `acceptance-tests` job to PR workflow with CI database
- Create `sync-prod-to-dev.js` script for one-way prod→dev sync
- Add `just` recipes: `sync-dev`, `test-prod`, `reset-ci-db`
- Store credentials in `.credentials` (gitignored) with unique CI user

## Testing
Verified against CI database:
- Schema reset works
- Migrations apply correctly
- Test users created successfully
- 219 tests pass (slow but working)

## Next Steps
- Set `CI_DATABASE_URL` as Gitea repository variable

Reviewed-on: #35
Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
2026-05-11 06:40:05 +00:00

136 lines
6.3 KiB
Markdown

# EuchreCamp - Todo List
## Current Tasks
### Completed ✅
- [x] Add `site_admin` role to database schema and permissions system
- [x] Add `isCasual` boolean field to Match model (already existed)
- [x] Update match upload API to support casual matches
- [x] Update match upload UI to include casual checkbox
- [x] Add tournament deletion API endpoint with delete/orphan options
- [x] Add delete tournament button and modal to tournament detail page
- [x] Run tests and verify implementation (84 tests passing)
- [x] Fix session issues with tournament admin access
- [x] Fix Elo recalculation error for player merge (delete elo snapshots before deleting players)
- [x] Add admin player management page
- [x] Add player name editing functionality in admin UI
- [x] Add admin panel links to navigation header
- [x] Add tournament update API endpoint (PUT /api/tournaments/[id])
- [x] Consolidate delete endpoint from admin API to main tournaments API
- [x] Update database schema to add variant scoring fields (targetScore, allowTies)
- [x] Fix tie handling logic in partnership stats (ties now correctly tracked)
- [x] Fix test files for normalizedName field in Player model
- [x] Fix auth.ts to include normalizedName in Player creation
- [x] Write TODO list to repository file
- [x] Auto-create tournament when uploading matches without selecting one
### Completed ✅
- [x] Update API routes to handle new variant scoring fields
- [x] Update EditTournamentForm to add variant scoring controls
- [x] Update MatchEditor to use tournament-specific target score
- [x] Run tests and verify variant scoring implementation
### Recently Completed ✅
- [x] Update CI/CD workflows to use Bun (PR, release)
- [x] Update Dockerfile to use Bun Alpine image
- [x] Update PR workflow to use Bun
- [x] Update Release workflow to use Bun
- [x] Remove test.yml workflow (redundant)
- [x] Verify Docker build with Bun
### Recently Completed ✅
- [x] Fix Prisma build error in CI pipeline (Docker build failure due to missing DATABASE_URL validation)
- [x] Add defensive checks to src/lib/prisma.ts to prevent build failures
- [x] Migrate from npm to Bun package manager
- [x] Migrate unit tests (Vitest → Bun test runner)
- [x] Migrate component tests (Vitest → Bun test runner)
- [x] Configure Bun with DOM environment for React Testing Library
- [x] Keep Playwright for E2E tests (hybrid approach)
### Recently Completed ✅
- [x] Add OpenSkill rating system support (src/lib/openskill-utils.ts)
- [x] Add Glicko2 rating system support (src/lib/glicko2-utils.ts)
- [x] Reset database and run all migrations from scratch
- [x] Regenerate Prisma client with new rating models
- [x] Update match upload page to auto-create tournament if none selected
- [x] Update all admin scripts to use PrismaPg adapter and dotenv
- [x] Fix match diagram player positioning
- [x] Add CasaOS deployment configuration and documentation
- [x] Create migration to add rating system tables (elo_ratings, glicko2_ratings, open_skill_ratings)
- [x] Add tabbed rankings page to display Elo, OpenSkill, and Glicko2 ratings
### Completed ✅
- [x] Add UI controls for variant scoring in tournament creation/edit
- [x] Test variant tournament functionality end-to-end (e2e/tournament-edit-allowTies.test.ts)
- [x] Add validation for tie scores based on tournament configuration (MatchEditor.tsx)
### Completed ✅ (CI/DB Infrastructure)
- [x] Fix PostgreSQL database ownership — each env owns its own DB
- [x] Fix role attributes — euchre_camp_dev gets CREATEDB, euchre_camp_ci loses SUPERUSER
- [x] Update .env.development to use euchre_camp_dev user
- [x] Update .env.development.local to use euchre_camp_dev user
- [x] Update CI docker-compose to use euchre_camp_ci user
- [x] Update dev docker-compose to use euchre_camp_dev user
- [x] Recreate dev and CI containers with correct credentials
- [x] Fix Playwright baseURL for CI (https://euchre-ci.notsosm.art)
- [x] Fix Navigation unit tests (RoleSwitcherProvider wrapper)
- [x] Fix secrets vs vars in PR workflow (secrets.CI_DATABASE_URL)
### Backlog 📋
- [ ] Document variant tournament features
- [ ] Update Gitea secret CI_DATABASE_URL to use euchre_camp_ci user
- [ ] Test isolation improvements for parallel CI execution
## Recently Completed (Detailed)
### Variant Euchre Scoring Support
- Added `targetScore` and `allowTies` fields to Event model
- Created database migration for new fields
- Fixed partnership stats tie handling (ties now increment neither wins nor losses)
- Updated Elo calculation functions to handle ties correctly (0.5 points for draw)
### Tournament Deletion
- Consolidated delete endpoint to `/api/tournaments/[id]`
- Added options to delete matches or orphan them
- Updated DeleteTournamentButton to use consolidated endpoint
### Player Management
- Added admin players page at `/admin/players`
- Added player name editing functionality via PATCH endpoint
- Added player merge functionality with automatic Elo recalculation
- Fixed foreign key constraint issues with elo_snapshots
### Permissions
- Added `site_admin` role as highest privilege level
- Updated all permission functions to include site_admin support
- Fixed session cache issues by reading roles from database
## Notes
- All 84 unit tests passing
- Database migrations applied successfully
- TypeScript compilation has pre-existing errors unrelated to our changes
### Completed After Commit 1729dac
#### Next.js 16 Breaking Change Fixes
- [x] Fixed `params.id` usage in all page components (must use `await params`)
- [x] Fixed `params.id` usage in all API routes (must use `await params`)
- [x] Updated client components to use `Promise<{ id: string }>` type
- [x] Added regression tests for Next.js 16 params Promise handling
- [x] Verified all 100 unit tests pass
#### Files Updated:
- Player pages: `profile.tsx`, `schedule.tsx`
- Tournament pages: `page.tsx`, `results.tsx`, `edit.tsx`, `entry.tsx`
- API routes: `admin/players/[id]/route.ts`, `users/[id]/route.ts`, `users/[id]/role/route.ts`
- Tournament API routes: `[id]/route.ts`, `[id]/participants/route.ts`, `[id]/games/bulk/route.ts`
#### Root Cause
Next.js 16 requires `params` to be awaited in both server components and API routes:
- Before: `const { id } = params`
- After: `const { id } = await params`
This was not caught by the unit test suite because:
- Unit tests test individual functions in isolation
- E2E tests (Playwright) would catch this but weren't run after the upgrade