feat: unify competition schedule and results
This commit is contained in:
1 parent
4e10998794
commit
c9140b8622
12 files changed
+910
-245
No files matched your search
@@ -12,12 +12,13 @@ import {
|
||||
competitionHistoryGameDetailPath,
|
||||
createCompetitionSeriesHistory,
|
||||
formatCompetitionHistoryDate,
|
||||
formatCompetitionHistoryDayHeading,
|
||||
formatCompetitionHistoryTime,
|
||||
formatSeriesGameDuration,
|
||||
getSeriesHistoryRecordLabel,
|
||||
getSeriesHistoryResultLabel,
|
||||
getSeriesHistoryStatusLabel,
|
||||
getSeriesHistoryTimePresentation,
|
||||
isCompetitionHistoryCalendarDate,
|
||||
shouldDisplaySeriesHistoryScore,
|
||||
} from "../src/components/competition/competition-series-history.ts";
|
||||
import { isSeriesEntryWinner } from "../src/components/competition/series-score-card-model.ts";
|
||||
@@ -140,7 +141,7 @@ test("groups and orders Series by the Asia/Seoul calendar day", () => {
|
||||
);
|
||||
});
|
||||
|
||||
test("includes recorded in-progress Series and game-less completed decisions only", () => {
|
||||
test("includes recorded in-progress Series and game-less completed decisions", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const running = inProgressSeries("running-recorded", teamA, teamB, 1, 0);
|
||||
@@ -173,9 +174,6 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [
|
||||
readySeries("ready", teamA, teamB),
|
||||
waitingSeries("waiting"),
|
||||
inactiveSeries("inactive"),
|
||||
unrecordedRunning,
|
||||
administrative,
|
||||
running,
|
||||
@@ -193,6 +191,231 @@ test("includes recorded in-progress Series and game-less completed decisions onl
|
||||
assert.equal(rows[1].occurredAt, administrative.outcome.completedAt);
|
||||
});
|
||||
|
||||
test("includes ready and waiting Series in dated and final unscheduled groups", () => {
|
||||
const teamA = teamId("future-team-a");
|
||||
const teamB = teamId("future-team-b");
|
||||
const scheduledReady = withSchedule(
|
||||
readySeries("scheduled-ready", teamA, teamB),
|
||||
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const scheduledWaiting = withSchedule(waitingSeries("scheduled-waiting"), {
|
||||
date: "2026-07-15",
|
||||
time: null,
|
||||
timeZone: "Asia/Seoul",
|
||||
});
|
||||
const unscheduledReady = {
|
||||
...readySeries("unscheduled-ready", teamA, teamB),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 3 },
|
||||
};
|
||||
const unscheduledWaiting = {
|
||||
...waitingSeries("unscheduled-waiting"),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 4 },
|
||||
};
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [
|
||||
unscheduledWaiting,
|
||||
scheduledWaiting,
|
||||
unscheduledReady,
|
||||
scheduledReady,
|
||||
],
|
||||
games: [],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
history.map(({ dateKey }) => dateKey),
|
||||
["2026-07-15", "unknown"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
history[0].rows.map(({ series }) => series.seriesId),
|
||||
[scheduledReady.seriesId, scheduledWaiting.seriesId],
|
||||
);
|
||||
assert.deepEqual(
|
||||
history[1].rows.map(({ series }) => series.seriesId),
|
||||
[unscheduledReady.seriesId, unscheduledWaiting.seriesId],
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps missing historical timestamps separate from unscheduled future Series", () => {
|
||||
const teamA = teamId("missing-record-time-a");
|
||||
const teamB = teamId("missing-record-time-b");
|
||||
const historical = completedSeries({
|
||||
id: "missing-record-time",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
completedAt: "not-an-iso-date",
|
||||
outcome: "administrative",
|
||||
});
|
||||
const future = readySeries("missing-schedule-date", teamA, teamB);
|
||||
|
||||
const history = createCompetitionSeriesHistory({
|
||||
series: [future, historical],
|
||||
games: [],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
history.map(({ dateKey }) => dateKey),
|
||||
["record-unknown", "unknown"],
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDate(history[0].dateKey),
|
||||
"기록 일시 미상",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDate(history[1].dateKey),
|
||||
"일정 미정",
|
||||
);
|
||||
});
|
||||
|
||||
test("prefers recorded start and decision times over an attached schedule", () => {
|
||||
const teamA = teamId("record-precedence-a");
|
||||
const teamB = teamId("record-precedence-b");
|
||||
const played = withSchedule(
|
||||
completedSeries({
|
||||
id: "recorded-start-precedence",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 0,
|
||||
completedAt: "2026-07-12T12:00:00.000Z",
|
||||
}),
|
||||
{ date: "2026-08-01", time: "20:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const recordedGame = game({
|
||||
id: "recorded-start-precedence-game",
|
||||
seriesId: played.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 20,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-12T11:00:00.000Z",
|
||||
});
|
||||
const decided = withSchedule(
|
||||
completedSeries({
|
||||
id: "decision-precedence",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 0,
|
||||
scoreB: 0,
|
||||
completedAt: "2026-07-13T11:00:00.000Z",
|
||||
outcome: "administrative",
|
||||
}),
|
||||
{ date: "2026-08-02", time: "21:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const running = withSchedule(
|
||||
inProgressSeries("running-start-precedence", teamA, teamB, 1, 0),
|
||||
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const runningGame = game({
|
||||
id: "running-start-precedence-game",
|
||||
seriesId: running.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 21,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-14T11:00:00.000Z",
|
||||
});
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [running, decided, played],
|
||||
games: [runningGame, recordedGame],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.equal(rows[0].timestampSource, "game-start");
|
||||
assert.equal(rows[0].occurredAt, recordedGame.startedAt);
|
||||
assert.equal(rows[1].timestampSource, "decision");
|
||||
assert.equal(rows[1].occurredAt, decided.outcome.completedAt);
|
||||
assert.equal(rows[2].timestampSource, "game-start");
|
||||
assert.equal(rows[2].occurredAt, runningGame.startedAt);
|
||||
});
|
||||
|
||||
test("keeps Series with invalid recorded Game starts in the missing-record group", () => {
|
||||
const teamA = teamId("invalid-game-start-a");
|
||||
const teamB = teamId("invalid-game-start-b");
|
||||
const scheduledRunning = withSchedule(
|
||||
inProgressSeries("invalid-running-scheduled", teamA, teamB, 0, 0),
|
||||
{ date: "2026-08-03", time: "22:00", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const unscheduledRunning = {
|
||||
...inProgressSeries("invalid-running-unscheduled", teamA, teamB, 0, 0),
|
||||
stage: { type: "upper" as const, roundNumber: 1, displayOrder: 2 },
|
||||
};
|
||||
const completed = completedSeries({
|
||||
id: "invalid-completed-game-start",
|
||||
teamA,
|
||||
teamB,
|
||||
scoreA: 1,
|
||||
scoreB: 0,
|
||||
displayOrder: 3,
|
||||
completedAt: "2026-07-15T11:00:00.000Z",
|
||||
});
|
||||
const invalidGames = [scheduledRunning, unscheduledRunning, completed].map(
|
||||
(series, index) =>
|
||||
game({
|
||||
id: `invalid-start-game-${index}`,
|
||||
seriesId: series.seriesId,
|
||||
ordinal: 1,
|
||||
displayNumber: 30 + index,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "not-an-iso-date",
|
||||
}),
|
||||
);
|
||||
invalidGames.push(
|
||||
game({
|
||||
id: "mixed-valid-start-game",
|
||||
seriesId: scheduledRunning.seriesId,
|
||||
ordinal: 2,
|
||||
displayNumber: 33,
|
||||
blueTeamId: teamA,
|
||||
redTeamId: teamB,
|
||||
winnerTeamId: teamA,
|
||||
startedAt: "2026-07-14T11:00:00.000Z",
|
||||
}),
|
||||
);
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [completed, unscheduledRunning, scheduledRunning],
|
||||
games: invalidGames,
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.equal(rows.length, 3);
|
||||
for (const row of rows) {
|
||||
assert.equal(row.dateKey, "record-unknown");
|
||||
assert.equal(row.timestampSource, "game-start");
|
||||
assert.equal(row.occurredAt, null);
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(row), {
|
||||
text: "—",
|
||||
dateTime: null,
|
||||
screenReaderText: "시작 시각 기록 없음",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("hides unscheduled inactive Series but includes a scheduled conditional Series", () => {
|
||||
const unscheduledInactive = inactiveSeries("inactive-unscheduled");
|
||||
const scheduledInactive = withSchedule(
|
||||
inactiveSeries("inactive-scheduled"),
|
||||
{ date: "2026-07-16", time: null, timeZone: "Asia/Seoul" },
|
||||
);
|
||||
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [unscheduledInactive, scheduledInactive],
|
||||
games: [],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
|
||||
assert.deepEqual(
|
||||
rows.map(({ series }) => series.seriesId),
|
||||
[scheduledInactive.seriesId],
|
||||
);
|
||||
assert.equal(getSeriesHistoryStatusLabel(scheduledInactive), "필요 시");
|
||||
});
|
||||
|
||||
test("sorts tied timestamps deterministically and ignores orphan Games", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
@@ -241,6 +464,13 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
const running = inProgressSeries("running", teamA, teamB, 1, 0);
|
||||
const ready = readySeries("ready-status", teamA, teamB);
|
||||
const waiting = waitingSeries("waiting-status");
|
||||
const conditional = withSchedule(inactiveSeries("conditional-status"), {
|
||||
date: "2026-07-16",
|
||||
time: null,
|
||||
timeZone: "Asia/Seoul",
|
||||
});
|
||||
const played = completedSeries({
|
||||
id: "played",
|
||||
teamA,
|
||||
@@ -292,6 +522,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
outcome: "administrative",
|
||||
});
|
||||
|
||||
assert.equal(getSeriesHistoryStatusLabel(ready), "예정");
|
||||
assert.equal(getSeriesHistoryStatusLabel(waiting), "예정");
|
||||
assert.equal(getSeriesHistoryStatusLabel(conditional), "필요 시");
|
||||
assert.equal(getSeriesHistoryStatusLabel(running), "진행 중");
|
||||
for (const completed of [
|
||||
played,
|
||||
@@ -304,6 +537,9 @@ test("separates lifecycle status from played and adjudicated result labels", ()
|
||||
assert.equal(getSeriesHistoryStatusLabel(completed), "최종");
|
||||
}
|
||||
|
||||
assert.equal(getSeriesHistoryResultLabel(ready), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(waiting), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(conditional), "VS");
|
||||
assert.equal(getSeriesHistoryResultLabel(running), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(played), null);
|
||||
assert.equal(getSeriesHistoryResultLabel(playedDraw), "무승부");
|
||||
@@ -341,6 +577,43 @@ test("describes recorded Games, decisions, and legacy missing records", () => {
|
||||
assert.equal(getSeriesHistoryRecordLabel(played, 0, false), "게임 기록 미등록");
|
||||
});
|
||||
|
||||
test("presents known and unknown future times without an invalid time value", () => {
|
||||
const teamA = teamId("time-team-a");
|
||||
const teamB = teamId("time-team-b");
|
||||
const knownTime = withSchedule(
|
||||
readySeries("known-scheduled-time", teamA, teamB),
|
||||
{ date: "2026-07-15", time: "21:30", timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const unknownTime = withSchedule(
|
||||
readySeries("unknown-scheduled-time", teamA, teamB),
|
||||
{ date: "2026-07-15", time: null, timeZone: "Asia/Seoul" },
|
||||
);
|
||||
const rows = createCompetitionSeriesHistory({
|
||||
series: [unknownTime, knownTime],
|
||||
games: [],
|
||||
}).flatMap(({ rows }) => rows);
|
||||
const knownRow = rows.find(
|
||||
({ series }) => series.seriesId === knownTime.seriesId,
|
||||
);
|
||||
const unknownRow = rows.find(
|
||||
({ series }) => series.seriesId === unknownTime.seriesId,
|
||||
);
|
||||
|
||||
assert.ok(knownRow);
|
||||
assert.ok(unknownRow);
|
||||
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(knownRow), {
|
||||
text: "21:30",
|
||||
dateTime: "2026-07-15T21:30:00+09:00",
|
||||
screenReaderText: null,
|
||||
});
|
||||
assert.deepEqual(getSeriesHistoryTimePresentation(unknownRow), {
|
||||
text: "--:--",
|
||||
dateTime: null,
|
||||
screenReaderText: "시작 시간 미정",
|
||||
});
|
||||
});
|
||||
|
||||
test("shows a numeric score only for played records", () => {
|
||||
const teamA = teamId("team-a");
|
||||
const teamB = teamId("team-b");
|
||||
@@ -423,25 +696,20 @@ test("formats recorded Game duration and omits unknown legacy zero values", () =
|
||||
});
|
||||
|
||||
test("formats history dates and times explicitly in Asia/Seoul", () => {
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 5일 (일)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-05"), "7월 05일 (일)");
|
||||
assert.equal(formatCompetitionHistoryDate("2026-07-13"), "7월 13일 (월)");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-05", 1),
|
||||
"7월 5일 (일) · 1경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("2026-07-13", 2),
|
||||
"7월 13일 (월) · 2경기",
|
||||
);
|
||||
assert.equal(
|
||||
formatCompetitionHistoryTime("2026-07-12T15:05:00.000Z"),
|
||||
"00:05",
|
||||
);
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일시 정보 없음");
|
||||
assert.equal(formatCompetitionHistoryDate("unknown"), "일정 미정");
|
||||
assert.equal(
|
||||
formatCompetitionHistoryDayHeading("unknown", 1),
|
||||
"일시 정보 없음 · 1경기",
|
||||
formatCompetitionHistoryDate("record-unknown"),
|
||||
"기록 일시 미상",
|
||||
);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("2026-07-05"), true);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("record-unknown"), false);
|
||||
assert.equal(isCompetitionHistoryCalendarDate("unknown"), false);
|
||||
});
|
||||
|
||||
function playedSeriesWithGame({
|
||||
@@ -647,3 +915,14 @@ function seriesId(value: string): SeriesId {
|
||||
function teamId(value: string): TeamId {
|
||||
return value as TeamId;
|
||||
}
|
||||
|
||||
function withSchedule<T extends SeriesProjection>(
|
||||
series: T,
|
||||
schedule: {
|
||||
date: string;
|
||||
time: string | null;
|
||||
timeZone: "Asia/Seoul";
|
||||
},
|
||||
): T & { schedule: typeof schedule } {
|
||||
return { ...series, schedule };
|
||||
}
|
||||
@@ -27,7 +27,7 @@ test("uses tabs only in progress or when finished and exposes operations only to
|
||||
);
|
||||
assert.deepEqual(
|
||||
publicTabs.map((tab) => tab.label),
|
||||
["대진표·순위", "경기 기록", "팀", "일정·안내"],
|
||||
["대진표·순위", "경기 일정·결과", "팀", "안내"],
|
||||
);
|
||||
|
||||
const managerTabs = createMatchDetailTabs({
|
||||
|
||||
Reference in new issue
Block a user