11import { 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";
79const REACT_EXAMPLE = "/?docs=guides/columns/column-adding/react/example2.tsx" ;
810const DOCS_PATH = "guides/columns/column-adding/react/example2.tsx" ;
911const 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
1123const 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 ( / N o d o c u m e n t a t i o n e x a m p l e s a r e a v a i l a b l e f o r H a n d s o n t a b l e 1 7 \. 1 \. 0 .* a v a i l a b l e f o r H a n d s o n t a b l e 1 8 \. 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 : / R e a c t / } ) . 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 ( / a v a i l a b l e f o r H a n d s o n t a b l e 1 8 \. 0 / ) ) . toBeVisible ( ) ;
560+ await expect ( page . getByText ( SUGGESTION ) ) . toBeVisible ( ) ;
545561} ) ;
546562
547563test ( "a deep link whose manifest row has no artifact shows not-found" , async ( { page } ) => {
0 commit comments