feat: add competition series result history
This commit is contained in:
1 parent
aa675199af
commit
3c60081ece
5 files changed
+503
-44
No files matched your search
@@ -10,9 +10,13 @@ import type {
|
||||
} from "@lolympus/contracts";
|
||||
import {
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
getSeriesHistoryStatusLabel,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
} from "../src/components/competition/competition-series-history.ts";
|
||||
import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
|
||||
|
||||
test("aggregates Games under their Series and preserves Series slot scores", () => {
|
||||
const teamA = teamId("team-a");
|
||||
@@ -265,6 +269,80 @@ test("returns explicit status labels for played and adjudicated outcomes", () =>
|
||||
);
|
||||
});
|
||||
|
||||
test("shows a numeric score only for played records", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const playedDraw = completedSeries({
|
||||
id: "played-draw",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "draw",
|
||||
});
|
||||
const administrativeDraw = {
|
||||
...playedDraw,
|
||||
seriesId: seriesId("administrative-draw"),
|
||||
outcome: {
|
||||
...playedDraw.outcome,
|
||||
basis: {
|
||||
type: "administrative" as const,
|
||||
decisionFactId: "draw-fact" as never,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert.equal(
|
||||
shouldDisplaySeriesHistoryScore(
|
||||
inProgressSeries("running-score", teamA, teamB, 1, 0),
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldDisplaySeriesHistoryScore(
|
||||
completedSeries({
|
||||
id: "played-score",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 2,
|
||||
scoreB: 1,
|
||||
}),
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(shouldDisplaySeriesHistoryScore(playedDraw), true);
|
||||
assert.equal(shouldDisplaySeriesHistoryScore(administrativeDraw), false);
|
||||
assert.equal(
|
||||
shouldDisplaySeriesHistoryScore(
|
||||
completedSeries({
|
||||
id: "forfeit-score",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 1,
|
||||
outcome: "forfeit",
|
||||
}),
|
||||
),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("uses the official outcome winner even when adjudicated score order differs", () => {
|
||||
const teamA = teamId("official-winner");
|
||||
const teamB = teamId("score-leader");
|
||||
const series = completedSeries({
|
||||
id: "adjudicated-winner",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 1,
|
||||
outcome: "forfeit",
|
||||
});
|
||||
|
||||
assert.equal(isSeriesEntryWinner(series, teamA), true);
|
||||
assert.equal(isSeriesEntryWinner(series, teamB), false);
|
||||
});
|
||||
|
||||
test("formats recorded Game duration and omits unknown legacy zero values", () => {
|
||||
assert.equal(formatSeriesGameDuration(1_875), "31:15");
|
||||
assert.equal(formatSeriesGameDuration(3_661), "1:01:01");
|
||||
@@ -272,6 +350,15 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
|
||||
assert.equal(formatSeriesGameDuration(-1), null);
|
||||
});
|
||||
|
||||
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "07월 13일 (월)");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
||||
"00:05",
|
||||
);
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
|
||||
});
|
||||
|
||||
function playedSeriesWithGame({
|
||||
id,
|
||||
displayOrder,
|
||||
|
||||
Reference in new issue
Block a user