feat(m4): playtest friction: perf overlay, fresh import, token seed (#82)
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.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// #82: the GM token form starts at the viewport centre, not the old 400,400. The scene is the
|
||||
// seeded 4096x4096 one, so the initial 1000x700 GM view centres on 2048,2048.
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { launchBrowser, newPage, signIn, waitForVisible, withStack } from './stack.mjs'
|
||||
|
||||
test('GM token create defaults X/Y to the viewport centre', { timeout: 120000 }, async () => {
|
||||
await withStack(async ({ origin, gmKey }) => {
|
||||
const browser = await launchBrowser()
|
||||
try {
|
||||
const { page } = await newPage(browser)
|
||||
await page.goto(`${origin}/`)
|
||||
await waitForVisible(page, '#signin')
|
||||
await signIn(page, gmKey)
|
||||
await waitForVisible(page, '#stage canvas')
|
||||
await page.waitForFunction(() => {
|
||||
const x = document.querySelector('#token-x')
|
||||
const y = document.querySelector('#token-y')
|
||||
return x?.value === '2048' && y?.value === '2048'
|
||||
}, undefined, { timeout: 20000 })
|
||||
assert.equal(await page.inputValue('#token-x'), '2048')
|
||||
assert.equal(await page.inputValue('#token-y'), '2048')
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,46 @@
|
||||
// #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()
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user