Opt-in ?perf=1 overlay (fps, frame p50/p95, JS p50/p95, tokens, zoom; no node or ticker work when off). fff-vtt import creates and migrates a fresh/empty state dir through the shared server startup path; devbox run serve gains --image. devbox run seed creates deterministic labelled NPC tokens over the real WS (idempotent rerun, --replace), and the GM token form defaults X/Y to the viewport centre.
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
// #82: the opt-in perf overlay. Hidden by default (no node, no work), and with `?perf=1` it shows
|
|
// the numbers the phone checklist records, from the real client through the real server/nginx.
|
|
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {
|
|
launchBrowser,
|
|
newPage,
|
|
signIn,
|
|
waitForText,
|
|
waitForVisible,
|
|
withStack,
|
|
} from './stack.mjs'
|
|
|
|
async function signInGm(browser, origin, gmKey, path = '/') {
|
|
const view = await newPage(browser)
|
|
await view.page.goto(`${origin}${path}`)
|
|
await waitForVisible(view.page, '#signin')
|
|
await signIn(view.page, gmKey)
|
|
await waitForVisible(view.page, '#stage canvas')
|
|
return view
|
|
}
|
|
|
|
test('perf overlay: absent by default, `?perf=1` shows fps/frame/JS/tokens/zoom', { timeout: 120000 },
|
|
async () => {
|
|
await withStack(async ({ origin, gmKey }) => {
|
|
const browser = await launchBrowser()
|
|
try {
|
|
const normal = await signInGm(browser, origin, gmKey)
|
|
assert.equal(await normal.page.locator('#perf').count(), 0,
|
|
'no overlay node without the opt-in')
|
|
await normal.context.close()
|
|
|
|
const perf = await signInGm(browser, origin, gmKey, '/?perf=1')
|
|
await waitForVisible(perf.page, '#perf')
|
|
const text = await waitForText(perf.page, '#perf', /fps \d/)
|
|
assert.match(text, /fps \d+\.\d/)
|
|
assert.match(text, /frame p50 \d+\.\d p95 \d+\.\d ms/)
|
|
assert.match(text, /JS p50 \d+\.\d\d p95 \d+\.\d\d ms/)
|
|
assert.match(text, /tokens \d+/)
|
|
assert.match(text, /zoom \d+\.\d\d/)
|
|
await perf.context.close()
|
|
} finally {
|
|
await browser.close()
|
|
}
|
|
})
|
|
})
|