Skip to content

Commit 5ebff11

Browse files
authored
Merge pull request #283 from handsontable/fix/e2e-docs-bucket-suggestion-not-hardcoded
fix(runner): stop hard-coding the suggested docs bucket in the e2e spec
2 parents 2472da9 + a00bf24 commit 5ebff11

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

‎runner/e2e/docs-examples.spec.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { test, expect } from "@playwright/test";
2+
import { highestReleaseBucket } from "../packages/runtime/src/docs-bucket.js";
3+
import { readFileSync } from "node:fs";
24

35
// End-to-end tests for the docs-example playground UI. Deterministic tests do
46
// not depend on the external Sandpack bundler; the live-render test does and is
@@ -7,6 +9,16 @@ import { test, expect } from "@playwright/test";
79
const REACT_EXAMPLE = "/?docs=guides/columns/column-adding/react/example2.tsx";
810
const DOCS_PATH = "guides/columns/column-adding/react/example2.tsx";
911
const NEXT_VERSION = "19.0.0-next.1";
12+
// The bucket DEMOS-1C suggests to a visitor on an absent version: whatever the
13+
// generated index holds, resolved with the app's own helper rather than restated
14+
// here. `docs-buckets.json` is regenerated by every docs import, so a hard-coded
15+
// minor goes stale the next time one lands (18.0 -> 18.1 is what broke it).
16+
const DOCS_BUCKETS: string[] = JSON.parse(
17+
readFileSync(new URL("../docs-buckets.json", import.meta.url), "utf8"),
18+
).buckets;
19+
const SUGGESTED_BUCKET = highestReleaseBucket(DOCS_BUCKETS);
20+
if (!SUGGESTED_BUCKET) throw new Error("docs-buckets.json holds no release bucket to suggest");
21+
const SUGGESTION = new RegExp(`available for Handsontable ${SUGGESTED_BUCKET.replace(".", "\\.")}`);
1022

1123
const FRAMEWORKS = [
1224
["react", "React", "tsx"],
@@ -472,9 +484,13 @@ test("an open docs example with no target bucket stops preview and remains recov
472484

473485
// DEMOS-1C: the visitor is told which version has docs examples, not left
474486
// at a dead end that names none. Discriminating against pre-fix code, whose
475-
// literal message named only the selected version and never "18.0".
487+
// literal message named only the selected version and never the suggestion.
476488
await expect(
477-
page.getByText(/No documentation examples are available for Handsontable 17\.1\.0.*available for Handsontable 18\.0/).first(),
489+
page
490+
.getByText(
491+
new RegExp(`No documentation examples are available for Handsontable 17\\.1\\.0.*${SUGGESTION.source}`),
492+
)
493+
.first(),
478494
).toBeVisible();
479495
await expect(page.locator("section[aria-label='Preview'] iframe")).toHaveAttribute("src", "about:blank");
480496
await page.getByRole("button", { name: /React/ }).first().click();
@@ -541,7 +557,7 @@ test("a deep link into a bucket-less version shows not-found, not a retry prompt
541557
// DEMOS-1C: the deep-link dead end (§2.5's genuinely user-visible harm) used
542558
// to name no version at all ("This example may not be imported yet.").
543559
// Discriminating: this text never appears against pre-fix code.
544-
await expect(page.getByText(/available for Handsontable 18\.0/)).toBeVisible();
560+
await expect(page.getByText(SUGGESTION)).toBeVisible();
545561
});
546562

547563
test("a deep link whose manifest row has no artifact shows not-found", async ({ page }) => {

0 commit comments

Comments
 (0)