From 79939bb647158c3db44263640d7dbbae7e807f32 Mon Sep 17 00:00:00 2001 From: ssw Date: Sun, 12 Jul 2026 16:56:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(TC-B):=20v0.21+=20Ant=20Design=20selector?= =?UTF-8?q?=20+=20=E7=BB=93=E6=9E=84=E6=96=AD=E8=A8=80=20(=E6=97=A0?= =?UTF-8?q?=E6=88=AA=E5=9B=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TC-B 验证 (workSystem, 5 form, 2026-07-12): - v1 (Element Plus selector): 0/5 PASS (selector 错) - v2 (Ant Design selector): 4/5 PASS (方法可行) 关键发现: - JNPF 6.x 用 Ant Design Vue (.ant-* class), 不是 Element Plus (.el-*) - formId (base_visual_dev) 跟 menuId (base_module) 不同 - 结构断言 (webapi 预测 + DOM 查询 + 对比) 可替代截图 md5 比对 - 完整脚本: /tmp/dacli-loop/tc-b-structural.py (250 行, 5 form 端到端) doc 更新: - §7 加 4 个子节 (7.1 Ant Design selector, 7.2 结构断言, 7.3 formId/menuId, 7.4 实测 4/5 PASS, 7.5 截图保留场景) - §5 反模式表加 Element Plus -> Ant Design 行 - §8 footer 加 v0.21+ 升级段 (6 条关键修正) --- .../references/tc-ab-real-test.md | 110 +++++++++++++++++- 1 file changed, 108 insertions(+), 2 deletions(-) diff --git a/skills/ssw-e2e-test/references/tc-ab-real-test.md b/skills/ssw-e2e-test/references/tc-ab-real-test.md index 175802e..baa7cfa 100644 --- a/skills/ssw-e2e-test/references/tc-ab-real-test.md +++ b/skills/ssw-e2e-test/references/tc-ab-real-test.md @@ -536,6 +536,7 @@ echo "✓ 删除前 $BEFORE_ITEMS → 删除后 $AFTER_ITEMS (期望 -1)" | **v0.14: `addInitScript "jnpf_access-token"` 注入 (JNPF 6.x 失效, AES 加密)** | **v0.20+: storage snapshot 注入 (一次性 login 拿 snapshot 复用)** | | **v0.14: sidebar click 走 SPA 内部 (1-2s 额外)** | **v0.20+: 直接 goto 真实 URL (含 suffix, 0s 额外)** | | **TC-B 跑 testspace (误判: SPA 路由全废)** | **实际: testspace 路由正常, 是 URL 不对 (`model/test1` vs 真实 `model/test1fbc1b`). 见 §8 v0.20+ 修正.** | +| **v0.20-: 用 Element Plus selector (`.el-input` / `.el-select`)** | **v0.20+: JNPF 6.x 用 Ant Design (`.ant-input` / `.ant-select`). 见 §7.1.** | | **大屏用 `/model/{enCode}` URL (大屏不走主 webapp)** | **大屏用 `/list` URL (独立子项目 `jnpf-web-datascreen-vue3`)** | --- @@ -636,14 +637,111 @@ ROWS=$(playwright -s={app_code} eval "() => document.querySelectorAll('tr').leng --- -## 7. 4 铁律 + 截图去重 (关卡 B 检测) +## 7. 4 铁律 + 结构断言 (关卡 B 检测, v0.20+) | 铁律 | 检测方式 | 实战通过条件 | |---|---|---| | 1. 按钮存在性 | `document.querySelectorAll('button')` 含 "新增" | addBtns≥1 | | 2. 跳过 modal ≠ PASS | 真实打开 modal + 关闭 (不构造数据) | modalOpen=true 后能关闭 | | 3. CREATE failed ≠ PASS | webapi 构造 + 浏览器验证可见 (hasNewRow=true) | rows ≥ 1 | -| 4. 截图去重 (md5 不全相同) | 4 张截图 md5 比较 | 4/4 md5 唯一 | +| 4. **结构断言 (v0.20+ 替代截图去重)** | webapi 预测 vs 浏览器 DOM 实际对比 | expected components ⊆ actual components | + +### 7.1 v0.20+ JNPF 6.x 关键修正: 用 Ant Design, 不是 Element Plus + +> **⚠️ 重要**: JNPF 6.x 前端用 **Ant Design Vue** (`ant-` 前缀), 不是 Element Plus (`el-` 前缀). 错用 selector 会导致所有断言 0 个 component 匹配. + +| 控件 | Ant Design selector (正确) | Element Plus selector (错) | +|------|---------------------------|----------------------------| +| input | `.ant-form-item input.ant-input` | `.el-input` | +| select | `.ant-form-item .ant-select` | `.el-select` | +| date | `.ant-form-item .ant-picker` | `.el-date-editor` | +| switch | `.ant-form-item .ant-switch` | `.el-switch` | +| radio | `.ant-form-item .ant-radio-wrapper` | `.el-radio` | +| checkbox | `.ant-form-item .ant-checkbox-wrapper` | `.el-checkbox` | +| textarea | `.ant-form-item textarea.ant-input` | `.el-textarea` | +| inputNumber | `.ant-form-item .ant-input-number` | `.el-input-number` | +| upload | `.ant-form-item .ant-upload` | `.el-upload` | +| relationForm | `.ant-form-item .jnpf-relation-form` | (无对应) | +| organizeSelect | `.ant-form-item .jnpf-organize-select` | (无对应) | +| popupSelect | `.ant-form-item .jnpf-popup-select` | (无对应) | +| popupTable | `.ant-form-item .jnpf-popup-table` | (无对应) | +| rate | `.ant-form-item .ant-rate` | `.el-rate` | +| editor | `.ant-form-item .tox-tinymce` / `.ant-form-item .monaco-editor` | `.el-editor` | +| form item container | `.ant-form-item` | `.el-form-item` | + +**实测** (workSystem, 5 form, 2026-07-12): v1 selector (`el-`) 0/5 PASS, v2 selector (`ant-`) 4/5 PASS. 唯一 diff 来自 `organizeSelect` 子 selector 还要更细. + +### 7.2 v0.20+ 结构断言 (无截图, 推荐) + +> **核心**: webapi 拿 form schema → 静态预测 jnpfKey → 浏览器查 DOM 实际 selector → 断言 expected ⊆ actual. 不用截图, 不用 md5, 可入 CI. + +```bash +# 1. webapi 拿 form schema (formId 来自 dacli form list) +FORM_ID=$(dacli form list --keyword= --json | jq -r '.data.list[0].id') +SCHEMA=$(dacli form info $FORM_ID --json) + +# 2. 拿真实 menu URL (含 8a3aa 后缀, 跟 formId 不同!) +MENU=$(curl -s "http://nginx/api/oauth/CurrentUser?systemCode=&isBackend=0" \ + -H "Authorization: $(dacli app context --json | jq -r .token)" | jq '.data.menuList') +REAL_URL=$(echo "$MENU" | jq -r '.. | objects | select(.enCode? | test(".*[0-9a-f]{6}$")) | .urlAddress' | head -1) + +# 3. 浏览器渲染 + 断言 +playwright -s= open "http://nginx/jnpf_app_/$REAL_URL" +playwright -s= click "button:has-text('新增')" # 进入 form 编辑页 + +EXPECTED='{ + "inputs": 3, "selects": 2, "dates": 1, "switches": 1 + // 来自 form schema 的 jnpfKey 统计 +}' +ACTUAL=$(playwright -s= eval '() => ({ + inputs: document.querySelectorAll(".ant-form-item input.ant-input").length, + selects: document.querySelectorAll(".ant-form-item .ant-select").length, + dates: document.querySelectorAll(".ant-form-item .ant-picker").length, + switches: document.querySelectorAll(".ant-form-item .ant-switch").length +})' --raw) + +# 4. 断言 (实际 ≥ 预期, 容差 ±2) +for k in inputs selects dates switches; do + EXPECTED_N=$(echo $EXPECTED | jq .$k) + ACTUAL_N=$(echo $ACTUAL | jq .$k) + test $ACTUAL_N -ge $((EXPECTED_N - 2)) || { echo "FAIL: $k expected=$EXPECTED_N actual=$ACTUAL_N"; exit 1; } +done +echo "✓ PASS" +``` + +### 7.3 formId vs menuId 区别 (v0.20+ 易踩坑) + +> **关键**: 这两个 ID 是不同的! +> - `dacli form list` 返 form id (来自 `base_visual_dev.f_id`) +> - `GET /api/oauth/CurrentUser` 返 menu id (来自 `base_module.f_id`) +> - 之前用错 → hesuanjiancedengji 解析失败 (`Data does not exist`) + +| 数据源 | 表 | 用法 | +|--------|---|------| +| `dacli form list --json` | `base_visual_dev` | **formId** for `dacli form info` | +| `dacli menu list --json` | `base_module` | menuId (enCode + urlAddress) | +| `CurrentUser.menuList[]` | `base_module` | **menuId + urlAddress** (含 suffix) | + +### 7.4 实测 4/5 PASS (workSystem, 2026-07-12) + +| Form | Schema fields | 实际 form items | 结构断言 | +|------|---------------|----------------|---------| +| hesuanjiancedengji | 9 | 12 | ✅ PASS | +| testcustomer | 11 | 16 | ⚠️ 1 diff (orgSelect 子 selector) | +| testreceivable | 7 | 15 | ✅ PASS | +| yaofangguanli | 17 | 20 | ✅ PASS | +| baomingguanli | 11 | 14 | ✅ PASS | + +→ 完整脚本 `/tmp/dacli-loop/tc-b-structural.py`, 5 form 4 PASS 1 close-call (selector 精度) + +### 7.5 截图保留场景 (不替代, 仅辅助) + +DOM 断言覆盖 **功能正确性**. 截图仍用于: +- **视觉回归** (CSS 变化, 文字断言抓不到) +- **调试** (看渲染细节) +- **Bug 留证据** (issue 报告附件) + +> 推荐: TC-B 默认结构断言 (快, 可入 CI), 截图仅在以下情况加: 视觉测试 + 调试 + 留证据. --- @@ -673,6 +771,14 @@ ROWS=$(playwright -s={app_code} eval "() => document.querySelectorAll('tr').leng 6. 实测: workSystem/hesuanjiancedengji TC-B 6.25s/form (含 storage 注入, 复用 snapshot) 7. 4 条 v0.20+ 新增反模式 (CurrentUser.menuList / storage snapshot / 真实 URL / workSystem) + v0.21+ 模板说明 (2026-07-12 升级, BS-NCPF-400 followup, JNPF 6.x Ant Design 修正): + 1. JNPF 6.x 用 **Ant Design Vue** (`.ant-input` / `.ant-select`), 不用 Element Plus (`.el-input` 等) + 2. formId 跟 menuId 不同 (formId 来自 base_visual_dev, menuId 来自 base_module) + 3. 结构断言 (webapi 预测 + DOM 实际) 替代截图 md5 比对 → 5 form 4 PASS 1 close-call + 4. selector map 见 §7.1 (15+ jnpfKey × Ant Design class) + 5. TC-B 默认结构断言 (可入 CI), 截图仅在视觉测试/调试/留证据时用 + 6. 实测脚本: `/tmp/dacli-loop/tc-b-structural.py` (250 行, 5 form 端到端) + v0.14+ 模板说明 (2026-07-01 升级): 1. jxcj1 干净子代理实战验证 (阶段 13, 2026-06-30) 2. v0.14+ 加速升级: webapi 准备 + 浏览器验证 (加速 3-5x, 用户原话强要求)