feat(training): Standard / Pro switch on the driver's page; purple day-best lap and stint consistency (1.87.0)
This commit is contained in:
1 parent
73e1c0ccf3
commit
0caf50254a
13 files changed
+204
-28
No files matched your search
@@ -39,4 +39,23 @@ export async function runProfileClassSmoke({ evaluate, savedState, waitFor, base
|
||||
assert.match(await evaluate(`location.search`), /class=pc_4wd/);
|
||||
assert.equal(await evaluate(`Boolean(document.querySelector("[data-switch-class]"))`), false);
|
||||
console.log("PASS on another class, the profile says the latest laps are in the 4WD and switches in one tap");
|
||||
|
||||
// Pro: a clean practice view with today's numbers and the stint cards only,
|
||||
// remembered on the phone and kept in the link.
|
||||
const visible = (selector) => evaluate(`(() => { const el = document.querySelector(${JSON.stringify(selector)}); return Boolean(el && el.offsetParent); })()`);
|
||||
assert.equal(await visible(".profile-pro"), false, "Standard by default");
|
||||
await evaluate(`document.querySelector('[data-profile-mode="pro"]').click()`);
|
||||
await waitFor(() => visible(".profile-pro"), "Pro view shown");
|
||||
assert.match(await evaluate(`location.search`), /mode=pro/);
|
||||
assert.equal(await visible(".profile-performance"), false, "stint statistics, goals and exercises are hidden");
|
||||
assert.equal(await visible(".profile-motivation-grid"), false);
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".profile-pro .stint-laps-card").length`), 1, "today's stint");
|
||||
await evaluate(`document.querySelector(".profile-pro .stint-laps-card > summary").click()`);
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".profile-pro .stint-lap").length`), 2, "both laps listed");
|
||||
await send("Page.navigate", { url: `${base}/public-training/${token}?lang=en` });
|
||||
await waitFor(() => visible(".profile-pro"), "the phone remembers Pro");
|
||||
await evaluate(`document.querySelector('[data-profile-mode="standard"]').click()`);
|
||||
await waitFor(async () => !(await visible(".profile-pro")) && (await visible(".profile-motivation-grid")), "back to Standard");
|
||||
assert.doesNotMatch(await evaluate(`location.search`), /mode=/);
|
||||
console.log("PASS the mobile profile has a Standard / Pro switch: Pro shows only today's numbers and the fold-out stints, and is remembered");
|
||||
}
|
||||
@@ -42,12 +42,12 @@ export async function runTrainingSourceSmoke({ evaluate, navigate, savedState, w
|
||||
assert.equal(await evaluate(`document.getElementById("training-source").value`), "practice", "practice is the default");
|
||||
assert.equal(await evaluate(`Boolean(document.querySelector('[data-sort-id="training-stints-featured"]'))`), true, "stints for practice");
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".training-race-origin").length`), 0, "no race laps mixed into practice");
|
||||
// The stint card folds out to every lap, with the best lap starred.
|
||||
// The stint card folds out to every lap; the day's fastest is purple.
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".stint-laps-card").length`), 1, "one practice stint card");
|
||||
await evaluate(`document.querySelector(".stint-laps-card > summary").click()`);
|
||||
assert.equal(await evaluate(`document.querySelector(".stint-laps-card").open`), true, "the card opens");
|
||||
assert.deepEqual(await evaluate(`[...document.querySelectorAll(".stint-laps-card .stint-lap-time")].map((cell) => cell.textContent.trim())`), ["0:20.000", "0:20.000", "0:19.500", "0:19.500"]);
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".stint-laps-card .stint-lap.is-best").length`), 2, "both 19.500 laps are best");
|
||||
assert.equal(await evaluate(`document.querySelectorAll(".stint-laps-card .stint-lap.is-day-best").length`), 2, "both 19.500 laps are the day's fastest (purple)");
|
||||
console.log("PASS training stats: a practice stint folds out to every lap time");
|
||||
|
||||
await evaluate(`(() => { const select = document.getElementById("training-source"); select.value = "race"; select.dispatchEvent(new Event("change")); })()`);
|
||||
|
||||
@@ -34,3 +34,17 @@ test("buildTrainingStintAnalysis rows carry their laps for the fold-out list", (
|
||||
assert.deepEqual(rows[0].laps.map((lap) => lap.lapMs), [10_000, 13_000, 13_500]);
|
||||
assert.equal(rows[0].averageLapMs, 12_167);
|
||||
});
|
||||
|
||||
test("the day's fastest lap is purple, over every stint that day", () => {
|
||||
const day = new Date(2026, 10, 9, 18).getTime();
|
||||
const stints = [
|
||||
{ id: "a", number: 1, startedAt: day, lapCount: 2, bestLapMs: 13300, laps: [{ lapMs: 13500 }, { lapMs: 13300 }] },
|
||||
{ id: "b", number: 2, startedAt: day + 3600000, lapCount: 2, bestLapMs: 13100, laps: [{ lapMs: 13100 }, { lapMs: 13400 }] },
|
||||
];
|
||||
const html = renderStintLapCards(stints.slice(0, 1), { formatLap: fmt, formatDuration: fmt, escapeHtml, labels, allStints: stints });
|
||||
assert.doesNotMatch(html, /is-day-best/, "the shown stint's best is not the day's best");
|
||||
assert.match(html, /class="stint-lap is-best"/);
|
||||
const both = renderStintLapCards(stints, { formatLap: fmt, formatDuration: fmt, escapeHtml, labels });
|
||||
assert.equal((both.match(/class="stint-lap is-day-best"/g) || []).length, 1);
|
||||
assert.equal(buildStintLapRows([{ lapMs: 13100 }], { dayBestMs: 13100 })[0].dayBest, true);
|
||||
});
|
||||
Reference in new issue
Block a user