修改完成

This commit is contained in:
2026-07-21 07:53:03 +08:00
parent 01d246c47b
commit ff60119277
172 changed files with 7982 additions and 2999 deletions
+40 -7
View File
@@ -2,7 +2,7 @@ const fs = require('fs')
const path = require('path')
const origin = 'http://localhost:5173'
const outputDirectory = path.resolve('docs/design/screens/runtime/2026-07-19/g01-approval')
const outputDirectory = path.join(require('os').tmpdir(), 'jiapuapp-runtime', 'g01-approval')
const sizes = [
{ width: 320, height: 568 },
{ width: 360, height: 640 },
@@ -36,8 +36,16 @@ const connect = async () => {
const send = (method, params = {}) => new Promise((resolve, reject) => {
id += 1
pending.set(id, { resolve, reject })
socket.send(JSON.stringify({ id, method, params }))
const requestId = id
const timer = setTimeout(() => {
pending.delete(requestId)
reject(new Error(`CDP request timed out: ${method}`))
}, 8000)
pending.set(requestId, {
resolve: (value) => { clearTimeout(timer); resolve(value) },
reject: (error) => { clearTimeout(timer); reject(error) }
})
socket.send(JSON.stringify({ id: requestId, method, params }))
})
return { projectPageCount: projectPages.length, socket, send }
@@ -69,6 +77,13 @@ const setSize = async (send, width, height) => {
await sleep(150)
}
let navigationId = 0
const openG01 = async (send) => {
navigationId += 1
await send('Page.navigate', { url: `${origin}/?g01SwitchAudit=${navigationId}#/pages/genealogy/g01-my-genealogies` })
await waitFor(send, "Boolean(document.querySelector('.current-slip'))", 'G01 did not render after navigation')
}
const openSwitcher = async (send) => {
if (!await valueOf(send, "Boolean(document.querySelector('.genealogy-switcher'))")) {
const clicked = await valueOf(send, `(() => {
@@ -134,9 +149,10 @@ const getMetrics = (send) => valueOf(send, `(() => {
})()`)
const capture = async (send, filename) => {
await send('Page.bringToFront')
const screenshot = await send('Page.captureScreenshot', {
format: 'png',
fromSurface: true,
fromSurface: false,
captureBeyondViewport: false
})
fs.mkdirSync(outputDirectory, { recursive: true })
@@ -165,13 +181,13 @@ const run = async () => {
await send('Runtime.enable')
await send('Network.enable')
await setSize(send, 412, 915)
await send('Page.reload')
await waitFor(send, "Boolean(document.querySelector('.current-slip'))", 'G01 did not render after reload')
await openG01(send)
await openSwitcher(send)
const sizeResults = []
for (const size of sizes) {
await setSize(send, size.width, size.height)
await openG01(send)
await clearClones(send)
await openSwitcher(send)
const metrics = await getMetrics(send)
@@ -189,6 +205,8 @@ const run = async () => {
}
await setSize(send, 412, 915)
await openG01(send)
await openSwitcher(send)
assert(await addClonesToTotal(send, 6), 'Could not prepare six-item stress state')
await sleep(100)
const sixItems = await getMetrics(send)
@@ -214,6 +232,21 @@ const run = async () => {
const twelveItemsBottom = await getMetrics(send)
assert(twelveItemsBottom.listScrollTop > 0, 'Twelve-item list did not scroll to the bottom')
assert(await addClonesToTotal(send, 50), 'Could not prepare fifty-item stress state')
await sleep(100)
const fiftyItemsTop = await getMetrics(send)
assert(fiftyItemsTop.itemCount === 50, 'Fifty-item state did not contain fifty items')
assert(Math.abs(fiftyItemsTop.dialog.height - expectedMaximumHeight) < 3, 'Fifty-item dialog escaped its safe maximum height')
assert(fiftyItemsTop.listScrollHeight > fiftyItemsTop.listClientHeight * 3, 'Fifty-item list does not own its long-data scrolling')
await valueOf(send, `(() => {
const list = document.querySelector('.genealogy-switcher__list')
list.scrollTop = list.scrollHeight
return true
})()`)
await sleep(50)
const fiftyItemsBottom = await getMetrics(send)
assert(fiftyItemsBottom.listScrollTop > 0, 'Fifty-item list did not reach its bottom data')
await clearClones(send)
await valueOf(send, "document.querySelector('.genealogy-switcher__content').click()")
assert(await valueOf(send, "Boolean(document.querySelector('.genealogy-switcher'))"), 'Inner click closed the switcher')
@@ -243,7 +276,7 @@ const run = async () => {
assert(runtimeErrors.length === 0, `Runtime exceptions: ${runtimeErrors.join(' | ')}`)
assert(resourceErrors.length === 0, `Resource errors: ${resourceErrors.join(' | ')}`)
process.stdout.write(`${JSON.stringify({ projectPageCount, sizeResults, sixItems, twelveItemsTop, twelveItemsBottom, final, runtimeErrors, resourceErrors }, null, 2)}\n`)
process.stdout.write(`${JSON.stringify({ projectPageCount, sizeResults, sixItems, twelveItemsTop, twelveItemsBottom, fiftyItemsTop, fiftyItemsBottom, final, runtimeErrors, resourceErrors }, null, 2)}\n`)
process.stdout.write('PASS G-01 switch dialog runtime smoke\n')
} finally {
socket.close()