brackt/app/models/__tests__
Chris Parsons 442b392461
Add audit logging for commissioner actions (#293)
Closes #144

* feat: add commissioner audit log for league transparency (issue #144)

Adds a complete audit log system so league members can verify that
settings, draft order, picks, and time banks have not been quietly
changed without their awareness.

Changes:
- database/schema.ts: new `audit_action` enum + `commissioner_audit_log`
  table (seasonId, leagueId, actorClerkId, actorDisplayName, action,
  affectedTeamIds[], details jsonb, createdAt)
- drizzle/0075: generated migration for the new table
- app/models/audit-log.ts: createAuditLogEntry, getAuditLogForSeason
  (paginated), logCommissionerAction (resolves display name automatically)
- app/lib/audit-log-display.ts: shared formatAuditDetail() helper used by
  both the league home widget and the full audit log page
- app/routes/leagues/$leagueId.audit-log.tsx: new read-only route at
  /leagues/:id/audit-log, accessible to all league members, with
  action-type filter and pagination
- app/routes.ts: registers the new route
- League home page ($leagueId.server.ts / $leagueId.tsx): "Recent Activity"
  summary card showing the last 5 entries with "View all" link
- Settings page ($leagueId.settings.tsx): "View Full Audit Log" link card;
  audit log calls added for league/draft settings changes, draft order
  set/randomized, and draft reset
- API routes: audit log calls added to draft.start, draft.pause,
  draft.resume, draft.rollback, draft.adjust-time-bank, draft.force-autopick,
  draft.force-manual-pick, draft.replace-pick
- Tests: 11 new unit tests for the audit-log model; mocks added to 3
  existing route test files to account for the new logCommissionerAction call

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

* fix: validate action filter URL param against known enum values

The action filter on the audit log route was cast directly from the URL
search param to AuditAction without validation. An invalid value would
be passed into the Drizzle inArray() call, potentially throwing a
PostgreSQL enum type error. Now validates against the actual enum values
before using the filter.

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

* Fix lint errors: use !== instead of != and toSorted instead of sort

https://claude.ai/code/session_01NdiwK2fbtKhAD3XuD58fTm

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-13 15:45:39 -07:00
..
afl-finals.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
audit-log.test.ts Add audit logging for commissioner actions (#293) 2026-04-13 15:45:39 -07:00
auto-pick.test.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
bracket-integration.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
bracket-seeding.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
bracket-templates.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
cfp-12-bracket.test.ts Add NCAA Football CFP simulator (12-team bracket) (#278) 2026-04-08 09:48:32 -04:00
commissioner.test.ts Grant sitewide admins commissioner-level access in leagues (#162) 2026-03-18 00:41:56 -07:00
executeAutoPick.timer.test.ts Fix while_on autodraft stalling between chain bursts, fixes #190 (#222) 2026-03-24 19:09:38 -07:00
group-stage-match.test.ts Add FIFA World Cup 2026 support with group stage display and Monte Carlo simulator (#242) 2026-03-29 10:27:47 -07:00
ncaa-68-bracket.test.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
nfl-bracket.test.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
participant-expected-value.test.ts fix: address VORP code review issues (#283) 2026-04-08 23:20:02 -04:00
playoff-match-game.test.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
playoff-match-odds.test.ts Add playoff match game scheduling and odds management (#135) 2026-03-11 14:17:43 -07:00
point-progression.test.ts feat: add recharts library and implement PointProgressionChart component for historical views 2025-11-14 21:18:34 -08:00
process-match-result.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
progressive-floor-scoring.test.ts Fix partial bracket scoring, rank labels, and Discord notification bugs (#158) 2026-03-17 12:34:10 -07:00
qualifying-points.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
regular-season-standings.test.ts Fix standings upsert no-op: use EXCLUDED pseudo-table (#215) 2026-03-23 21:22:53 -07:00
scoring-calculator-qualifying.test.ts feat: Implement Qualifying Points Standings component and related logic 2025-11-11 10:08:25 -08:00
scoring-calculator.test.ts feat: Implement bracket expansion plan to support various tournament structures 2025-11-03 09:36:16 -08:00
scoring-event-dashboard.test.ts Show events on multiple dates when games span requested date range (#254) 2026-04-01 13:39:03 -07:00
season-standings.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
sports-season.clone.test.ts feat: clone sports season (#282) (#288) 2026-04-11 22:03:37 -07:00
sports-season.test.ts feat: sort admin sports seasons by status, sport name, then year (#286) 2026-04-09 10:07:18 -04:00
standings-snapshots.test.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
surface-elo.test.ts Add tennis Grand Slam simulator with surface Elo ratings, fixes #116 (#216) 2026-03-23 23:59:35 -07:00
team-projected-score.test.ts Fix tiebreaker incorrectly separating tied teams with pending participants, fixes #244 (#245) 2026-03-29 16:59:13 -07:00
tiebreaker-logic.test.ts Fix tiebreaker incorrectly separating tied teams with pending participants, fixes #244 (#245) 2026-03-29 16:59:13 -07:00
upcoming-calendar.test.ts Exclude completed playoff matches from upcoming events query (#247) 2026-03-31 10:08:25 -07:00