接口开始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
@@ -1,10 +1,5 @@
const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds))
const fs = require('fs')
const os = require('os')
const path = require('path')
const origin = process.argv.find((argument) => /^https?:\/\//.test(argument)) || 'http://localhost:5173'
const captureEnabled = process.argv.includes('--capture')
const captureDirectory = path.join(os.tmpdir(), 'jiapuapp-runtime', 't-business-split')
const connect = async () => {
const pages = await (await fetch('http://127.0.0.1:9222/json/list')).json()
@@ -66,13 +61,6 @@ const assertText = async (send, text, message) => {
if (!(await includesText(send, text))) throw new Error(message)
}
const capture = async (send, name) => {
if (!captureEnabled) return
fs.mkdirSync(captureDirectory, { recursive: true })
const result = await send('Page.captureScreenshot', { format: 'png', fromSurface: false })
fs.writeFileSync(path.join(captureDirectory, `${name}.png`), Buffer.from(result.data, 'base64'))
}
const run = async () => {
const { socket, send } = await connect()
try {
@@ -89,19 +77,16 @@ const run = async () => {
await open(send, '/pages/tree/t03-member-profile', '?genealogyId=1001&personId=102', '.member-state--detail')
await assertText(send, '汤正国', 'T03 did not derive content from personId 102')
await assertText(send, '隐私资料', 'T03 did not expose person 102 privacy entry')
await capture(send, 't03-person-102-320x568')
await open(send, '/pages/tree/t04-add-relative', '?genealogyId=1001&personId=101', '.add-state--form')
await assertText(send, '为汤文远添加一位亲属', 'T04 did not derive the current member task')
await valueOf(send, 'document.querySelector(".form-action").click()')
await waitFor(send, 'document.querySelectorAll(".field-error").length === 3', 'T04 did not keep required-field errors near their fields')
await capture(send, 't04-validation-320x568')
await open(send, '/pages/tree/t04-add-relative', '?genealogyId=1001&mode=first', '.add-state--form')
await assertText(send, '录入家谱中的第一位成员', 'T04 first-member mode did not render')
await open(send, '/pages/tree/t05-edit-member', '?genealogyId=1001&personId=102', '.edit-state--form')
await assertText(send, '完善汤正国的生命记录', 'T05 did not load the selected member')
await capture(send, 't05-person-102-320x568')
await open(send, '/pages/tree/t05-edit-member', '?state=no-permission&genealogyId=1001&personId=103', '.edit-state--no-permission')
await assertText(send, '当前账号不能编辑这位成员', 'T05 permission state did not render')
@@ -110,10 +95,14 @@ const run = async () => {
await assertText(send, '关系影响预览', 'T06 relationship preview is missing')
await valueOf(send, 'document.querySelector(".form-action").click()')
await waitFor(send, 'document.querySelectorAll(".field-error").length === 2 && Boolean(document.querySelector(".relationship-state--form"))', 'T06 confused missing fields with a relationship conflict')
await capture(send, 't06-validation-320x568')
await open(send, '/pages/tree/t06-edit-relationship', '?state=conflict&genealogyId=1001&personId=102', '.relationship-state--conflict')
await assertText(send, '这段关系会造成世系矛盾', 'T06 conflict result did not render')
// 冲突说明必须通过当前页面的真实操作打开共享弹窗,不能只检查静态冲突文案。
await valueOf(send, 'document.querySelector(".result-actions .form-action:last-child").click()')
await waitFor(send, 'Boolean(document.querySelector(".app-dialog-layer"))', 'T06 conflict help did not open the shared dialog')
await assertText(send, '为什么不能保存这段关系', 'T06 conflict help dialog title is missing')
await open(send, '/pages/tree/t08-member-states', '?state=deceased&genealogyId=1001&personId=101', '.member-status--deceased')
await assertText(send, '汤文远', 'T08 did not retain member identity')
if (await valueOf(send, 'Boolean(document.querySelector(".status-tabs"))')) throw new Error('T08 still exposes demonstration state tabs')
@@ -121,7 +110,6 @@ const run = async () => {
await assertText(send, '汤正国', 'T08 privacy state is not person-driven')
await open(send, '/pages/tree/t08-member-states', '?state=forbidden&genealogyId=1001&personId=103', '.member-status--forbidden')
await assertText(send, '汤正华', 'T08 forbidden state is not person-driven')
await capture(send, 't08-person-103-forbidden-320x568')
await open(send, '/pages/tree/t08-member-states', '?state=privacy&genealogyId=1001', '.member-status--error')
process.stdout.write('T03-T08-BUSINESS-SPECIALIZATION-RUNTIME-SMOKE PASS\n')