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>
49 lines
3.3 KiB
JavaScript
49 lines
3.3 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { startFakeDecoder } from "./browser_fake_decoder.js";
|
|
|
|
// The user's case: an Open Practice is running, another session gets selected (another
|
|
// practice, or the next heat on Race Day). Passings used to be dropped as "no running
|
|
// session"; they must keep going to the running one, and the page must say so.
|
|
export async function runLiveSessionSmoke({ evaluate, navigate, savedState, waitFor, base }) {
|
|
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 decoder = await startFakeDecoder();
|
|
const seeded = await savedState();
|
|
const startedAt = Date.now() - 60000;
|
|
const running = { id: "ls_running", eventId: "ls_event", name: "LS Practice A", type: "open_practice", status: "running", startedAt, durationMin: 600 };
|
|
const selected = { id: "ls_selected", eventId: "ls_event", name: "LS Practice B", type: "open_practice", status: "ready", durationMin: 600 };
|
|
await patchState({
|
|
events: [...seeded.events, { id: "ls_event", name: "LS Club", mode: "race", raceConfig: { practiceOnly: true } }],
|
|
drivers: [...seeded.drivers, { id: "ls_driver", name: "LS Driver", transponder: "8880001" }],
|
|
sessions: [...seeded.sessions.map((session) => (["running", "paused"].includes(session.status) ? { ...session, status: "finished", endedAt: Date.now() } : session)), running, selected],
|
|
activeSessionId: selected.id,
|
|
settings: { ...seeded.settings, autoReconnect: true, wsUrl: `ws://127.0.0.1:${decoder.port}` },
|
|
});
|
|
try {
|
|
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);
|
|
await waitFor(async () => ((await savedState()).resultsBySession?.ls_running?.passings || []).length === 1, "the passing is counted on the running practice, not dropped");
|
|
assert.equal(((await savedState()).resultsBySession?.ls_selected?.passings || []).length, 0, "nothing on the selected, not-started one");
|
|
await evaluate(`document.querySelector("[data-show-live]").click()`);
|
|
await waitFor(async () => (await savedState()).activeSessionId === running.id, "Show it selects the running session");
|
|
await waitFor(async () => !(await evaluate(`Boolean(document.getElementById("liveElsewhereBanner"))`)), "notice gone once it is selected");
|
|
console.log("PASS passings keep going to the running session when another one is selected, and the page says so");
|
|
} finally {
|
|
const current = await savedState();
|
|
await patchState({
|
|
settings: { ...current.settings, autoReconnect: false },
|
|
sessions: current.sessions.filter((session) => !session.id.startsWith("ls_")),
|
|
events: current.events.filter((event) => event.id !== "ls_event"),
|
|
drivers: current.drivers.filter((driver) => driver.id !== "ls_driver"),
|
|
activeSessionId: "",
|
|
});
|
|
await decoder.close();
|
|
}
|
|
}
|