feat: link competition games to detail analysis

Route each result-history Game by its global display number and preserve the Competition return target. Refuse stale detail fallbacks so a missing requested Game cannot silently show another Game.
This commit is contained in:
dahyeon committed 2026-07-13 10:41:44 +00:00
1 parent 3c60081ece
commit 3bd3120eb1
11 files changed
+382 -54

No files matched your search

@@ -9,6 +9,7 @@ import type {
TeamId,
} from "@lolympus/contracts";
import {
competitionHistoryGameDetailPath,
createCompetitionSeriesHistory,
formatCompetitionHistoryDate,
formatCompetitionHistoryTime,
@@ -70,6 +71,40 @@ test("aggregates Games under their Series and preserves Series slot scores", ()
assert.equal(history[0].rows[0].timestampSource, "game-start");
});
test("builds Game detail routes from global display numbers, not Series ordinals", () => {
const recordedGame = game({
id: "globally-numbered-game",
seriesId: seriesId("second-series"),
ordinal: 1,
displayNumber: 17,
blueTeamId: teamId("team-a"),
redTeamId: teamId("team-b"),
winnerTeamId: teamId("team-a"),
startedAt: "2026-07-13T09:00:00.000Z",
});
assert.equal(
competitionHistoryGameDetailPath(
"community-1",
"match-1",
recordedGame,
),
"/communities/community-1/internal-stats/match/match-1/game/17",
);
assert.equal(
competitionHistoryGameDetailPath("community-1", "match-1", {
displayNumber: 0,
}),
null,
);
assert.equal(
competitionHistoryGameDetailPath("community-1", "match-1", {
displayNumber: 1.5,
}),
null,
);
});
test("groups and orders Series by the Asia/Seoul calendar day", () => {
const firstDay = playedSeriesWithGame({
id: "first-day",
@@ -0,0 +1,13 @@
import assert from "node:assert/strict";
import test from "node:test";
import { selectInternalMatchGame } from "../src/lib/internal-match-game-selection.ts";
test("selects only the Game explicitly requested by its global number", () => {
const firstGame = { gameNumber: 1, id: "first" };
const requestedGame = { gameNumber: 17, id: "requested" };
const games = [firstGame, requestedGame];
assert.equal(selectInternalMatchGame(games, 17), requestedGame);
assert.equal(selectInternalMatchGame(games, 99), null);
assert.equal(selectInternalMatchGame(games, Number.NaN), null);
});