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
@@ -30,7 +30,7 @@ export async function runCorrectionsScopeSmoke({ evaluate, navigate, savedState,
|
||||
|
||||
try {
|
||||
// Race: Timing details are read-only and point to Judging.
|
||||
await navigate("timing", "resetSession");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await evaluate(`document.getElementById("leaderboard-detail-driver_cs_driver").click()`);
|
||||
await waitFor(async () => exists("#corrOpenJudging"), "Open in Judging in a race");
|
||||
assert.equal(await exists("#corrLapPlus"), false, "no penalty buttons on Timing");
|
||||
@@ -43,7 +43,7 @@ export async function runCorrectionsScopeSmoke({ evaluate, navigate, savedState,
|
||||
|
||||
// Practice: no penalties anywhere, lap clean-up on Timing.
|
||||
await patchState({ sessions: (await savedState()).sessions.map((session) => (session.id === heat.id ? { ...session, status: "finished", endedAt: Date.now() } : session.id === practice.id ? { ...session, status: "running", startedAt } : session)), activeSessionId: practice.id });
|
||||
await navigate("timing", "resetSession");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await evaluate(`document.getElementById("leaderboard-detail-driver_cs_driver").click()`);
|
||||
await waitFor(async () => exists('#leaderboardModalOverlay [data-lap-action="remove"]'), "Remove per lap in practice");
|
||||
assert.equal(await exists("#corrOpenJudging"), false, "no corrections block in practice");
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function runLiveSessionSmoke({ evaluate, navigate, savedState, wait
|
||||
settings: { ...seeded.settings, autoReconnect: true, wsUrl: `ws://127.0.0.1:${decoder.port}` },
|
||||
});
|
||||
try {
|
||||
await navigate("timing", "resetSession");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await waitFor(async () => evaluate('document.getElementById("connectionBadge")?.classList.contains("badge-online")'), "decoder connected");
|
||||
await waitFor(async () => (await evaluate(`document.getElementById("liveElsewhereBanner")?.textContent || ""`)).includes("LS Practice A"), "the page says laps go to the running practice");
|
||||
decoder.sendPassing("8880001", startedAt + 20000);
|
||||
|
||||
@@ -37,15 +37,16 @@ export async function runPracticeResetSmoke({ evaluate, navigate, savedState, wa
|
||||
});
|
||||
|
||||
try {
|
||||
await navigate("timing", "resetSession");
|
||||
// "New practice day" lives on Race Day (it used to be "Reset data" on Timing).
|
||||
await navigate("race_day", "raceDayNewPracticeDay");
|
||||
// The laps were seeded straight into the results and haven't been synced into the training
|
||||
// stats yet - Reset itself must sync them before clearing (the case of laps driven since
|
||||
// the last save).
|
||||
const before = dialogs.length;
|
||||
await evaluate(`document.getElementById("resetSession").click()`);
|
||||
await evaluate(`document.getElementById("raceDayNewPracticeDay").click()`);
|
||||
await waitFor(async () => dialogs.slice(before).some((dialog) => dialog.type === "confirm" && /training|tränings/i.test(dialog.message)), "confirm says the laps stay in the training stats");
|
||||
// The Timing view recreates an empty result for the active session straight away - which
|
||||
// is why the old code lost the laps already on the next save, not only on the next lap.
|
||||
// A view can recreate an empty result for the active session straight away - which is why
|
||||
// the old code lost the laps already on the next save, not only on the next lap.
|
||||
await waitFor(async () => ((await savedState()).resultsBySession?.[practice.id]?.passings || []).length === 0, "timing data cleared");
|
||||
assert.deepEqual((await driverLaps()).sort(), [19000, 19500, 20000], "laps kept right after the reset");
|
||||
assert.equal((await savedState()).sessions.find((session) => session.id === practice.id).status, "running", "the practice keeps running");
|
||||
|
||||
@@ -13,6 +13,8 @@ export async function runRaceDaySmoke({ evaluate, navigate, fill, savedState, wa
|
||||
assert.equal(response.ok, true);
|
||||
};
|
||||
const buttonDisabled = async id => await evaluate(`document.getElementById(${JSON.stringify(id)})?.disabled`);
|
||||
// Race Day renders only the buttons that apply right now (no greyed-out Pause before a start).
|
||||
const shown = async id => await evaluate(`Boolean(document.getElementById(${JSON.stringify(id)}))`);
|
||||
|
||||
const decoder = await startFakeDecoder();
|
||||
try {
|
||||
@@ -46,8 +48,8 @@ export async function runRaceDaySmoke({ evaluate, navigate, fill, savedState, wa
|
||||
|
||||
await navigate("race_day", "raceDayStart");
|
||||
await waitFor(async () => (await buttonDisabled("raceDayStart")) === false, "start enabled once preflight is ready");
|
||||
assert.equal(await buttonDisabled("raceDayPause"), true);
|
||||
assert.equal(await buttonDisabled("raceDayFinish"), true);
|
||||
assert.equal(await shown("raceDayPause"), false, "no Pause before a start");
|
||||
assert.equal(await shown("raceDayFinish"), false, "no Finish before a start");
|
||||
|
||||
await click("raceDayStart");
|
||||
await waitFor(async () => (await findSession("Race Day Heat 1")).status === "running", "heat 1 running");
|
||||
@@ -56,15 +58,15 @@ export async function runRaceDaySmoke({ evaluate, navigate, fill, savedState, wa
|
||||
// normalizeSession() in src/app.js stores "not paused" as 0, not null (Number(null) === 0
|
||||
// passes its Number.isFinite check) - every real usage treats pausedAt as falsy, so match that.
|
||||
assert.ok(!started.pausedAt, "not paused after start");
|
||||
await waitFor(async () => (await buttonDisabled("raceDayPause")) === false, "pause enabled after start");
|
||||
await waitFor(async () => (await buttonDisabled("raceDayPause")) === false, "pause shown after start");
|
||||
assert.equal(await buttonDisabled("raceDayFinish"), false);
|
||||
assert.equal(await buttonDisabled("raceDayResume"), true);
|
||||
assert.equal(await shown("raceDayResume"), false, "no Resume while running");
|
||||
|
||||
await click("raceDayPause");
|
||||
await waitFor(async () => (await findSession("Race Day Heat 1")).status === "paused", "heat 1 paused");
|
||||
assert.ok((await findSession("Race Day Heat 1")).pausedAt, "pausedAt recorded");
|
||||
await waitFor(async () => (await buttonDisabled("raceDayResume")) === false, "resume enabled after pause");
|
||||
assert.equal(await buttonDisabled("raceDayPause"), true);
|
||||
await waitFor(async () => (await buttonDisabled("raceDayResume")) === false, "resume shown after pause");
|
||||
assert.equal(await shown("raceDayPause"), false, "no Pause while paused");
|
||||
await pause(1200);
|
||||
|
||||
await click("raceDayResume");
|
||||
|
||||
@@ -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: "",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import { runSeriesSmoke } from "./browser_series.js";
|
||||
import { runTrainingSourceSmoke } from "./browser_training_source.js";
|
||||
import { runDecoderUrlSmoke } from "./browser_decoder_url.js";
|
||||
import { runLiveSessionSmoke } from "./browser_live_session.js";
|
||||
import { runRaceDayQuickSmoke } from "./browser_race_day_quick.js";
|
||||
import { runObsPopupSmoke } from "./browser_obs_popup.js";
|
||||
import { runDecoderReconnectSmoke } from "./browser_decoder_reconnect.js";
|
||||
import assert from "node:assert/strict";
|
||||
@@ -168,6 +169,7 @@ try {
|
||||
await runTrainingSourceSmoke({ evaluate, navigate, savedState, waitFor, base });
|
||||
await runDecoderUrlSmoke({ evaluate, navigate, savedState, waitFor, base });
|
||||
await runLiveSessionSmoke({ evaluate, navigate, savedState, waitFor, base });
|
||||
await runRaceDayQuickSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs });
|
||||
await runRaceDaySmoke({ evaluate, navigate, fill, savedState, waitFor, pause, base, dialogs });
|
||||
await runRaceDayStartSequencesSmoke({ evaluate, navigate, waitFor, pause, base, dialogs });
|
||||
await runObsPopupSmoke({ evaluate, navigate, fill, savedState, waitFor, pause, base, debugPort, dialogs, realClick });
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function runSuspectLapsSmoke({ evaluate, navigate, savedState, wait
|
||||
});
|
||||
|
||||
try {
|
||||
await navigate("timing", "resetSession");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await waitFor(async () => evaluate('document.getElementById("connectionBadge")?.classList.contains("badge-online")'), "decoder connected");
|
||||
decoder.sendPassing("8330001", lastTs + 14000);
|
||||
await waitFor(async () => (await results())?.passings?.length === 7, "the short lap arrived");
|
||||
@@ -58,11 +58,11 @@ export async function runSuspectLapsSmoke({ evaluate, navigate, savedState, wait
|
||||
assert.equal(await evaluate(`[...document.querySelectorAll(".suspect-flag")].length > 0`), true, "⚠ in the overlay");
|
||||
console.log("PASS the overlay marks the driver with a suspect lap");
|
||||
|
||||
await navigate("race_day", "raceDayStart");
|
||||
await navigate("race_day", "raceDaySessionSelect");
|
||||
await waitFor(async () => Boolean(await evaluate(`document.querySelector('#suspectLapsPanel [data-lap-action="approve"]')`)), "the same panel on Race Day");
|
||||
console.log("PASS Race Day shows the suspect lap with Approve / Remove");
|
||||
|
||||
await navigate("timing", "resetSession");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await waitFor(async () => Boolean(await evaluate(`document.querySelector('#suspectLapsPanel [data-lap-action="remove"]')`)), "Remove button");
|
||||
await evaluate(`document.querySelector('#suspectLapsPanel [data-lap-action="remove"]').click()`);
|
||||
await waitFor(async () => (await results())?.passings?.at(-1)?.validLap === false, "the short lap removed");
|
||||
|
||||
Reference in new issue
Block a user