Files
FFF_vtt_frozen/client/e2e/perf.test.mjs
T

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 visible \d+ \/ total \d+/)
assert.match(text, /zoom \d+\.\d\d/)
await perf.context.close()
} finally {
await browser.close()
}
})
})