diff --git a/docs/viewer-publishing.md b/docs/viewer-publishing.md index e23adb4..2e07b7b 100644 --- a/docs/viewer-publishing.md +++ b/docs/viewer-publishing.md @@ -9,3 +9,9 @@ BGS compresses JS, CSS, JSON and WASM automatically during upload. Send the orig The BGS admin's **Upload folder** control handles multi-file builds. For scripted releases, use BGS's `scripts/publish-viewer.mjs` with `--dir`, `--entry` and `--style`; it verifies every uploaded file, records the previous viewer, and activates only with `--apply --activate`. The full command and API contract are in the [BGS viewer documentation](https://docs.boardgamers.space/guide/viewer-api#publishing-a-viewer-with-multiple-files). English needs no language download; other languages load when selected. Test a cold load and a language change after publishing. Also check the browser Network panel for missing relative assets. + +Verify the uploaded entry itself with `node test/journal-release-browser.mjs viewer.json`, +where `viewer.json` contains the published viewer metadata. This checks journal +apostrophes and quoted player names before and after English/French switching. +An optional second argument supplies a candidate JS file at the existing entry URL +for a pre-publication check with the release's actual CSS and locale files. diff --git a/test/journal-release-browser.mjs b/test/journal-release-browser.mjs new file mode 100644 index 0000000..3a3b8d2 --- /dev/null +++ b/test/journal-release-browser.mjs @@ -0,0 +1,83 @@ +// Test the actual release artifact, including its relative locale downloads. +// Usage: node test/journal-release-browser.mjs viewer.json [candidate-viewer.js] +import assert from "node:assert/strict"; +import { readFile } from "node:fs/promises"; +import { chromium } from "playwright"; +import { prepared } from "../viewer/tutorials.js"; +import { stripSecret } from "../engine/index.js"; + +const viewer = JSON.parse(await readFile(process.argv[2], "utf8")); +const browser = await chromium.launch({ + executablePath: process.env.CHROMIUM_EXECUTABLE, +}); +try { + const page = await browser.newPage(); + const errors = []; + page.on("pageerror", (error) => errors.push(error.message)); + await page.route( + "https://boardgamers.space/__journal_release_check__", + (route) => + route.fulfill({ + contentType: "text/html; charset=utf-8", + body: '
', + }), + ); + if (process.argv[3]) { + const body = await readFile(process.argv[3], "utf8"); + await page.route(viewer.url, (route) => + route.fulfill({ contentType: "text/javascript; charset=utf-8", body }), + ); + } + await page.goto("https://boardgamers.space/__journal_release_check__"); + for (const url of viewer.dependencies?.stylesheets ?? []) + await page.addStyleTag({ url }); + await page.addScriptTag({ url: viewer.url }); + const state = prepared(); + const name = `O'Brien & "Co"