验收20%

This commit is contained in:
2026-07-16 07:42:07 +08:00
parent 0dec90ffdd
commit cb25317412
108 changed files with 6477 additions and 1308 deletions
@@ -12,8 +12,10 @@ const connect = async () => {
})
let id = 0
const pending = new Map()
const exceptions = []
socket.addEventListener('message', (event) => {
const message = JSON.parse(event.data)
if (message.method === 'Runtime.exceptionThrown') exceptions.push(message.params.exceptionDetails.text)
const request = pending.get(message.id)
if (!request) return
pending.delete(message.id)
@@ -24,10 +26,14 @@ const connect = async () => {
pending.set(id, { resolve, reject })
socket.send(JSON.stringify({ id, method, params }))
})
return { socket, send }
return { socket, send, exceptions }
}
const valueOf = async (send, expression) => (await send('Runtime.evaluate', { expression, returnByValue: true })).result?.value
const valueOf = async (send, expression) => {
const result = await send('Runtime.evaluate', { expression, returnByValue: true })
if (result.exceptionDetails) throw new Error(result.exceptionDetails.exception?.description || result.exceptionDetails.text)
return result.result?.value
}
const waitFor = async (send, expression, message) => {
for (let attempt = 0; attempt < 40; attempt += 1) {
if (await valueOf(send, expression)) return
@@ -45,7 +51,7 @@ const open = async (send, route, query, selector) => {
}
const run = async () => {
const { socket, send } = await connect()
const { socket, send, exceptions } = await connect()
try {
await send('Page.enable')
await send('Runtime.enable')
@@ -63,12 +69,56 @@ const run = async () => {
})()`)
if (!prepared) throw new Error('G08 form controls could not be prepared')
await waitFor(send, "Boolean(document.querySelector('.join-state--success'))", 'G08 real form submission did not reach the same-page success state')
await open(send, '/pages/genealogy/g08-join-application', '?source=invite&genealogyId=2001', '.join-state--form')
await valueOf(send, "document.querySelector('.join-action').click()")
await waitFor(send, "document.querySelectorAll('.join-field-error').length === 2", 'G08 invite source did not show two inline required errors')
const invitePrepared = await valueOf(send, `(() => {
const inputs = Array.from(document.querySelectorAll('.join-field input'))
inputs[0].value = '汤明远'
inputs[0].dispatchEvent(new Event('input', { bubbles: true }))
inputs[1].value = '汤正华堂侄'
inputs[1].dispatchEvent(new Event('input', { bubbles: true }))
return true
})()`)
if (!invitePrepared) throw new Error('G08 invite controls could not be prepared')
await sleep(100)
await valueOf(send, "document.querySelector('.join-action').click()")
await waitFor(send, "Boolean(document.querySelector('.join-state--success'))", 'G08 invite source did not reach success')
if (!(await valueOf(send, "document.body.textContent.includes('无需等待审核')"))) throw new Error('G08 invite source did not preserve direct-join semantics')
await valueOf(send, "document.querySelector('.join-result .join-action').click()")
await waitFor(send, "location.href.includes('/pages/genealogy/g01-my-genealogies?genealogyId=2001')", 'G08 invite success did not return to selected G01 genealogy')
for (const size of [{ width: 320, height: 568 }, { width: 360, height: 800 }, { width: 412, height: 915 }]) {
await send('Emulation.setDeviceMetricsOverride', { ...size, deviceScaleFactor: 1, mobile: true })
await open(send, '/pages/genealogy/g08-join-application', '?source=search&genealogyId=2001', '.join-state--form')
const width = await valueOf(send, 'document.documentElement.scrollWidth')
if (width > size.width + 1) throw new Error(`G08 has horizontal overflow at ${size.width}x${size.height}`)
}
await open(send, '/pages/genealogy/g09-my-applications', '', '.application-state--list')
if ((await valueOf(send, "document.querySelectorAll('.application-card__action').length")) !== 3) throw new Error('G09 list did not render the three status-specific actions')
await valueOf(send, "document.querySelector('.application-card__action').click()")
await waitFor(send, "Boolean(document.querySelector('.withdraw-layer'))", 'G09 pending action did not open custom withdrawal confirmation')
await valueOf(send, "document.querySelector('.withdraw-action--danger').click()")
await waitFor(send, "document.querySelector('.application-card__status')?.textContent.includes('已撤回')", 'G09 withdrawal did not update the local status')
await valueOf(send, "document.querySelectorAll('.application-card__action')[1].click()")
await waitFor(send, "location.href.includes('/pages/genealogy/g08-join-application?source=search&previous=rejected&genealogyId=')", 'G09 rejected action did not reopen G08 search source')
await open(send, '/pages/genealogy/g09-my-applications', '?state=empty', '.application-state--empty')
await open(send, '/pages/genealogy/g10-application-review', '?genealogyId=1001', '.review-state--list')
await valueOf(send, "document.querySelectorAll('.review-action')[1].click()")
await waitFor(send, "Boolean(document.querySelector('.review-dialog-layer'))", 'G10 approve action did not open custom confirmation')
await valueOf(send, "document.querySelector('.review-dialog__action--primary').click()")
await waitFor(send, "document.querySelector('.application-card__status')?.textContent.includes('已通过')", 'G10 approval did not update the card')
await waitFor(send, "Boolean(document.querySelector('.review-feedback'))", 'G10 approval did not show custom feedback')
await valueOf(send, "document.querySelector('.header-action').click()")
await waitFor(send, "document.querySelector('.review-dialog__title')?.textContent.includes('审核说明')", 'G10 help did not use the custom dialog')
await valueOf(send, "document.querySelector('.review-dialog__single').click()")
await open(send, '/pages/genealogy/g10-application-review', '?state=empty&genealogyId=1001', '.review-state--empty')
await open(send, '/pages/genealogy/g10-application-review', '?state=no-permission&genealogyId=1001', '.review-state--no-permission')
if (exceptions.length) throw new Error(`G08-G10 raised browser exceptions: ${exceptions.join('; ')}`)
process.stdout.write('G08-G10-APPLICATION-FLOW-RUNTIME-SMOKE PASS\n')
} finally {
try { await send('Emulation.clearDeviceMetricsOverride') } catch (_) {}
socket.close()
}
}