fix(series): report created races, delete a series with its races; group Race Day sessions by today's races (1.43.1)
This commit is contained in:
1 parent
74dbbf6ae0
commit
dbda06d101
10 files changed
+133
-13
No files matched your search
@@ -62,6 +62,10 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
assert.deepEqual(rounds.map((event) => [event.raceConfig.qualifyingScoring, event.raceConfig.countedQualRounds, event.raceConfig.heatOrder]), [["best", 2, "fastest_last"], ["best", 2, "fastest_last"]], "ÖRC Winter is the default format, fastest heat last");
|
||||
const seedPractices = state.sessions.filter((session) => rounds.some((event) => event.id === session.eventId) && session.type === "practice");
|
||||
assert.deepEqual(seedPractices.map((session) => [session.durationMin, session.seedBestLapCount, session.seedMethod, session.driverIds.length]), [[5, 3, "consecutive", 0], [5, 3, "consecutive", 0]], "every round starts with a seeding practice that follows the round's drivers");
|
||||
assert.equal(dialogs.at(-1)?.message, "2 races created. They are listed below and under Race Setup.", "creating says how many races were made");
|
||||
await evaluate(`(() => { const form = document.getElementById("seriesCreateEvents"); form.elements.dates.value = "2026-11-01"; form.requestSubmit(); })()`);
|
||||
await waitFor(async () => dialogs.at(-1)?.message.startsWith("No new races were created"), "clicking again for an existing date says so");
|
||||
assert.equal((await savedState()).series.find((series) => series.id === saved.id).eventIds.length, 2);
|
||||
console.log("PASS a series is created with club, class and count rule, and its rounds are created from dates");
|
||||
|
||||
// The series is the hub for each round: drivers, a late entry, copy to the next round,
|
||||
@@ -138,6 +142,17 @@ export async function runSeriesSmoke({ evaluate, navigate, savedState, waitFor,
|
||||
assert.equal(pdf.title, "SR Winter Cup");
|
||||
assert.deepEqual(pdf.sections[0].rows[0], ["1", "SR Anna", "100", "", "1", "100"]);
|
||||
console.log("PASS the series PDF export contains the standings");
|
||||
|
||||
// Deleting the series asks whether its races go too (the test run accepts both questions).
|
||||
const seriesSessionIds = (await savedState()).sessions.filter((session) => rounds.some((event) => event.id === session.eventId)).map((session) => session.id);
|
||||
assert.ok(seriesSessionIds.length > 0);
|
||||
await evaluate(`document.getElementById("seriesDelete").click()`);
|
||||
await waitFor(async () => !(await savedState()).series.some((series) => series.id === saved.id), "series deleted");
|
||||
const afterDelete = await savedState();
|
||||
assert.equal(afterDelete.events.filter((event) => rounds.some((round) => round.id === event.id)).length, 0, "its races are gone from Race Setup");
|
||||
assert.equal(afterDelete.sessions.filter((session) => seriesSessionIds.includes(session.id)).length, 0, "with their heats");
|
||||
assert.ok(dialogs.some((dialog) => dialog.message.startsWith("Also delete the series' 2 races")), "the races are a separate question");
|
||||
console.log("PASS deleting a series can take its races along");
|
||||
} finally {
|
||||
dialogs.splice(dialogsAtStart);
|
||||
const current = await savedState();
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { buildRaceDaySessionGroups } from "../src/race_day_view.js";
|
||||
|
||||
const events = [
|
||||
{ id: "old", name: "Old race", date: "2026-10-01" },
|
||||
{ id: "today", name: "Winter #1", date: "2026-11-08" },
|
||||
{ id: "next", name: "Winter #2", date: "2026-11-22" },
|
||||
{ id: "undated", name: "Undated" },
|
||||
];
|
||||
const sessions = [
|
||||
{ id: "old_final", eventId: "old", status: "finished" },
|
||||
{ id: "old_practice", eventId: "old", status: "running" },
|
||||
{ id: "t_practice", eventId: "today", status: "finished" },
|
||||
{ id: "t_q1", eventId: "today", status: "ready" },
|
||||
{ id: "n_practice", eventId: "next", status: "ready" },
|
||||
{ id: "u_ready", eventId: "undated", status: "ready" },
|
||||
{ id: "u_done", eventId: "undated", status: "finished" },
|
||||
];
|
||||
const ids = (result) => result.groups.map((group) => [group.event.id, group.sessions.map((session) => session.id)]);
|
||||
|
||||
test("Race Day picker: today's races, live and selected sessions, grouped per race", () => {
|
||||
const result = buildRaceDaySessionGroups({ sessions, events, selectedId: "n_practice", today: "2026-11-08" });
|
||||
assert.deepEqual(ids(result), [
|
||||
["old", ["old_practice"]],
|
||||
["next", ["n_practice"]],
|
||||
["today", ["t_practice", "t_q1"]],
|
||||
["undated", ["u_ready"]],
|
||||
]);
|
||||
assert.equal(result.hidden, 2);
|
||||
});
|
||||
|
||||
test("Race Day picker: show all lists every session", () => {
|
||||
const result = buildRaceDaySessionGroups({ sessions, events, showAll: true, today: "2026-11-08" });
|
||||
assert.equal(result.hidden, 0);
|
||||
assert.equal(result.groups.flatMap((group) => group.sessions).length, sessions.length);
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import "./auth.test.js";
|
||||
import "./race_day_sessions.test.js";
|
||||
import "./overlay_leaderboard.test.js";
|
||||
import "./decoder_clock_check.test.js";
|
||||
import "./practice_callouts_logic.test.js";
|
||||
|
||||
Reference in new issue
Block a user