feat(day): one start time - Race setup's start time and gap are Race Day's, with Race Day's times shown (1.89.17)
This commit is contained in:
1 parent
cb29c5471b
commit
f8080ffaeb
11 files changed
+122
-17
No files matched your search
@@ -36,9 +36,9 @@ export async function runEventScheduleSmoke({ evaluate, navigate, fill, savedSta
|
||||
sessions: [...seeded.sessions, qualifyingSession, practiceSession],
|
||||
});
|
||||
|
||||
const openSchedule = async () => {
|
||||
const openSchedule = async (eventId = raceEvent.id) => {
|
||||
await navigate("race_setup", "raceWizardStepForm");
|
||||
await click("event-manage-" + raceEvent.id);
|
||||
await click("event-manage-" + eventId);
|
||||
await waitFor(async () => await evaluate(`Boolean(document.querySelector(".manage-tabs"))`), "manage tabs rendered");
|
||||
await evaluate(`document.querySelector('[data-manage-tab="schedule"]').click()`);
|
||||
await waitFor(async () => await evaluate(`Boolean(document.getElementById("scheduleForm"))`), "schedule panel visible");
|
||||
@@ -84,4 +84,28 @@ export async function runEventScheduleSmoke({ evaluate, navigate, fill, savedSta
|
||||
await openSchedule();
|
||||
assert.equal(await evaluate(`Boolean(document.querySelector('[data-manage-panel="schedule"] table'))`), false, "with no start time set, the schedule table is replaced by the not-set hint");
|
||||
console.log("PASS clearing the schedule removes the start time but keeps the configured gap");
|
||||
|
||||
// A race with a date (every race made in the app has one): the start time and gap are Race
|
||||
// Day's for that date - one setting - and the table shows Race Day's times.
|
||||
const dated = { ...raceEvent, id: "esc_event_dated", name: "ESC Dated", date: "2027-03-12" };
|
||||
await patchState({
|
||||
events: [...(await savedState()).events, dated],
|
||||
sessions: [...(await savedState()).sessions,
|
||||
{ id: "esc_dated_p", eventId: dated.id, name: "Dated Practice", type: "practice", durationMin: 5, status: "ready" },
|
||||
{ id: "esc_dated_q", eventId: dated.id, name: "Dated Qualification", type: "qualification", durationMin: 5, status: "ready" }],
|
||||
});
|
||||
await openSchedule(dated.id);
|
||||
await fill("scheduleForm", { scheduleStartTime: "10:00", scheduleGapMin: "4" });
|
||||
await submit("scheduleForm");
|
||||
const dayStart = new Date("2027-03-12T10:00").getTime();
|
||||
await waitFor(async () => (await savedState()).raceDays?.find((day) => day.date === dated.date)?.startAt === dayStart, "Race setup saves Race Day's first start");
|
||||
assert.equal((await savedState()).raceDays.find((day) => day.date === dated.date).gapMin, 4, "and its break between heats");
|
||||
await openSchedule(dated.id);
|
||||
const planned = await evaluate(`Array.from(document.querySelectorAll('[data-manage-panel="schedule"] table tbody tr td:nth-child(3)')).map((td) => td.textContent.trim())`);
|
||||
assert.deepEqual(planned.map((text) => text.slice(0, 5)), ["10:00", "10:09"], "Race Day's times: 5 min heat + 4 min break");
|
||||
// Changed in Race Day -> Race setup shows it.
|
||||
await patchState({ raceDays: (await savedState()).raceDays.map((day) => (day.date === dated.date ? { ...day, startAt: new Date("2027-03-12T11:00").getTime() } : day)) });
|
||||
await openSchedule(dated.id);
|
||||
assert.equal(await evaluate(`document.querySelector('#scheduleForm [name="scheduleStartTime"]').value`), "11:00", "a first start changed in Race Day shows in Race setup");
|
||||
console.log("PASS Race setup's start time and gap are Race Day's first start and break, and its table shows Race Day's times");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { orderDaySessions, buildDaySchedule, getAutopilotAction, normalizeRaceDays, moveInDayOrder, pickBoardDate, fixedBreakWindow } from "../src/day_schedule_logic.js";
|
||||
import { orderDaySessions, buildDaySchedule, getAutopilotAction, normalizeRaceDays, moveInDayOrder, pickBoardDate, fixedBreakWindow, withRaceSetupStart, eventScheduleFromDayRows } from "../src/day_schedule_logic.js";
|
||||
|
||||
const events = [
|
||||
{ id: "e4", name: "Cup #1 4WD", date: "2026-11-08", mode: "race" },
|
||||
@@ -170,3 +170,26 @@ test("a heat already run between pending ones doesn't pull the rest of the day b
|
||||
const rows = buildDaySchedule(sessions, { startAt: T("23:40"), gapMin: 3 }, T("23:39")).filter((row) => row.state === "upcoming");
|
||||
assert.deepEqual(rows.map((row) => row.start), [T("23:40"), T("23:48"), T("23:56")], "one after the other from the first start, not all at 23:39");
|
||||
});
|
||||
|
||||
test("one start time: Race Day's first start; a Race setup start time from before fills in a day without one", () => {
|
||||
const at = new Date("2026-11-14T09:30:00").getTime();
|
||||
const events = [{ id: "e", date: "2026-11-14", raceConfig: { scheduleStartAt: at } }];
|
||||
assert.equal(withRaceSetupStart({ date: "2026-11-14", startAt: null }, events).startAt, at);
|
||||
const own = new Date("2026-11-14T10:00:00").getTime();
|
||||
assert.equal(withRaceSetupStart({ date: "2026-11-14", startAt: own }, events).startAt, own, "Race Day's own time wins");
|
||||
assert.equal(withRaceSetupStart({ date: "2026-11-15", startAt: null }, events).startAt, null, "another day is not touched");
|
||||
});
|
||||
|
||||
test("Race setup shows its race's heats with Race Day's times (lunch and other classes included)", () => {
|
||||
const T = (h) => new Date(`2026-11-14T${h}:00`).getTime();
|
||||
const sessions = [
|
||||
{ id: "a1", eventId: "a", type: "qualification", name: "Q1 H1", status: "ready", durationMin: 5 },
|
||||
{ id: "b1", eventId: "b", type: "qualification", name: "Q1 H1", status: "ready", durationMin: 5 },
|
||||
{ id: "a2", eventId: "a", type: "qualification", name: "Q2 H1", status: "ready", durationMin: 5 },
|
||||
];
|
||||
const rows = buildDaySchedule(sessions, { date: "2026-11-14", startAt: T("11:50"), gapMin: 2, breakFrom: "12:00", breakTo: "13:00" }, T("08:00"));
|
||||
const own = eventScheduleFromDayRows(rows, "a");
|
||||
assert.deepEqual(own.map((row) => row.sessionId), ["a1", "a2"]);
|
||||
assert.equal(own[0].plannedStart, T("11:50"));
|
||||
assert.equal(own[1].plannedStart, T("13:07"), "the other class would run into lunch, goes 13:00-13:05, then a2 after the gap");
|
||||
});
|
||||
Reference in new issue
Block a user