brackt/app/services/simulations/__tests__
Chris Parsons 43dbdf0040
Add not-participating exclusion support for event results (#446)
* Add notParticipating flag to allow excluding withdrawn participants from qualifying-points simulators

Adds a `not_participating` boolean column to `event_results` so admins can
mark a participant as not competing in a specific upcoming major (e.g. Alcaraz
withdrawing from Wimbledon due to injury). The golf, tennis, and CS2 major
simulators now query this flag for incomplete events and exclude those
participants from the event's draw/field, redistributing probability weight
to the remaining field. Admin UI for qualifying major_tournament events gains
a "Not Participating" card to mark/unmark withdrawals before the event runs.

https://claude.ai/code/session_01HxNPLEXzr5Km3suWrJe2F9

* Address code review feedback on not-participating flag

Security: unmark-not-participating now validates the result exists, belongs
to this event, and is actually a DNP row before deleting. mark-not-participating
now returns a user-friendly error on duplicate-key constraint violations.

Code quality: extract shared getExcludedByEventMap() utility to event-result
model, eliminating the duplicated 20-line exclusion-loading block that was
copy-pasted into all three simulators. Fix hasParticipantResult() to exclude
notParticipating rows so it correctly reflects actual competition participation.
Remove optional chaining on the non-optional notParticipatingIds field in the
admin UI. Fix misleading empty-state message.

Tests: replace the misleading first tennis DNP test (which never used the
activeIds variable it created) with a test that explicitly validates the
fallback behaviour when too few players remain after exclusion. Add three CS2
DNP tests covering the excluded-team-gets-zero-QP path, the redistribution
of wins, and per-event pool independence.

https://claude.ai/code/session_01HxNPLEXzr5Km3suWrJe2F9

* Fix lint errors: replace non-null assertions in CS2 DNP test

https://claude.ai/code/session_01HxNPLEXzr5Km3suWrJe2F9

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-19 11:13:32 -07:00
..
afl-simulator.test.ts Add projected-wins input mode to admin Elo Ratings page (#306) 2026-04-17 12:40:08 -07:00
brackt-simulator.test.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
college-hockey-simulator.test.ts Fix college hockey bracket resolution (#396) 2026-05-08 12:29:39 -07:00
cs-major-simulator.test.ts Add not-participating exclusion support for event results (#446) 2026-05-19 11:13:32 -07:00
darts-simulator.test.ts Fix QP tie rounding and finalized scoring (#440) 2026-05-17 21:58:53 -07:00
epl-simulator.test.ts Fix EPL simulator parity config (#421) 2026-05-13 15:02:23 -07:00
golf-simulator.test.ts Add not-participating exclusion support for event results (#446) 2026-05-19 11:13:32 -07:00
input-policy.test.ts Fix EPL simulator parity config (#421) 2026-05-13 15:02:23 -07:00
llws-simulator.test.ts fix: infer LLWS bracket side from name when externalId is null (#285) 2026-04-09 09:51:16 -04:00
manifest.test.ts Fix EPL simulator parity config (#421) 2026-05-13 15:02:23 -07:00
mlb-simulator.test.ts Fix simulator brackets: NHL bracket-aware mode, MLB/NBA/WNBA sourceElo support (#358) 2026-04-30 08:33:57 -07:00
mls-simulator.test.ts Add MLS standings sync and fix simulator conference resolution (#423) 2026-05-14 15:39:40 -07:00
nba-simulator.test.ts fix: NBA play-in bracket advancement bugs (#292) 2026-04-12 22:25:32 -07:00
ncaa-football-simulator.test.ts Add NCAA Football CFP simulator (12-team bracket) (#278) 2026-04-08 09:48:32 -04:00
ncaam-simulator.test.ts Upgrade NCAA preseason simulators (#419) 2026-05-12 22:26:25 -07:00
ncaaw-simulator.test.ts Upgrade NCAA preseason simulators (#419) 2026-05-12 22:26:25 -07:00
nfl-simulator.test.ts Add NFL season + playoffs Monte Carlo simulator (#272) 2026-04-07 09:39:34 -04:00
nhl-simulator.test.ts Fix simulator brackets: NHL bracket-aware mode, MLB/NBA/WNBA sourceElo support (#358) 2026-04-30 08:33:57 -07:00
nll-simulator.test.ts Add NLL box lacrosse simulator implementation plan and preseason-draftability guidance (#417) 2026-05-12 14:22:34 -07:00
runner.test.ts Hide completed seasons in admin tools (#418) 2026-05-12 16:52:26 -07:00
simulator-config.test.ts Fix college hockey bracket resolution (#396) 2026-05-08 12:29:39 -07:00
snooker-simulator.test.ts Add snooker bracket simulator and Elo ratings admin UI, fixes #119 2026-03-23 08:24:28 -07:00
tennis-simulator.test.ts Add not-participating exclusion support for event results (#446) 2026-05-19 11:13:32 -07:00
ucl-simulator.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
wnba-simulator.test.ts Fix simulator brackets: NHL bracket-aware mode, MLB/NBA/WNBA sourceElo support (#358) 2026-04-30 08:33:57 -07:00
world-cup-simulator.test.ts Canonical tournament layer: schema + backfill (1/2) (#365) 2026-05-01 20:13:18 -07:00