New `client/` package (Vite + TypeScript + PixiJS v8, plain DOM overlay): the pure reducer seam (no Pixi import), an append-only slice registry build-time glob, the `proto` 2 WS client with envelope/ack/closing mapping, the sign-in door (`POST /join`, one "Key not recognised." for wrong and unknown), the DOM shell/HUD and a minimal Pixi stage created only after a live `hello`. `hello` resets every slice so a reconnect cannot show stale state; `proto-mismatch` shows reload; `revoked` returns to the sign-in page and stops. The browser e2e moves into the client package (`client/e2e/`, owning playwright-core) and runs the real Vite build through the TLS/HTTP2 test nginx: join -> canvas -> hello/roster for GM and player, no data before join, identical wrong/unknown key refusal, proto mismatch, revoked. `devbox run client-test` adds the Vitest seam; `devbox run e2e` builds the client first. The #66 stub dist stays local to `tools/vhost.test.mjs`, so `devbox run test` still needs no npm install. Refs #67
56 lines
2.7 KiB
JavaScript
56 lines
2.7 KiB
JavaScript
// The browser half of the vhost gate (#66, TESTING 10.3): real Chromium loads the real client build
|
|
// from `/` through the TLS/HTTP2 test nginx and reports h2 for the document and its hashed assets.
|
|
// The client bundle replaces the throwaway `tools/distfixture.mjs` of #66; `client/e2e/run.sh`
|
|
// builds it before this test runs.
|
|
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { launchBrowser, newPage, withStack } from './stack.mjs'
|
|
|
|
test('e2e: headless chromium loads the real client build and the page reports h2', { timeout: 120000 }, async () => {
|
|
await withStack(async ({ origin }) => {
|
|
const browser = await launchBrowser()
|
|
try {
|
|
const { page } = await newPage(browser)
|
|
const loaded = []
|
|
page.on('response', response => loaded.push({ url: response.url(), status: response.status() }))
|
|
const errors = []
|
|
page.on('pageerror', error => errors.push(error.message))
|
|
page.on('console', message => {
|
|
// The boot probe's refused WebSocket upgrade is the expected no-session path (the browser
|
|
// logs it); it is not a page error. Everything else must be silent.
|
|
if (message.type() === 'error' && !message.text().includes('WebSocket connection')) {
|
|
errors.push(message.text())
|
|
}
|
|
})
|
|
|
|
await page.goto(`${origin}/`, { waitUntil: 'load' })
|
|
|
|
assert.equal(await page.title(), 'FFF VTT')
|
|
await page.locator('#app').waitFor({ state: 'attached' })
|
|
// A visitor with no session gets the sign-in door; the canvas is created only after `hello`.
|
|
await page.locator('#signin').waitFor({ state: 'visible', timeout: 20000 })
|
|
assert.deepEqual(errors, [])
|
|
|
|
const assets = loaded.filter(response => new URL(response.url).pathname.startsWith('/assets/'))
|
|
assert.ok(assets.length > 0, `the page loaded hashed assets: ${JSON.stringify(loaded)}`)
|
|
assert.ok(assets.every(response => response.status === 200))
|
|
|
|
const proto = await page.evaluate(() => {
|
|
const navigation = performance.getEntriesByType('navigation')[0]
|
|
const resources = performance
|
|
.getEntriesByType('resource')
|
|
.map(entry => ({ name: entry.name, protocol: entry.nextHopProtocol }))
|
|
return { scheme: location.protocol, navigation: navigation.nextHopProtocol, resources }
|
|
})
|
|
assert.equal(proto.scheme, 'https:')
|
|
assert.equal(proto.navigation, 'h2', 'the document came over HTTP/2')
|
|
assert.ok(
|
|
proto.resources.some(resource => resource.protocol === 'h2' && resource.name.endsWith('.js')),
|
|
`subresources are h2 too: ${JSON.stringify(proto.resources)}`,
|
|
)
|
|
} finally {
|
|
await browser.close()
|
|
}
|
|
})
|
|
})
|