feat(ux): run sessions from Race Day with quick actions
Race Day gets Start practice, New track layout and Create race, a session picker, only the buttons that apply, and New practice day (replaces Reset data on Timing; laps stay in the training stats). Timing is for following and links to Race Day. The Dashboard shows the three common tasks first. Guide, READMEs, screenshot and the "Run a session" video follow the flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3a6789f42f
commit
c4df90706a
23 files changed
+344
-111
No files matched your search
@@ -0,0 +1,64 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
// The easy path for a club evening: the Dashboard's "Start practice" creates and starts an
|
||||
// Open Practice on Race Day; Race Day's quick actions add a track layout (the running practice
|
||||
// moves onto it) and switch sessions; Timing no longer has the run controls, only a link.
|
||||
export async function runRaceDayQuickSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs }) {
|
||||
// The layout prompts are expected here; drop them afterwards so later "no unexpected dialog" checks stay meaningful.
|
||||
const dialogsAtStart = dialogs.length;
|
||||
const patchState = async (patch) => {
|
||||
const current = await savedState();
|
||||
Object.assign(current, patch);
|
||||
const response = await fetch(base + "/api/state", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(current) });
|
||||
assert.equal(response.ok, true);
|
||||
};
|
||||
const seeded = await savedState();
|
||||
// No Open Practice to continue, and nothing running: "Start practice" must create one.
|
||||
await patchState({
|
||||
sessions: seeded.sessions.map((session) => (session.type === "open_practice" || ["running", "paused"].includes(session.status) ? { ...session, status: "finished", endedAt: Date.now() } : session)),
|
||||
events: [...seeded.events, { id: "rq_event", name: "RQ Race", mode: "race", raceConfig: {} }],
|
||||
activeSessionId: "",
|
||||
trackLayouts: [],
|
||||
});
|
||||
const before = new Set((await savedState()).sessions.map((session) => session.id));
|
||||
let created = null;
|
||||
try {
|
||||
await navigate("dashboard", "dashboardQuickPractice");
|
||||
await evaluate(`document.getElementById("dashboardQuickPractice").click()`);
|
||||
await waitFor(async () => (await savedState()).sessions.some((session) => !before.has(session.id) && session.type === "open_practice" && session.status === "running"), "a new Open Practice is created and running");
|
||||
created = (await savedState()).sessions.find((session) => !before.has(session.id) && session.type === "open_practice");
|
||||
await waitFor(async () => (await savedState()).activeSessionId === created.id, "and selected");
|
||||
await waitFor(async () => (await evaluate(`location.search`)).includes("race_day") && Boolean(await evaluate(`document.getElementById("raceDayQuickPractice")`)), "on Race Day");
|
||||
await waitFor(async () => (await evaluate(`document.getElementById("raceDayQuickPractice").textContent`)).includes(created.name), "the quick button shows the running practice");
|
||||
assert.equal(await evaluate(`Boolean(document.getElementById("raceDayNewPracticeDay"))`), true, "New practice day is on Race Day for a practice");
|
||||
console.log("PASS Start practice on the Dashboard creates, starts and opens an Open Practice on Race Day");
|
||||
|
||||
await evaluate(`document.querySelector('.race-day-quick [data-track-layout-new]').click()`);
|
||||
await waitFor(async () => ((await savedState()).trackLayouts || []).length === 1, "a layout is created from the quick actions");
|
||||
const layoutId = (await savedState()).trackLayouts[0].id;
|
||||
await waitFor(async () => (await savedState()).sessions.find((session) => session.id === created.id)?.trackLayoutId === layoutId, "the running practice moved onto it");
|
||||
console.log("PASS New track layout from Race Day's quick actions moves the running practice onto it");
|
||||
|
||||
await patchState({ sessions: [...(await savedState()).sessions, { id: "rq_heat", eventId: "rq_event", name: "RQ Heat 1", type: "heat", status: "ready", durationMin: 5 }] });
|
||||
await navigate("race_day", "raceDaySessionSelect");
|
||||
await evaluate(`(() => { const select = document.getElementById("raceDaySessionSelect"); select.value = "rq_heat"; select.dispatchEvent(new Event("change")); })()`);
|
||||
await waitFor(async () => (await savedState()).activeSessionId === "rq_heat", "the session picker switches session");
|
||||
assert.equal(await evaluate(`Boolean(document.getElementById("raceDayNewPracticeDay"))`), false, "no New practice day for a heat");
|
||||
console.log("PASS Race Day's session picker switches the selected session");
|
||||
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
assert.equal(await evaluate(`Boolean(document.getElementById("startSession") || document.getElementById("resetSession") || document.getElementById("stopSession"))`), false, "no run controls on Timing");
|
||||
await evaluate(`document.getElementById("timingOpenRaceDay").click()`);
|
||||
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayQuickPractice")`)), "the link opens Race Day");
|
||||
console.log("PASS Timing is for following: run controls moved to Race Day, with a link there");
|
||||
} finally {
|
||||
dialogs.splice(dialogsAtStart);
|
||||
const current = await savedState();
|
||||
await patchState({
|
||||
sessions: current.sessions.filter((session) => session.id !== "rq_heat").map((session) => (created && session.id === created.id ? { ...session, status: "finished", endedAt: Date.now() } : session)),
|
||||
events: current.events.filter((event) => event.id !== "rq_event"),
|
||||
trackLayouts: [],
|
||||
activeSessionId: "",
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user