feat(race-day): call the next heat - asked by hand, automatic with the autopilot (1.51.0)
This commit is contained in:
1 parent
fdc6c179dc
commit
b2e08db3d8
15 files changed
+178
-31
No files matched your search
@@ -51,6 +51,9 @@ export async function runDayScheduleSmoke({ evaluate, navigate, savedState, wait
|
||||
await evaluate(`(() => { const form = document.getElementById("dayPlanForm"); form.elements.startTime.value = ${JSON.stringify(hhmm(new Date(Date.now() - 60000)))}; form.requestSubmit(); })()`);
|
||||
await waitFor(async () => (await evaluate(`document.querySelector("[data-autopilot-status]").textContent`)).includes("decoder is not connected"), "waits for the decoder");
|
||||
assert.equal((await savedState()).sessions.find((session) => session.id === "ds_4wd_q1").status, "ready", "nothing started without a decoder");
|
||||
// With the autopilot on, a heat due within 10 minutes is called on its own.
|
||||
await waitFor(async () => Boolean((await savedState()).sessions.find((session) => session.id === "ds_4wd_q1").calledAt), "the autopilot calls the next heat");
|
||||
assert.equal(await evaluate(`Boolean(document.getElementById("dayCallBanner"))`), false, "no question to the race controller while the autopilot runs");
|
||||
await evaluate(`document.getElementById("dayPause").click()`);
|
||||
await waitFor(async () => Boolean(((await savedState()).raceDays || []).find((day) => day.date === today)?.pausedAt), "the day is paused");
|
||||
await waitFor(async () => (await evaluate(`document.querySelector("[data-autopilot-status]").textContent`)) === "The day is paused", "the autopilot says the day is paused");
|
||||
@@ -58,7 +61,20 @@ export async function runDayScheduleSmoke({ evaluate, navigate, savedState, wait
|
||||
await waitFor(async () => !((await savedState()).raceDays || []).find((day) => day.date === today)?.pausedAt, "the day is resumed");
|
||||
await evaluate(`document.getElementById("dayAutopilotOff").click()`);
|
||||
await waitFor(async () => ((await savedState()).raceDays || []).find((day) => day.date === today)?.autopilot === false, "autopilot off");
|
||||
console.log("PASS the autopilot says what comes next, waits for the decoder, and the day can be paused and resumed");
|
||||
console.log("PASS the autopilot says what comes next, calls the heat, waits for the decoder, and the day can be paused and resumed");
|
||||
|
||||
// By hand: Race Day asks the race controller to call the next heat (here 20 min before).
|
||||
await evaluate(`(() => { const form = document.getElementById("dayPlanForm"); form.elements.callMin.value = "20"; form.requestSubmit(); })()`);
|
||||
// The autopilot may already have called the 2WD Q1 H1; the banner asks for each heat not yet called, in order.
|
||||
for (let round = 0; round < 3; round += 1) {
|
||||
await waitFor(async () => Boolean(await evaluate(`document.getElementById("dayCallBanner")?.dataset.dayCall`)), "Race Day asks to call the next heat not yet called");
|
||||
const asked = await evaluate(`document.getElementById("dayCallBanner").dataset.dayCall`);
|
||||
await evaluate(`document.getElementById("dayCallNow").click()`);
|
||||
await waitFor(async () => Boolean((await savedState()).sessions.find((session) => session.id === asked).calledAt), "Call now marks it called");
|
||||
if (asked === "ds_2wd_q2") break;
|
||||
}
|
||||
await waitFor(async () => !(await evaluate(`Boolean(document.getElementById("dayCallBanner"))`)), "and the question goes away once every heat is called");
|
||||
console.log("PASS heats started by hand: Race Day asks the race controller to call the next heat");
|
||||
|
||||
const printHtml = await evaluate(`(async () => {
|
||||
const { buildDaySchedulePrintHtml } = await import("/src/day_schedule_view.js");
|
||||
@@ -70,9 +86,10 @@ export async function runDayScheduleSmoke({ evaluate, navigate, savedState, wait
|
||||
await send("Page.navigate", { url: base + "/public-overlay/schedule" });
|
||||
await waitFor(async () => (await evaluate(`document.querySelectorAll(".board-next").length`)) === 3, "the board shows the next three heats");
|
||||
const board = await evaluate(`document.querySelector(".driver-board").innerText`);
|
||||
assert.ok(board.includes("Get ready"), "a heat due within 10 minutes gets a heads-up");
|
||||
assert.ok(board.includes("Called – get ready"), "a called heat is highlighted for the drivers");
|
||||
assert.equal(await evaluate(`document.querySelector(".board-next").classList.contains("is-called")`), true);
|
||||
assert.equal(await evaluate(`document.querySelector(".board-next").dataset.boardSession`), "ds_4wd_q1", "in the day's order");
|
||||
console.log("PASS the drivers' board shows the next heats with their drivers and a heads-up");
|
||||
console.log("PASS the drivers' board shows the next heats with their drivers, called heats highlighted");
|
||||
} finally {
|
||||
const current = await savedState();
|
||||
await patchState({
|
||||
|
||||
@@ -68,3 +68,17 @@ test("race days are stored one per date, and the board shows today or the next d
|
||||
assert.equal(pickBoardDate({ events, sessions, today: "2026-11-01" }), "2026-11-08");
|
||||
assert.equal(pickBoardDate({ events, sessions, today: "2026-12-01" }), "2026-12-01");
|
||||
});
|
||||
|
||||
test("a heat is due for its call within callMin, once, and not while put off or the day is paused", async () => {
|
||||
const { getDueCall } = await import("../src/day_schedule_logic.js");
|
||||
const start = Date.UTC(2026, 10, 8, 10, 0);
|
||||
const rows = buildDaySchedule([s("one", "e2", "qualification", "Q1 H1"), s("two", "e2", "qualification", "Q1 H2")], { startAt: start, gapMin: 3 }, start - 3600000);
|
||||
const day = { callMin: 10 };
|
||||
assert.equal(getDueCall(rows, { day, now: start - 11 * 60000 }), null);
|
||||
assert.equal(getDueCall(rows, { day, now: start - 10 * 60000 }).session.id, "one");
|
||||
const called = rows.map((row, i) => (i === 0 ? { ...row, session: { ...row.session, calledAt: start - 600000 } } : row));
|
||||
assert.equal(getDueCall(called, { day, now: start - 5 * 60000 }), null, "the next heat is not due yet");
|
||||
assert.equal(getDueCall(called, { day, now: start }).session.id, "two");
|
||||
assert.equal(getDueCall(rows, { day, now: start - 5 * 60000, snoozedUntil: () => start - 3 * 60000 }), null, "put off");
|
||||
assert.equal(getDueCall(rows, { day: { ...day, pausedAt: 1 }, now: start }), null);
|
||||
});
|
||||
Reference in new issue
Block a user