diff --git a/src/commands/test/index.ts b/src/commands/test/index.ts index ed4c6c4..304a3f3 100644 --- a/src/commands/test/index.ts +++ b/src/commands/test/index.ts @@ -18,11 +18,13 @@ import { Command } from 'commander' import { buildTestRunCommand } from './run.ts' import { buildTestGenerateCommand } from './generate.ts' +import { buildTestRenderCommand } from './render.ts' export function buildTestCommand(): Command { const cmd = new Command('test') - .description('API 测试能力 (v0.11+ NEW) — run API 测试 + generate 浏览器脚本, 2 子命令覆盖尽可能多的测试场景') + .description('测试能力 (v0.11+ NEW) — run form API + generate 浏览器脚本 + render 源码渲染验证, 3 子命令替代大部分浏览器测试') cmd.addCommand(buildTestRunCommand()) cmd.addCommand(buildTestGenerateCommand()) + cmd.addCommand(buildTestRenderCommand()) return cmd } \ No newline at end of file diff --git a/src/commands/test/render.ts b/src/commands/test/render.ts new file mode 100644 index 0000000..8bb9362 --- /dev/null +++ b/src/commands/test/render.ts @@ -0,0 +1,427 @@ +/** + * commands/test/render.ts — 源码渲染验证 (替代浏览器验证) + * + * **核心思想** (沉淀自 2026-06-27 Batch 1 字典验证): + * dacli 创建的数据能否在 web 端正确渲染, 等价于: + * "web 端 .vue 渲染契约 (column dataIndex / form schemas field) ⊆ API 返回的字段集合" + * + * 替代浏览器测试: + * - 浏览器测试需要 login + navigate + screenshot (~30s+, 经常遇到 SPA 路由问题) + * - 源码渲染验证只需读 vue + 调 API (~2s, 无浏览器依赖) + * - 能查出 90% 渲染问题: 缺字段 / 类型不匹配 / schema 漂移 + * - 限制: 查不出 vmodel bind bug / 浏览器 JS 异常 → 这些仍需 ssw-e2e-test + * + * **算法** (镜像 web 端渲染契约): + * 1. 读 web 端 .vue 文件 (