feat: Implement tournament schedule tab and fix E2E tests #27

Merged
david merged 43 commits from feature/7-schedule-tab into main 2026-04-27 01:59:17 +00:00
Owner

Summary

This PR implements the tournament schedule tab functionality and fixes all remaining E2E test failures.

Changes Included

  1. Tournament Schedule Feature

    • Added tournament schedule page at /admin/tournaments/[id]/schedule
    • Implemented "Generate Schedule" button functionality
    • Added schedule generation logic for round-robin tournaments
  2. E2E Test Fixes

    • Fixed database connection issues in production builds
    • Improved test reliability with better error handling and debugging
    • Updated test infrastructure to use environment variables instead of hardcoded values
  3. CI/CD Updates

    • Added E2E test job to PR workflow
    • Configured tests to run against development database
    • Moved database password to Gitea secrets
  4. Code Quality

    • Removed hardcoded passwords from codebase
    • Improved Prisma client configuration
    • Enhanced authentication and navigation components

Test Results

All 16 E2E test scenarios are now passing:

  • Authentication tests:
  • Registration tests:
  • Tournament schedule tests:
  • Player schedule tests:
  • Admin navigation tests:

Database Configuration

  • Tests run against euchre_camp_dev database
  • Production builds use environment variables for database configuration
  • Database password stored in Gitea secrets as DB_PASSWORD

CI Pipeline

The PR workflow now includes:

  1. Unit tests
  2. E2E tests (using production build)
  3. Version bump analysis

E2E tests must pass before PR can be merged.

## Summary This PR implements the tournament schedule tab functionality and fixes all remaining E2E test failures. ### Changes Included 1. **Tournament Schedule Feature** - Added tournament schedule page at `/admin/tournaments/[id]/schedule` - Implemented "Generate Schedule" button functionality - Added schedule generation logic for round-robin tournaments 2. **E2E Test Fixes** - Fixed database connection issues in production builds - Improved test reliability with better error handling and debugging - Updated test infrastructure to use environment variables instead of hardcoded values 3. **CI/CD Updates** - Added E2E test job to PR workflow - Configured tests to run against development database - Moved database password to Gitea secrets 4. **Code Quality** - Removed hardcoded passwords from codebase - Improved Prisma client configuration - Enhanced authentication and navigation components ### Test Results All 16 E2E test scenarios are now passing: - Authentication tests: ✅ - Registration tests: ✅ - Tournament schedule tests: ✅ - Player schedule tests: ✅ - Admin navigation tests: ✅ ### Database Configuration - Tests run against `euchre_camp_dev` database - Production builds use environment variables for database configuration - Database password stored in Gitea secrets as `DB_PASSWORD` ### CI Pipeline The PR workflow now includes: 1. Unit tests 2. E2E tests (using production build) 3. Version bump analysis E2E tests must pass before PR can be merged.
david added 41 commits 2026-04-26 23:44:57 +00:00
Implement circle-method algorithm for generating round-robin tournament
schedules. Handles both even and odd team counts with bye rounds.

Includes unit tests for algorithm correctness, input validation, and
expected round/matchup calculations.
GET returns rounds with matchups for a tournament.
POST generates a round-robin schedule from registered teams.
DELETE removes all rounds and matchups.

All endpoints enforce tournament admin permissions via canManageTournament.
Schedule page displays round-robin rounds with matchups, team names,
status badges, and links to result entry. Generator component provides
generate/delete buttons with success/error feedback.
Replace non-functional tab buttons with Link components for Schedule
and Results tabs. Disable unimplemented tabs (Participants, Teams,
Analytics) as styled spans with cursor-not-allowed.
Playwright tests covering: schedule link visibility, empty state,
schedule generation, round/matchup display, and API response format.
Closes #7.
Bun v1.2+ switched from binary lockfile (bun.lockb) to text-based
bun.lock format. Update the Dockerfile COPY to match.
Add fields for team durability, partner rotation, and configuration:
- teamDurability: permanent, variable, or per_round
- partnerRotation: none, minimize_repeat, maximize_even, elo_based
- allowByes: handle odd participant counts
- teamConfiguration: JSON for additional options
- maxRosterChanges: limit roster changes per player
- requireAdminVerify: for match score verification

Refs #22
Implement team generation algorithms for tournament partnerships:
- Random pairing (Fisher-Yates shuffle)
- ELO-based pairing (strongest + weakest)
- Even matches (balance competitive levels)
- Minimize repeat partnerships
- Support for byes with odd participant counts
- Team balance calculation utilities

Refs #22
Add API endpoints for team management:
- POST /api/tournaments/[id]/teams/generate: Generate teams based on configuration
- DELETE /api/tournaments/[id]/teams: Delete all teams
- GET /api/tournaments/[id]/teams: Fetch teams and configuration

Supports multiple generation strategies:
- Random pairing
- ELO-based pairing
- Even matches
- Minimize repeat partnerships

Refs #22
Add interactive team configuration panel:
- Team durability selection (permanent, variable, per_round)
- Partner rotation strategy selection
- Allow byes configuration
- Generate Teams button with participant count
- Delete All Teams functionality
- Available participants display with ELO ratings

Refs #22
Update tournament detail page to use new TeamsSection component:
- Import TeamsSection component
- Replace static teams display with interactive configuration
- Pass tournament ID, teams, and participants to component

Refs #22
Add comprehensive tests for team generation:
- Test random pairing strategy
- Test ELO-based pairing strategy
- Test even matches strategy
- Test minimize repeat partnerships
- Test bye player handling
- Test team balance calculation
- Test partnership frequency tracking

All 19 tests pass.

Refs #22
Fix JSON parsing errors when server returns non-JSON responses:
- Check response.ok before calling response.json()
- Add fallback error messages using status text
- Apply fix to all fetch calls across 12 components

This prevents 'JSON.parse: unexpected character' errors when
server returns HTML error pages or other non-JSON responses.
Add 'mode: insensitive' to Prisma query for player search:
- Allows searching by partial name regardless of case
- Improves user experience when searching for players
Update tournament APIs to support:
- tournamentType field (individual/team)
- Team creation for team tournaments
- Even number validation for team tournaments
- Automatic pairing of consecutive players into teams
Add tournamentType field with default value 'individual':
- Supports 'individual' and 'team' tournament types
- Creates migration for database schema update
- Change PUT endpoint to only include fields present in the request
- Add support for team configuration fields (teamDurability, partnerRotation, allowByes)
- Fix contradictory test that expected resetting allowTies when not provided
- When a field is not in the request, it is preserved (not modified)

Fixes issue where Save Configuration button would fail with
'Tournament name is required' error.
- Add manual team entry for permanent teams in Matchups tab
- Rename 'Teams' tab to 'Matchups' for clarity
- Implement partner rotation strategies (minimize_repeat, maximize_even, elo_based)
- Track partnerships across rounds to minimize repeat pairings
- Fix unit tests for team configuration and ELO calculations
- Add E2E test for 9+ participant tournaments with variable matchups

Key changes:
- TeamsSection.tsx: Added router.refresh(), manual team entry, and matchup display
- schedule-generator.ts: Enhanced generateVariableRoundRobin to track partnerships
- team-generator.ts: Fixed partnership frequency tracking across rounds
- API routes: Updated to support variable team durability with rotation strategies
- Prevents tests from running against production database
- Uses same logic as Playwright global setup
- Ensures test data isolation
- Add error handling for browser context creation
- Auto-relaunch browser if context creation fails
- Add better error logging
- Simplify registration redirect after session refresh
- Update wordmark to use dynamic href based on session/role
- Add anchor tag for wordmark to avoid Next.js Link issues
chore: remove .env.production from repository and add to .gitignore
Pull Request / unit-tests (pull_request) Successful in 59s
Pull Request / e2e-tests (pull_request) Successful in 3m6s
Pull Request / analyze-bump-type (pull_request) Successful in 11s
2658dc07cb
david force-pushed feature/7-schedule-tab from b2fcf0fae7 to 2658dc07cb 2026-04-26 23:44:57 +00:00 Compare

🏷️ Version Bump Analysis

Suggested bump type: PATCH
Reason: Defaulting to patch (fixes or other changes)

This PR will bump the version to the next patch version when merged.

## 🏷️ Version Bump Analysis **Suggested bump type:** `PATCH` **Reason:** Defaulting to patch (fixes or other changes) This PR will bump the version to the next patch version when merged.

🏷️ Version Bump Analysis

Suggested bump type: PATCH
Reason: Defaulting to patch (fixes or other changes)

This PR will bump the version to the next patch version when merged.

## 🏷️ Version Bump Analysis **Suggested bump type:** `PATCH` **Reason:** Defaulting to patch (fixes or other changes) This PR will bump the version to the next patch version when merged.
david added 1 commit 2026-04-27 00:18:01 +00:00
feat: implement club admin dashboard with activity feed and settings
Pull Request / unit-tests (pull_request) Successful in 57s
Pull Request / e2e-tests (pull_request) Successful in 3m10s
Pull Request / analyze-bump-type (pull_request) Successful in 12s
31fc26478d

🏷️ Version Bump Analysis

Suggested bump type: PATCH
Reason: Defaulting to patch (fixes or other changes)

This PR will bump the version to the next patch version when merged.

## 🏷️ Version Bump Analysis **Suggested bump type:** `PATCH` **Reason:** Defaulting to patch (fixes or other changes) This PR will bump the version to the next patch version when merged.
david added 1 commit 2026-04-27 01:01:56 +00:00
fix: improve test script to ensure server is ready and properly cleaned up
Pull Request / unit-tests (pull_request) Successful in 1m2s
Pull Request / e2e-tests (pull_request) Failing after 2m56s
Pull Request / analyze-bump-type (pull_request) Has been skipped
07397974d0
david merged commit bb6be245b7 into main 2026-04-27 01:59:17 +00:00
david deleted branch feature/7-schedule-tab 2026-04-27 01:59:17 +00:00
Sign in to join this conversation.