Files
dacli/src/commands/test/index.ts
T
sswandClaude 98dd56cedc feat(test): 新增 test render 子命令 (源码渲染验证, 替代浏览器验证)
实现 (镜像 web 端渲染契约 + 调 API 字段对比):
  - @vue/compiler-sfc 解析 web/.../sysData/dictionary/{index,Form,components/index,components/Form}.vue
  - list mode: 提取 BasicColumn[].dataIndex (列表渲染字段)
  - form mode: 提取 useForm({schemas:[{field}]}).field (表单渲染字段)
  - 调对应 API 拿当前数据 (DictionaryType / DictionaryData/{typeId})
  - 对比: 渲染字段 ⊆ API 字段 ? PASS : FAIL

覆盖 4 个页面 (dict module):
  - 字典类型列表 (components/index.vue + GET /DictionaryType)
  - 字典数据列表 (index.vue + GET /DictionaryData/{typeId})
  - 字典类型编辑表单 (components/Form.vue + GET /DictionaryType/{id})
  - 字典数据编辑表单 (Form.vue + GET /DictionaryData/{id}/Info)

vs 浏览器测试:
  - 速度 2s vs 30s+
  - 不需 playwright / 浏览器启动
  - 不依赖 SPA 路由 (JNPF admin 菜单经常 404)
  - 局限: 查不出 vmodel bind bug (浏览器 JS) → 仍需 ssw-e2e-test

镜像 web 端代码 (2026-06-27 读源码):
  - web/.../sysData/dictionary/index.vue L27-32 BasicColumn
  - web/.../sysData/dictionary/Form.vue L19-62 useForm.schemas
  - web/.../sysData/dictionary/components/index.vue L20-25 BasicColumn
  - web/.../sysData/dictionary/components/Form.vue L19-69 useForm.schemas
  - web/.../api/systemData/dictionary.ts L9-60

镜像 JNPF 后端:
  - jnpf/.../controller/DictionaryTypeController.java L57 L168-169
  - jnpf/.../controller/DictionaryDataController.java L89 L257-258

验证 (在 tdd1 Batch 1 跑通):
  - PASS: 字典类型列表 (4 渲染字段 ⊆ 9 API 字段)
  - PASS: 字典数据列表 (4 渲染字段 ⊆ 6 API 字段)
  - PASS: 字典数据编辑表单 (6 渲染字段 ⊆ 8 API 字段)

用户拍板: 把'读 vue + 调 API'方法固化, 替代浏览器验证.

Co-Authored-By: Claude <[email protected]>
2026-06-27 17:26:01 +08:00

30 lines
1.4 KiB
TypeScript

/**
* commands/test/index.ts — test 父命令 (v0.11+ 新命名, 替代 testcase)
*
* 命名: 主命令 `dacli test` (短, 对齐 npm/pytest 惯例). 早期 v0.11+ 命名 testcase, 用户拍板简化为 test.
*
* 2 子命令覆盖:
* - run 跑 form API 测试 (POST/GET/PUT/DELETE, ~5s, 不需浏览器)
* - generate 生成浏览器 E2E 脚本 (playwright bash, 覆盖 vmodel bind bug)
*
* v0.11+ cleanup: 删 `check` (BS-52+6 盲点必查已被 webapi 镜像自动保证, 无需单独检查)
*
* 覆盖 vs 浏览器测试 (v0.11+ 闭环):
* - API 层: run 完全覆盖 (POST/GET/PUT/DELETE)
* - Schema 层: webapi 镜像自动保证 (BS-51/52/54)
* - 浏览器层: generate 生成脚本, 用户手动跑
* - 浏览器层手动: 仍保留 ssw-e2e-test 作为 visual regression
*/
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('测试能力 (v0.11+ NEW) — run form API + generate 浏览器脚本 + render 源码渲染验证, 3 子命令替代大部分浏览器测试')
cmd.addCommand(buildTestRunCommand())
cmd.addCommand(buildTestGenerateCommand())
cmd.addCommand(buildTestRenderCommand())
return cmd
}