接口开始5%

This commit is contained in:
rain
2026-07-22 17:31:33 +08:00
parent eced3d1e6e
commit 9b0ad62df4
426 changed files with 20111 additions and 28472 deletions
@@ -63,16 +63,49 @@ const open = async (socket, send, route, query, selector) => {
await waitFor(send, `Boolean(document.querySelector(${JSON.stringify(selector)}))`, `${route}${query} did not render`)
}
const setFieldValue = async (send, selector, value) => {
const prepared = await valueOf(send, `(() => {
const field = document.querySelector(${JSON.stringify(selector)})
if (!field) return false
field.value = ${JSON.stringify(value)}
field.dispatchEvent(new Event('input', { bubbles: true }))
return true
})()`)
if (!prepared) throw new Error(`Could not prepare field: ${selector}`)
await sleep(50)
}
const run = async () => {
const { socket, send } = await connect()
try {
await send('Page.enable')
await send('Runtime.enable')
// 步骤一:G11 从真实表单触发必填校验,再保存有效名称并进入成功反馈。
await open(socket, send, '/pages/genealogy/g11-genealogy-settings', '?genealogyId=1001', '.settings-state--form')
await setFieldValue(send, '.settings-field input', '')
await valueOf(send, "document.querySelector('.settings-action').click()")
await waitFor(send, "Boolean(document.querySelector('.settings-field-error'))", 'G11 empty name did not show inline validation')
await setFieldValue(send, '.settings-field input', '某氏家谱')
await valueOf(send, "document.querySelector('.settings-action').click()")
await waitFor(send, "Boolean(document.querySelector('.settings-state--success'))", 'G11 valid save did not enter success state')
await waitFor(send, "Boolean(document.querySelector('.settings-feedback'))", 'G11 valid save did not show feedback')
await open(socket, send, '/pages/genealogy/g11-genealogy-settings', '?state=success&genealogyId=1001', '.settings-state--success')
// 步骤二:G12 依次验证空内容、模拟保存失败和真实保存成功,三类结果不能只靠查询参数摆出。
await open(socket, send, '/pages/genealogy/g12-generation-poems', '?genealogyId=1001', '.poem-state--list')
await open(socket, send, '/pages/genealogy/g12-generation-poems', '?state=empty&genealogyId=1001', '.poem-state--empty')
await open(socket, send, '/pages/genealogy/g12-generation-poems', '?state=edit&genealogyId=1001', '.poem-state--edit')
await setFieldValue(send, '.poem-field textarea', '')
await valueOf(send, "document.querySelector('.poem-editor__actions .poem-action:last-child').click()")
await waitFor(send, "document.querySelector('.poem-field-error')?.textContent.includes('请录入字辈内容')", 'G12 empty poem did not show validation')
await setFieldValue(send, '.poem-field textarea', '失败')
await valueOf(send, "document.querySelector('.poem-editor__actions .poem-action:last-child').click()")
await waitFor(send, "document.querySelector('.poem-field-error')?.textContent.includes('保存失败')", 'G12 simulated save failure did not render')
await setFieldValue(send, '.poem-field textarea', '启宪敦本继世传芳')
await valueOf(send, "document.querySelector('.poem-editor__actions .poem-action:last-child').click()")
await waitFor(send, "Boolean(document.querySelector('.poem-state--list'))", 'G12 valid save did not return to the list')
await waitFor(send, "Boolean(document.querySelector('.poem-feedback'))", 'G12 valid save did not show feedback')
process.stdout.write('G11-G12-SETTINGS-POEMS-RUNTIME-SMOKE PASS\n')
} finally {
socket.close()