feat(race): autopilot waits for qualifying from practice; qualifying start time per class (1.89.51)

This commit is contained in:
larssand committed 2026-11-16 23:01:49 +01:00
1 parent 57e081e291
commit fbc4246a60
12 files changed
+114 -10

No files matched your search

+10
View File
@@ -109,6 +109,16 @@ export async function runRaceSetupSmoke({ evaluate, navigate, fill, savedState,
const practiceHeats = (await savedState()).sessions.filter((session) => session.eventId === club.id && session.type === "practice");
assert.ok(practiceHeats.every((session) => session.driverIds.length <= 2), `practice heats rebuilt with max 2 cars: ${practiceHeats.map((session) => session.name + ":" + session.driverIds.length)}`);
console.log("PASS format change rebuilds the practice and qualifying heats (cars per heat, rounds)");
// "Qualifying starts at": saved per class on the day plan, and cleared again.
await waitFor(async () => Boolean(await evaluate('Boolean(document.getElementById("qualStartForm"))')), "qualifying start form");
await fill("qualStartForm", { qualStart: "13:30" });
await submit("qualStartForm");
const expectedAt = new Date("2026-09-08T13:30:00").getTime();
await waitFor(async () => ((await savedState()).raceDays || []).some((day) => day.date === "2026-09-08" && day.qualStartAt?.[club.id] === expectedAt), "qualifying start saved");
await waitFor(async () => Boolean(await evaluate('Boolean(document.getElementById("qualStartClear"))')), "clear button");
await click("qualStartClear");
await waitFor(async () => !((await savedState()).raceDays || []).some((day) => day.date === "2026-09-08" && day.qualStartAt?.[club.id]), "qualifying start cleared");
console.log("PASS qualifying start time is saved per class and cleared");
}
await navigate("race_setup", "raceWizardStepForm");
await editEvent(race, "race_setup", "raceWizardStepForm");
+21
View File
@@ -222,3 +222,24 @@ test("marshals: the drivers of the heat before (or after), never someone driving
assert.deepEqual(names(assignMarshals(rows, "off", of)), ["", "", ""]);
assert.equal(normalizeRaceDays([{ date: "2026-11-08", marshalRule: "bogus" }])[0].marshalRule, "off");
});
test("a class's qualifying start time holds its qualifiers until then; practice and other days are not moved", () => {
const now = new Date("2026-11-08T10:00:00").getTime();
const qualAt = new Date("2026-11-08T11:30:00").getTime();
const day = { date: "2026-11-08", gapMin: 2, qualStartAt: { e2: qualAt } };
const daySessions = [s("p", "e2", "practice", "practice 1"), s("q1", "e2", "qualification", "Q1 H1"), s("q2", "e2", "qualification", "Q1 H2")];
const rows = buildDaySchedule(daySessions, day, now);
assert.equal(rows[0].start, now, "practice now");
assert.equal(rows[1].start, qualAt, "first qualifier at the chosen time");
assert.equal(rows[2].start, qualAt + 5 * 60000 + 2 * 60000, "the next one after it as usual");
assert.equal(normalizeRaceDays([day])[0].qualStartAt.e2, qualAt);
});
test("autopilot waits for 'Generate qualifying from practice' when the next heat is a preliminary qualifier", () => {
const rows = [{ state: "done", session: s("p", "e2", "practice", "practice 1") }, { state: "upcoming", start: 0, session: s("q1", "e2", "qualification", "Q1 H1") }];
const waiting = getAutopilotAction(rows, { day: {}, now: 10, seedPending: { e2: "2WD" } });
assert.equal(waiting.type, "wait");
assert.equal(waiting.reason, "seed");
assert.deepEqual(waiting.classes, ["2WD"]);
assert.equal(getAutopilotAction(rows, { day: {}, now: 10, seedPending: {} }).type, "start", "built from practice: starts as before");
});