feat(race-setup): group the race list into today, upcoming and folded done, with progress and search (1.52.0)

This commit is contained in:
larssand committed 2026-11-02 08:21:17 +01:00
1 parent b2e08db3d8
commit b23410c190
13 files changed
+213 -29

No files matched your search

+13
View File
@@ -107,4 +107,17 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState,
return order.includes(q12.id) && order.indexOf(q12.id) < order.indexOf(q11.id);
}, "the order is saved on the race");
console.log("PASS Race Setup lists sessions in running order and ▲▼ change it");
// The race list: races from past dates are folded away under Done; search finds them.
await navigate("race_setup", "raceWizardStepForm");
const raceId = (await raceState()).id;
assert.equal(await evaluate(`document.querySelector('[data-event-row="${raceId}"]').closest("details")?.id || ""`), "eventListDone", "a race from a past date is under Done");
assert.equal(await evaluate(`document.getElementById("eventListDone").open`), false, "Done is folded by default");
if (await evaluate(`Boolean(document.getElementById("eventListSearch"))`)) {
await evaluate(`(() => { const box = document.getElementById("eventListSearch"); box.value = "endurance"; box.dispatchEvent(new Event("input")); })()`);
assert.equal(await evaluate(`document.getElementById("eventListDone").open`), true, "search opens Done");
assert.equal(await evaluate(`document.querySelector('[data-event-row="${raceId}"]').hidden`), false);
assert.ok(await evaluate(`[...document.querySelectorAll("[data-event-row]")].some((row) => row.hidden)`), "other races are filtered out");
}
console.log("PASS Race Setup groups races into today, upcoming and a folded Done list, with search");
}
+32
View File
@@ -0,0 +1,32 @@
import test from "node:test";
import assert from "node:assert/strict";
import { groupEventsForList, getEventProgress } from "../src/race_list_logic.js";
const s = (id, eventId, name, status = "ready", type = "qualification") => ({ id, eventId, name, status, type });
const sessions = [
s("a1", "a", "Q1 H1", "finished"), s("a2", "a", "Q1 H2"),
s("b1", "b", "Q1 H1", "finished"),
s("c1", "c", "Q1 H1"),
s("d1", "d", "Q1 H1", "running"),
];
const events = [
{ id: "a", name: "Cup #2 2WD", date: "2026-11-08" },
{ id: "b", name: "Cup #1 2WD", date: "2026-11-01" },
{ id: "c", name: "Old unfinished", date: "2026-10-01" },
{ id: "d", name: "Live", date: "2026-10-30" },
{ id: "e", name: "Cup #2 4WD", date: "2026-11-08" },
{ id: "f", name: "Today", date: "2026-11-02" },
];
const getSessions = (id) => sessions.filter((item) => item.eventId === id);
test("races are grouped today / upcoming / done, per date", () => {
const groups = groupEventsForList(events, getSessions, "2026-11-02");
assert.deepEqual(groups.today.flatMap((day) => day.items.map((item) => item.event.id)), ["d", "f"], "today's date and anything running");
assert.deepEqual(groups.upcoming.map((day) => [day.date, day.items.map((item) => item.event.id)]), [["2026-11-08", ["a", "e"]]], "same day together");
assert.deepEqual(groups.done.map((day) => day.date), ["2026-11-01", "2026-10-01"], "newest done first");
});
test("progress says what is running or next and how many are run", () => {
assert.deepEqual(getEventProgress(events[0], getSessions("a")), { total: 2, done: 1, live: "", next: "Q1 H2" });
assert.equal(getEventProgress(events[3], getSessions("d")).live, "Q1 H1");
});
+1
View File
@@ -1,4 +1,5 @@
import "./auth.test.js";
import "./race_list.test.js";
import "./day_schedule.test.js";
import "./race_day_live.test.js";
import "./series_next_step.test.js";