Commit Graph

106 Commits

Author SHA1 Message Date
david e086d7398a feat: add tournament type and team support to tournament APIs
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
2026-04-26 16:44:47 -07:00
david 729993913a fix: make player search case-insensitive
Add 'mode: insensitive' to Prisma query for player search:
- Allows searching by partial name regardless of case
- Improves user experience when searching for players
2026-04-26 16:44:47 -07:00
david 5763534e26 fix: check response.ok before parsing JSON in fetch calls
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.
2026-04-26 16:44:47 -07:00
david ec798fc29d test: add unit tests for team generation algorithms
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
2026-04-26 16:44:47 -07:00
david 1532c10223 feat: integrate TeamsSection component into tournament detail page
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
2026-04-26 16:44:47 -07:00
david 0ee295e9b1 feat: add TeamsSection component for team configuration UI
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
2026-04-26 16:44:47 -07:00
david 912a1cd268 feat: add team generation API endpoints
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
2026-04-26 16:44:47 -07:00
david c141fc6dd7 feat: add team generator library with multiple strategies
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
2026-04-26 16:44:47 -07:00
david 54f89c4bec feat: convert tournament tabs to functional navigation links
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.
2026-04-26 16:44:47 -07:00
david 0b792cc911 feat: add tournament schedule page with generator component
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.
2026-04-26 16:44:47 -07:00
david df4d6fff7c feat: add schedule API endpoints
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.
2026-04-26 16:44:47 -07:00
david 3e98c59d85 feat: add round-robin schedule generator
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.
2026-04-26 16:44:47 -07:00
david 967bdc1b89 fix(tests): resolve password validation, csv upload, and admin auth issues
Pull Request / unit-tests (pull_request) Successful in 57s
Pull Request / acceptance-tests (pull_request) Failing after 28m30s
Pull Request / analyze-bump-type (pull_request) Has been skipped
- Set explicit min/max password length in Better Auth config (8-128 chars)
- Fix CSV upload tests to use multipart/form-data instead of data
- Add @chromium-admin annotations to tests requiring admin access
2026-04-01 20:35:38 -07:00
david d8a8931bc3 fix(tests): add @prisma/client mock for test isolation
Pull Request / unit-tests (pull_request) Successful in 1m3s
Pull Request / acceptance-tests (pull_request) Failing after 3s
Pull Request / analyze-bump-type (pull_request) Has been skipped
Mock @prisma/client globally in bun-setup.ts to allow unit tests to run
without requiring the generated Prisma client. This improves test isolation
and allows tests to pass even when prisma generate hasn't been run.
2026-04-01 14:06:57 -07:00
david ed43399b24 fix: improve TypeScript types for better IDE code hinting
- Install @types/bun and @types/jsdom for proper type definitions
- Fix mock function typing in test files
- Create jest-dom.d.ts to properly extend Bun's Matchers interface
- Remove MockedFunction imports (not supported in Bun's types)
- Cast global.fetch and useSession mocks to any where needed
- Fix mock.module return types to match expected signatures

This resolves TypeScript errors that were preventing proper code
completion and type checking in IDEs.
2026-04-01 12:44:44 -07:00
david 4e3b25e2fc fix: avoid global mock clearing in EditTournamentForm tests
Pull Request / unit-tests (pull_request) Failing after 59s
Pull Request / acceptance-tests (pull_request) Has been skipped
Pull Request / analyze-bump-type (pull_request) Has been skipped
Replace mock.clearAllMocks() with mockFetch.mockClear() to only
clear the specific fetch mock without affecting global module mocks
used by other test files.
2026-04-01 12:20:16 -07:00
david e4c4333b40 fix: avoid global mock clearing in Navigation tests
- Add explicit next/link mock for consistency
- Remove mock.clearAllMocks() from beforeEach/afterEach
- Navigation tests now rely on module mocks set at file level
- Prevents interference with other test files
2026-04-01 12:20:13 -07:00
david 09302fd911 fix: add DOM cleanup to bun-setup.ts
Add afterEach hook to clear document.body.innerHTML between tests.
This prevents test pollution where elements from previous tests
interfere with subsequent test queries.
2026-04-01 12:20:10 -07:00
david b90ec08966 refactor: improve test structure for Bun compatibility
Pull Request / unit-tests (pull_request) Failing after 58s
Pull Request / acceptance-tests (pull_request) Has been skipped
Pull Request / analyze-bump-type (pull_request) Has been skipped
- Update all test files to use named mock variables instead of inline mocks
- Clear mock history in beforeEach instead of using mock.restore()
- Add default mock implementations stored at module level
- Document that tests should not use --randomize flag due to mock.module() limitations
- All 89 unit tests pass consistently without randomization
2026-04-01 01:05:01 -07:00
david 24db43eb7f feat: migrate from npm to Bun
Test / unit-tests (push) Failing after 1m54s
Pull Request / unit-tests (pull_request) Failing after 1m41s
Pull Request / acceptance-tests (pull_request) Has been skipped
Pull Request / analyze-bump-type (pull_request) Has been skipped
- Install Bun via mise
- Update package.json scripts to use Bun
- Migrate unit tests from Vitest to Bun test runner
- Migrate component tests from Vitest to Bun test runner
- Configure Bun with DOM environment for React Testing Library
- Keep Playwright for E2E tests (as planned)
- 93/100 tests passing (7 flaky tests when running all together, pass individually)
2026-04-01 00:13:15 -07:00
david 5caa284b3c fix: add defensive checks to prisma.ts to prevent build failures
Test / unit-tests (push) Has been cancelled
2026-03-31 23:44:43 -07:00
david 501e1b7e23 fix: version bumping and Docker registry authentication (#17)
Release / release (push) Failing after 1m9s
Test / unit-tests (push) Successful in 2m5s
## Summary

This PR fixes the release workflow to properly handle version bumping on PR merge and uses the new Docker registry authentication secrets.

## Changes

### Release Workflow (release.yml)
- **Version Bumping**: Now automatically bumps version on PR merge
  - Determines bump type from commit messages (major/minor/patch)
  - Commits version bump to `package.json` and `CHANGELOG.md`
  - Creates git tag for the release
- **Docker Registry Auth**: Uses `DOCKER_LOGIN` and `DOCKER_PASSWORD` secrets
  - Falls back gracefully if secrets are not configured
- **Tag Handling**: Checks if tag exists before creating (prevents failures)

### PR Workflow (pr.yml) - NEW
- Runs unit tests on every PR
- Analyzes commits to suggest bump type
- Comments the suggested bump type on the PR

### Documentation
- Added `WORKFLOW_ARCHITECTURE.md` explaining the workflow design

## Workflow Architecture

**Two-step process:**
1. **PR Workflow** (on PR): Analyzes commits and suggests bump type
2. **Release Workflow** (on merge): Bumps version, creates tag, builds Docker image

## Benefits

1. **No CI Loops**: Version bump commits are detected and skipped
2. **Clear Communication**: PR comments inform developers of version impact
3. **Semantic Versioning**: Automated adherence to semver rules
4. **Traceability**: Git tags and changelog reflect all changes

## Testing

The new workflows will be tested when this PR is merged.

Closes #13 (Add database test safety configuration)

Reviewed-on: #17
Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
2026-04-01 05:03:14 +00:00
david 59009f0bf7 feat: add view match link to admin matches page 2026-03-31 18:52:06 -07:00
david f9d6321721 fix: use ELO change instead of win rate for best partner calculation 2026-03-31 18:39:27 -07:00
david 6989decf6f fix: load .env.development in test setup files 2026-03-31 18:30:19 -07:00
david 4e112c92ae fix: remove hardcoded database URLs and use environment variables 2026-03-31 18:28:17 -07:00
david abc1963aea feat: add database test safety configuration 2026-03-31 18:23:47 -07:00
david 255b330695 fix: allowTies not saved when editing tournaments (closes #6)
Fix the allowTies checkbox not being saved when editing tournaments. Added comprehensive unit and E2E tests to verify the fix.

Co-authored-by: David Gwilliam <dhgwilliam@gmail.com>
Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
2026-04-01 00:20:25 +00:00
david 26c5158724 feat: set up development database and test cleanup utilities 2026-03-31 16:52:56 -07:00
david 48a96ce65f fix: improve availablePlayers query to handle undefined playerId 2026-03-31 16:44:48 -07:00
david 1f9f708f19 fix: handle empty playerId string in user edit API 2026-03-31 16:44:26 -07:00
david f04a0f4db9 test: add smoke and admin features acceptance tests 2026-03-31 16:16:20 -07:00
david 9a2c2d5c75 test: fix Navigation unit tests to handle updated session handling 2026-03-31 16:16:17 -07:00
david a22c801f0c feat: add match management admin panel with delete functionality 2026-03-31 16:16:13 -07:00
david 222fb0bdc3 feat: add delete player functionality to admin panel 2026-03-31 16:16:10 -07:00
david 81f023317e fix: update session handling to refresh admin navigation after login 2026-03-31 16:16:06 -07:00
david 7c2c198167 feat: add matches list page at /matches route 2026-03-31 13:19:03 -07:00
david 0ae4a171fd feat: add git commit hash to footer for version tracking 2026-03-31 11:44:13 -07:00
david f66242d569 fix: correct match diagram player positions to show teammates opposite each other 2026-03-31 11:36:24 -07:00
david 2062188cb3 fix: update API routes to handle Next.js 15+ params as Promise 2026-03-31 10:44:39 -07:00
david d595dfa62d fix: update Prisma client configuration and test files for Prisma 7.x compatibility 2026-03-31 10:41:04 -07:00
david a960bb8a41 feat: add user management link to admin dashboard 2026-03-31 10:26:37 -07:00
david f26cbf2f65 feat: add delete user functionality for site admins 2026-03-31 10:26:11 -07:00
david 2ed86dafe9 feat: add user management panel for superusers 2026-03-31 10:24:35 -07:00
david 0431a7fcf3 fix: add dynamic config to prevent static generation 2026-03-31 10:14:26 -07:00
david 1b5776951c fix: update auth-simple test to mock headers function 2026-03-31 09:18:14 -07:00
david 103c62497c fix: update authentication to support http://dhg.lol:51193 2026-03-31 09:16:58 -07:00
david 9609a15534 fix: configure Better Auth for euchre.notsosm.art domain 2026-03-31 09:01:33 -07:00
david 31c93de81a fix: disable trusted origins validation 2026-03-31 04:55:03 -07:00
david 39e7573e76 fix: add dhg.lol:51193 to trusted origins 2026-03-31 04:44:04 -07:00