Explains creating a series, running each round from the series page, points and standings, and a worked winter-series example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
4.0 KiB
JavaScript
61 lines
4.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
|
|
// Regression coverage for splitting the Guide page into tabs (previously ~20 stacked
|
|
// panels on one very long page - "Getting started", "Create a race", "Run a race",
|
|
// "Training & results", "Video guides"). Tabs must show exactly one group of panels at a
|
|
// time, default to "Getting started" on first load, and - the actual bug class this
|
|
// guards against - keep the selection when the page re-renders in place (a language
|
|
// switch calls renderView() without navigating away), not silently reset. activeGuideTab
|
|
// is a module-level variable specifically so it survives that re-render.
|
|
export async function runGuideTabsSmoke({ evaluate, navigate }) {
|
|
await navigate("guide", "guideOverview");
|
|
|
|
const activeTab = () => evaluate(`document.querySelector(".guide-tab.active")?.dataset.guideTab`);
|
|
const panelVisibility = () => evaluate(`
|
|
Object.fromEntries(Array.from(document.querySelectorAll("[data-guide-panel]"))
|
|
.map((panel) => [panel.dataset.guidePanel, !panel.hidden]))
|
|
`);
|
|
|
|
assert.equal(await activeTab(), "start", "Getting started is the default tab on first load");
|
|
let visible = await panelVisibility();
|
|
assert.equal(visible.start, true, "start panel visible by default");
|
|
assert.equal(visible.create, false, "create panel hidden by default");
|
|
assert.equal(visible.run, false, "run panel hidden by default");
|
|
assert.equal(visible.series, false, "series panel hidden by default");
|
|
assert.equal(visible.training, false, "training panel hidden by default");
|
|
assert.equal(visible.videos, false, "videos panel hidden by default");
|
|
console.log("PASS guide defaults to the Getting started tab with only that panel visible");
|
|
|
|
for (const tab of ["create", "run", "series", "training", "videos", "start"]) {
|
|
await evaluate(`document.querySelector('[data-guide-tab="${tab}"]').click()`);
|
|
assert.equal(await activeTab(), tab, `clicking the ${tab} tab activates it`);
|
|
visible = await panelVisibility();
|
|
for (const [panelId, isVisible] of Object.entries(visible)) {
|
|
assert.equal(isVisible, panelId === tab, `after switching to ${tab}, panel ${panelId} should be ${panelId === tab ? "visible" : "hidden"}`);
|
|
}
|
|
}
|
|
console.log("PASS clicking each guide tab shows only its own panel and hides the rest");
|
|
|
|
// The series tab explains the whole series workflow, step by step.
|
|
await evaluate(`document.querySelector('[data-guide-tab="series"]').click()`);
|
|
const seriesText = await evaluate(`document.querySelector('[data-guide-panel="series"]').innerText`);
|
|
assert.equal(await evaluate(`document.querySelectorAll('[data-guide-panel="series"] .guide-list li').length`), 21, "four sections, 21 steps");
|
|
assert.ok(!/guide\.series_/.test(seriesText), "every guide text is translated");
|
|
assert.equal(await evaluate(`[...document.querySelectorAll("#guideOverview .guide-overview-card strong")].some((node) => /Serie|Series/.test(node.textContent))`), true, "the overview has a series card");
|
|
console.log("PASS the guide has a Series / cup tab with the whole workflow");
|
|
|
|
const videoLinkCount = await evaluate(`document.querySelectorAll('[data-guide-panel="videos"] a[href^="/docs/videos/"]').length`);
|
|
assert.equal(videoLinkCount, 7, "all 7 video guide links live under the Video guides tab");
|
|
|
|
await evaluate(`document.querySelector('[data-guide-tab="run"]').click()`);
|
|
assert.equal(await activeTab(), "run");
|
|
// Switching language calls renderView() in place (no navigation) - exactly the path
|
|
// that would silently reset the tab if activeGuideTab weren't module-scoped state.
|
|
await evaluate(`(() => { const select = document.getElementById("languageSelect"); select.value = select.value === "en" ? "sv" : "en"; select.onchange(); })()`);
|
|
assert.equal(await activeTab(), "run", "the selected tab survives a language-switch re-render, instead of resetting to Getting started");
|
|
visible = await panelVisibility();
|
|
assert.equal(visible.run, true);
|
|
assert.equal(visible.start, false);
|
|
console.log("PASS the active guide tab is preserved across a language-switch re-render");
|
|
}
|