fix(practice): stop flagging a driver's faster pace as suspect laps (1.42.5)
Flagged laps never entered the reference pace, so a driver who got faster had every lap flagged. They now count in the reference (last 10 laps), settled flags are released, and a flagged lap counts until it is removed; Approve only drops the flag.
This commit is contained in:
1 parent
35eb3eb059
commit
2c2b16537e
13 files changed
+132
-47
No files matched your search
@@ -46,12 +46,12 @@ export async function runSuspectLapsSmoke({ evaluate, navigate, savedState, wait
|
||||
const shortLap = (await results()).passings.at(-1);
|
||||
assert.equal(shortLap.lapMs, 14000);
|
||||
assert.equal(shortLap.suspect, true, "flagged as suspect");
|
||||
assert.equal((await results()).competitors.driver_sl_driver.bestLapMs, 19800, "not used as the best lap");
|
||||
assert.equal((await results()).competitors.driver_sl_driver.bestLapMs, 14000, "it counts like any lap until someone removes it");
|
||||
|
||||
await waitFor(async () => Boolean(await evaluate(`document.getElementById("suspectLapsPanel")`)), "suspect panel on Timing");
|
||||
assert.match(await evaluate(`document.getElementById("suspectLapsPanel").innerText`), /SL Kid/);
|
||||
assert.equal(await evaluate(`Boolean([...document.querySelectorAll(".table-primary")].find((node) => node.textContent.includes("SL Kid"))?.querySelector(".suspect-flag"))`), true, "⚠ in the leaderboard");
|
||||
console.log("PASS a lap far quicker than the driver's own pace is flagged on Timing and not used as the best lap");
|
||||
console.log("PASS a lap far quicker than the driver's own pace is flagged on Timing but counts until removed");
|
||||
|
||||
await navigate("overlay", "view");
|
||||
await waitFor(async () => evaluate(`document.body.innerText.includes("SL Kid")`), "overlay shows the driver");
|
||||
@@ -69,9 +69,27 @@ export async function runSuspectLapsSmoke({ evaluate, navigate, savedState, wait
|
||||
const after = await results();
|
||||
assert.equal(after.passings.at(-1).invalidReason, "manual_invalid");
|
||||
assert.equal(after.competitors.driver_sl_driver.laps, 6, "no longer counted");
|
||||
assert.equal(after.competitors.driver_sl_driver.bestLapMs, 19800, "and no longer the best lap");
|
||||
assert.ok(after.adjustments?.some((adjustment) => adjustment.category === "invalid"), "logged as a judge correction (undoable)");
|
||||
await waitFor(async () => !(await evaluate(`Boolean(document.getElementById("suspectLapsPanel"))`)), "panel gone once nothing is pending");
|
||||
console.log("PASS one click removes the suspect lap and it is logged as an undoable correction");
|
||||
|
||||
// Flags from the old rule (flagged laps never entered the reference): a driver who simply
|
||||
// got faster had every lap at the new pace flagged. Opening Timing releases those.
|
||||
const pace = [23000, 23400, 22900, 23100, 23300, 19000, 19200, 18900, 19100, 18800, 19300, 19000];
|
||||
let paceTs = Date.now() - 400000;
|
||||
const pacePassings = pace.map((lapMs, index) => { paceTs += lapMs; return { driverId: "sl_fast", driverName: "SL Fast", displayName: "SL Fast", competitorKey: "driver_sl_fast", transponder: "8330002", lapMs, timestamp: paceTs, validLap: true, suspect: index >= 5 }; });
|
||||
const current = await results();
|
||||
// The session is live: write its results the way a correction does (a full-state save
|
||||
// can't overwrite live results), then reload so the page hydrates them.
|
||||
const sessionResult = { ...current, passings: [...current.passings, ...pacePassings], competitors: { ...current.competitors, driver_sl_fast: { key: "driver_sl_fast", driverId: "sl_fast", driverName: "SL Fast", displayName: "SL Fast", transponder: "8330002", laps: pace.length, lastLapMs: 19000, bestLapMs: 22900, startTimestamp: startedAt, lastTimestamp: paceTs } } };
|
||||
const stored = await fetch(base + "/api/session-results", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ sessionId: practice.id, sessionResult }) });
|
||||
assert.equal(stored.ok, true);
|
||||
assert.equal((await results()).passings.filter((passing) => passing.competitorKey === "driver_sl_fast" && passing.suspect).length, 7, "seven laps flagged under the old rule");
|
||||
await navigate("timing", "activeSessionSelect");
|
||||
await waitFor(async () => { const fast = (await results()).passings.filter((passing) => passing.competitorKey === "driver_sl_fast"); return fast.length === pace.length && !fast.some((passing) => passing.suspect); }, "the old flags at the driver's real pace are released");
|
||||
assert.equal((await results()).competitors.driver_sl_fast.bestLapMs, 18800, "and the best lap is recalculated");
|
||||
console.log("PASS laps flagged under the old rule at a driver's real (faster) pace are released");
|
||||
} finally {
|
||||
dialogs.splice(dialogsAtStart);
|
||||
const current = await savedState();
|
||||
|
||||
Reference in new issue
Block a user