claude/reprocess-bracket-scoring-mbkfa4 #128

Merged
chrisp merged 3 commits from claude/reprocess-bracket-scoring-mbkfa4 into main 2026-07-04 04:09:10 +00:00
2 changed files with 9 additions and 6 deletions
Showing only changes of commit 698c6a6509 - Show all commits

View file

@ -286,7 +286,7 @@ export function PlayoffBracket({
.map((id) => participantMap.get(id))
.filter((p): p is Participant => p !== undefined)
// Owned-by-a-manager players first, then alphabetical by name.
.sort((a, b) => {
.toSorted((a, b) => {
const aOwned = ownershipMap.has(a.id);
const bOwned = ownershipMap.has(b.id);
if (aOwned !== bOwned) return aOwned ? -1 : 1;

View file

@ -1,5 +1,7 @@
import { describe, it, expect, vi, beforeEach } from "vitest";
import type { Mock } from "vitest";
import type * as DrizzleOrm from "drizzle-orm";
import type * as ScoringCalculatorModule from "~/models/scoring-calculator";
vi.mock("~/database/context", () => ({
database: vi.fn(),
@ -10,7 +12,7 @@ vi.mock("~/models/scoring-calculator", async () => {
// to processQualifyingEvent reflects the mock canonical results AND the bracket's
// structural tie span (deriveBracketQualifyingStates / getRoundConfig). Only the
// DB-touching orchestrators are stubbed.
const actual = await vi.importActual<typeof import("~/models/scoring-calculator")>(
const actual = await vi.importActual<typeof ScoringCalculatorModule>(
"~/models/scoring-calculator"
);
return {
@ -975,11 +977,12 @@ describe("syncMajorFromPrimaryEvent", () => {
).toHaveLength(4);
// The mirror window was scored with the STRUCTURAL span, not the row count.
const mirrorCall = vi
.mocked(processQualifyingEvent)
.mock.calls.find((c) => c[0] === "ev-MIRROR");
const mirrorCall = (processQualifyingEvent as Mock).mock.calls.find(
(c) => c[0] === "ev-MIRROR"
);
expect(mirrorCall).toBeDefined();
const tieMap = mirrorCall![2]!.canonicalTieCountByPlacement as Map<number, number>;
if (!mirrorCall) return;
const tieMap = mirrorCall[2].canonicalTieCountByPlacement as Map<number, number>;
expect(tieMap.get(9)).toBe(8); // R16 tier spans 8, not the 4 rows currently there
expect(tieMap.get(5)).toBe(4); // QF tier spans 4
});