// 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 => { // A fresh visitor no longer probes `/ws` before signing in (M4 UX), so a healthy load has // no refused-upgrade noise: every console error is a real error here. if (message.type() === 'error') 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() } }) })