渲染链路加固: - PageRenderPage 加 AmisErrorBoundary class component + SchemaErrorCard,覆盖 schema 拉取失败/JSON 异常/amis 渲染抛错三种路径,不白屏不崩 Tab - schema 加载成功后调用 recordRecentPage 写入最近打开 - src/api/schema.ts mock 模式下未配置 templateId 自动 fallback 后端接口 全量健康度扫描 (scripts/schema-scan.mjs): - 登录→psql 拉取 1489 个 template_id→并发≤8 扫描→产出报告 - 结果: 1489/1489 HTTP 200,JSON 可解析率 100%,顶层 type 全为 page,零失败 抽样渲染实测 (e2e/schema-samples.spec.ts): - 9 种类型 26 个样本,Node 侧预登录注入真实 JWT,断言 amis-host 挂载且无错误卡片 - 结果: 26/26 全部通过,截图存 e2e/artifacts/ 配置更新: - playwright.config.ts 后端反代改为 8093 (dev profile,含所有端点) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
3.9 KiB
F1-4 Schema 全量接入扫描报告
日期:2026-06-11
执行人:自动化脚本 + Playwright e2e
后端:localhost:8093(dev profile,eip4dev 库)
一、渲染链路加固(PageRenderPage 错误边界)
实施内容:
src/pages/PageRenderPage.tsx:新增AmisErrorBoundary(class component)捕获 amis 渲染层抛错,新增SchemaErrorCard统一错误卡片(含data-testid="schema-error-card"),覆盖三种失败路径:- schema 拉取失败(HTTP 4xx/5xx/网络错误)→ SchemaErrorCard
- schema 顶层 JSON 异常(非对象)→ SchemaErrorCard
- amis 渲染抛错 → AmisErrorBoundary → SchemaErrorCard
src/api/schema.ts:mock 模式下未配置的 templateId 自动 fallback 到后端接口,支持真实 UUID 在开发期直接渲染。recordRecentPage接入:schema 渲染成功后写入最近打开(取schema.title或 templateId)。
菜单链路确认:
SideMenu 叶子点击 → handleMenuOpen(templateId) → openTab('/page/{templateId}', templateId) → PageRenderPage 路由渲染。链路已通,无需改动壳层代码。
二、全量产物健康度扫描(scripts/schema-scan.mjs)
扫描时间:2026-06-11
后端:localhost:8093,并发:≤8
| 指标 | 值 |
|---|---|
| 总计 template_id | 1489 |
| HTTP 200 成功数 | 1489 |
| HTTP 200 成功率 | 100.00% |
| JSON 可解析数 | 1489 |
| JSON 可解析率 | 100.00% |
| 失败数 | 0 |
| 顶层 type 分布 | { "page": 1489 } |
结论:全量 1489 条产物 100% 可达、可解析,顶层 type 全为 page,无任何失败条目。
失败清单:无(failureCount = 0)
三、抽样渲染实测(e2e/schema-samples.spec.ts)
样本数:26 个(任务单给出 27 个,其中 type5 仅列出 2 个,测试中发现 SAMPLES 数组共 26 条)
断言:data-testid="amis-host" 可见 + data-testid="schema-error-card" 不可见
| 类型 | 样本数 | 通过 | 失败 |
|---|---|---|---|
| type1 | 3 | 3 | 0 |
| type3 | 3 | 3 | 0 |
| type4 | 3 | 3 | 0 |
| type5 | 2 | 2 | 0 |
| type6 | 3 | 3 | 0 |
| type7 | 3 | 3 | 0 |
| type100 | 3 | 3 | 0 |
| type101 | 3 | 3 | 0 |
| type200 | 3 | 3 | 0 |
| 合计 | 26 | 26 | 0 |
截图存放:e2e/artifacts/{type}-{templateId}.png
四、既有回归(e2e/script-replay.spec.ts)
结果:2 tests 失败(与 F1-4 改动无关)
根因:script-replay 测试依赖 /api/script/execute-template 端点上的特定改写后脚本数据(templateId 0d9eac07-...),该数据存在于 P4-5 专用后端实例(localhost:8086),当前运行环境 8093(eip4dev)没有这批脚本。
验证方法:git stash 恢复到 effc21d(F1-4 改动前),在相同环境运行 script-replay,结果同样 2 failed。确认为环境预存问题,非 F1-4 引入回归。
归因分桶:
| 错误类型 | 数量 | 说明 |
|---|---|---|
| 脚本数据缺失 | 2 | 8093 无 P4-5 测试脚本数据,需在 8086 环境运行 |
五、构建与单测
| 检查项 | 结果 |
|---|---|
npm run build(tsc + vite build) |
✅ 通过 |
npm run test(vitest,21 tests) |
✅ 全部通过 |
npx tsc --noEmit |
✅ 零错误 |
六、文件清单
| 文件 | 变更类型 | 说明 |
|---|---|---|
src/pages/PageRenderPage.tsx |
修改 | 错误边界 + recentPages 接入 |
src/api/schema.ts |
修改 | mock fallback 到后端(开发期支持真实 UUID) |
playwright.config.ts |
修改 | 后端反代改为 8093(dev profile) |
scripts/schema-scan.mjs |
新增 | 全量 schema 健康度扫描脚本 |
scripts/schema-scan-report.json |
新增 | 扫描结果报告 |
e2e/schema-samples.spec.ts |
新增 | 27 样本抽样渲染 e2e |
e2e/artifacts/ |
新增 | 渲染截图(26 张) |
docs/F1-4扫描报告.md |
新增 | 本报告 |