@@ -5,9 +5,10 @@ import { expect, test } from '@playwright/test'
55
66/*
77 * /h5p/skill/ as a chat that cannot install the h5p-author skill reads it: a page that writes out
8- * the full address of every file, since a chat's fetch tool may open only addresses it has seen
9- * whole; each file there as the pinned author package carries it; and every address SKILL.md gives,
10- * relative to itself or written out, served by this site.
8+ * the full address of every file, and of the build tool and every bundle in /h5p/bundles/, since a
9+ * chat's fetch tool may open only addresses it has seen whole; each file there as the pinned author
10+ * package carries it; and every address SKILL.md gives, relative to itself or written out, served
11+ * by this site.
1112 */
1213
1314const SITE = 'https://missing-elements.github.io'
@@ -38,6 +39,17 @@ test('the page writes out the full address of every file of the skill, as its li
3839 expect ( [ ...listing . files ] . sort ( ) ) . toEqual ( files )
3940} )
4041
42+ test ( 'writes out the full address of the build tool and of every bundle the site serves, as its link and its text' , async ( { page, request } ) => {
43+ // The page names the bundles before Vite writes them; the listing is what Vite wrote.
44+ const listing = await ( await request . get ( '/h5p/bundles/index.json' ) ) . json ( ) as { tool : string , bundles : Array < { file : string } > }
45+ expect ( listing . bundles . length ) . toBeGreaterThan ( 40 )
46+ await page . goto ( '/h5p/skill/' )
47+ const links = await page . locator ( `main a[href^="${ SITE } /h5p/bundles/"]` ) . evaluateAll ( ( anchors ) =>
48+ anchors . map ( ( anchor ) => ( { href : anchor . getAttribute ( 'href' ) , text : anchor . textContent ?. trim ( ) } ) ) )
49+ expect ( links . map ( ( { href } ) => href ) ) . toEqual ( [ listing . tool , ...listing . bundles . map ( ( { file } ) => file ) ] . map ( ( file ) => `${ SITE } /h5p/bundles/${ file } ` ) )
50+ for ( const { href, text } of links ) expect ( text ) . toBe ( href )
51+ } )
52+
4153test ( 'serves each file at its address as the pinned author package carries it' , async ( { request } ) => {
4254 for ( const file of await carried ( ) ) {
4355 const response = await request . get ( `/h5p/skill/${ file } ` )
@@ -54,6 +66,9 @@ test('serves every address SKILL.md gives, relative to itself or on this site',
5466 // Its addresses on this site, with a content type for the name it leaves to fill in, and no fragment.
5567 const filled = skill . replace ( / < t y p e > / gi, 'H5P.QuestionSet' )
5668 const onSite = [ ...new Set ( [ ...filled . matchAll ( / h t t p s : \/ \/ m i s s i n g - e l e m e n t s \. g i t h u b \. i o ( \/ [ ^ \s ` ) > " ' # ] * ) / g) ] . map ( ( [ , path ] ) => path ) ) ]
57- expect ( onSite ) . toEqual ( expect . arrayContaining ( [ '/h5p/build/types/H5P.QuestionSet.md' , '/h5p/bundles/H5P.QuestionSet.zip' , '/h5p/build/' ] ) )
69+ expect ( onSite ) . toEqual ( expect . arrayContaining ( [ '/h5p/bundles/H5P.QuestionSet.zip' , '/h5p/build/' ] ) )
70+ // A type's file, at an address of its own as h5p-author 0.9.0 gives it, or from this page, which
71+ // writes each one out (the first test), as the release after it does (h5p-offline-player#180).
72+ expect ( onSite . some ( ( path ) => path === '/h5p/build/types/H5P.QuestionSet.md' || path === '/h5p/skill/' ) , 'a way to a type\'s file' ) . toBe ( true )
5873 for ( const path of [ ...relativeLinks , ...onSite ] ) expect ( ( await request . get ( path ) ) . ok ( ) , path ) . toBe ( true )
5974} )
0 commit comments