The live tennis-draw sync now fans eliminations out to mirror windows, but the admin bracket UI is a second live scoring path: when an admin enters match results for a shared qualifying major, mirror windows already receive "Qualifying Points Update" posts via the fan-out, yet the "Knocked Out" section was still dropped there. Thread the newly-decided losers (losers of matches reaching completion for the first time this action) through the admin route's fanOutMajorIfPrimary calls in the set-winner and set-round-winners intents, reusing the same per-window elimination translation. Re-scores, complete-round, reprocess, and finalize decide no new losers, so they pass nothing and never re-announce an exit — mirroring populateBracketFromDraw's first-completion rule. Extract the first-completion decision into a pure newlyDecidedLosers() helper shared by both intents and unit-tested directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WZGsG5R1q3kyKCaXuysiWJ
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { newlyDecidedLosers } from "../admin.sports-seasons.$id.events.$eventId.bracket.helpers";
|
|
|
|
describe("newlyDecidedLosers", () => {
|
|
it("returns losers of matches that were not already complete", () => {
|
|
expect(
|
|
newlyDecidedLosers([
|
|
{ wasComplete: false, loserId: "sp-1" },
|
|
{ wasComplete: false, loserId: "sp-2" },
|
|
])
|
|
).toEqual(["sp-1", "sp-2"]);
|
|
});
|
|
|
|
it("drops re-scores of already-complete matches (no re-announce)", () => {
|
|
// sp-1's match just finished; sp-2's match was already complete before this
|
|
// action — only sp-1 is a NEW knockout.
|
|
expect(
|
|
newlyDecidedLosers([
|
|
{ wasComplete: false, loserId: "sp-1" },
|
|
{ wasComplete: true, loserId: "sp-2" },
|
|
])
|
|
).toEqual(["sp-1"]);
|
|
});
|
|
|
|
it("skips entries with an unknown loser", () => {
|
|
expect(
|
|
newlyDecidedLosers([
|
|
{ wasComplete: false, loserId: null },
|
|
{ wasComplete: false, loserId: "sp-3" },
|
|
])
|
|
).toEqual(["sp-3"]);
|
|
});
|
|
|
|
it("returns an empty array when nothing was newly decided", () => {
|
|
expect(
|
|
newlyDecidedLosers([
|
|
{ wasComplete: true, loserId: "sp-1" },
|
|
{ wasComplete: true, loserId: "sp-2" },
|
|
])
|
|
).toEqual([]);
|
|
expect(newlyDecidedLosers([])).toEqual([]);
|
|
});
|
|
});
|