diff --git a/CLAUDE.md b/CLAUDE.md index 75b38f4..9ee5afe 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -46,7 +46,7 @@ **新会话 4 步** (跨项目通用): ```bash alias dacli='npx tsx $ccWorkDir/dacli/src/cli.ts' # 一次性, 写进 ~/.bashrc -dacli app login --account=admin --password=123456 --appCode=developSystem +dacli app login --account=admin --password=123456 --appCode=testspace # 统一测试场 (developSystem/workSystem 是 JNPF 只读 baseline, 禁止当测试场) dacli app context --json # 必看 dbLinkId / existingEnCodes dacli help # 22 父命令 / 116 子命令索引 ``` @@ -55,10 +55,11 @@ dacli help # 22 父命令 / 116 子 ## 当前应用 (app_code) -| # | 应用 | system_id | 说明 | -|---|------|-----------|------| -| 1 | **developSystem** | 664077319056394183 | 开发系统示例(21个表单/3个流程等) | -| 2 | **workSystem** | — | 工作系统示例(53个表单,含工作流) | +| # | 应用 | system_id | 说明 | 用途 | +|---|------|-----------|------|------| +| 1 | **testspace** | 841610403778660421 | 统一测试场 (本项目新创建, systemId 动态) | **测试场** — 新会话默认登录, 自由 CRUD, 不会污染业务数据 | +| 2 | **developSystem** | 664077319056394183 | JNPF 平台开发系统示例(21个表单/3个流程等) | ⚠️ **JNPF baseline** — 只读, **禁止当测试场** (查 schema/示范性功能用) | +| 3 | **workSystem** | — | JNPF 平台工作系统示例(53个表单,含工作流) | ⚠️ **JNPF baseline** — 只读, **禁止当测试场** (查 schema/示范性功能用) | --- @@ -141,7 +142,8 @@ jnpf-admin **仅支持 Java 8**,后端代码禁止使用 Java 11+ 特性(如 ### 13. 复现的盲点固化前先验证 - 发现重复出现的 bug / 盲点 → 想"固化到 dacli 命令或技能" -- **先在测试 app(developSystem / workSystem)或 tds 跑通验证** → 写最小复现命令 + 期望输出 +- **先在测试场 (testspace) 跑通验证** → 写最小复现命令 + 期望输出 +- **禁止用 developSystem / workSystem 验证** — 它们是 JNPF 平台只读 baseline, 改了会污染 dacli 0 差错基线 - 验证通过 → 才提交到 dacli 源码 / 技能主 SKILL.md - 没复现验证的"理论修复" → 不入主代码,只入 polish doc 备查 @@ -202,7 +204,7 @@ java -jar jnpf-admin/target/jnpf-admin-*.jar --spring.profiles.active=dev # dacli 使用(TS 版) alias dacli='npx tsx $ccWorkDir/dacli/src/cli.ts' cd $ccWorkDir/dacli && npm install # 首次需装依赖 -dacli app login --account=admin --password=123456 --appCode=developSystem +dacli app login --account=admin --password=123456 --appCode=testspace # 统一测试场, 不是 developSystem (baseline 只读) # E2E测试(playwright Node.js) cd $ccWorkDir/test && npx playwright test --project=chromium diff --git a/skills/dacli-ts/SKILL.md b/skills/dacli-ts/SKILL.md index f0da74e..ea9499d 100644 --- a/skills/dacli-ts/SKILL.md +++ b/skills/dacli-ts/SKILL.md @@ -496,7 +496,7 @@ dacli tool logs --level=error --lines=50 # 后端错误日志 dacli app init -- --appCode=X --restart # 自动 kill + nohup + 健康检查 + 重登 # 浏览器层 tdd 404 (nginx 代理阻塞) -dacli app switch --appCode=workSystem # 切到 workSystem 验证或仅做 API 验证 +dacli app switch --appCode=testspace # 切到 testspace 统一测试场验证 (不是 workSystem, 它是 JNPF 只读 baseline) ``` ## 📦 架构速记 diff --git a/skills/dacli-ts/examples/baseline/all.sh b/skills/dacli-ts/examples/baseline/all.sh index b10996e..2469a3c 100755 --- a/skills/dacli-ts/examples/baseline/all.sh +++ b/skills/dacli-ts/examples/baseline/all.sh @@ -14,11 +14,11 @@ # bash examples/baseline/all.sh --limit=3 # 只跑前 3 张 (调试) # bash examples/baseline/all.sh --full # 真 baseline clone (会动 tds, 用户手动跑) # -# 默认模式 (--skip-import 隐式): 仅在 developSystem/workSystem 上跑 form info + validate, -# 不动 tds 生产, 验证 API 0 错. 适合 CI / AI 自检 / 日常回归. +# 默认模式 (--skip-import 隐式): 仅在 developSystem/workSystem (JNPF 只读 baseline 源) 上跑 form info + validate, +# 不动 testspace 测试场, 验证 API 0 错. 适合 CI / AI 自检 / 日常回归. # -# 完整模式 (--full): 真实 export → import 到 tds → release → validate. **会动 tds 生产**, -# AI 助手严禁自动跑, 仅人类手动跑 + 确认 tds 可写入. +# 完整模式 (--full): 真实 export → import 到 testspace → release → validate. **会动 testspace**, +# AI 助手严禁自动跑, 仅人类手动跑 + 确认 testspace 可写入. # # 依赖: dacli CLI + python3 (无 jq 依赖) set -euo pipefail @@ -37,8 +37,8 @@ else fi # ========== 配置解析 ========== -TARGET_APP="tds" -SOURCE_APPS=("developSystem" "workSystem") +TARGET_APP="testspace" # 目标 app (统一测试场; 不要用 tds/业务 app, 改坏数据) +SOURCE_APPS=("developSystem" "workSystem") # 源 app = JNPF 只读 baseline (仅 form info / export 用, 不要写) LIMIT="" # 默认 SKIP_IMPORT=1 (API 0 错 only, 不动 tds 生产); 加 --full 跑真 baseline clone SKIP_IMPORT=1 @@ -50,7 +50,7 @@ while [ $# -gt 0 ]; do --target=*) TARGET_APP="${1#*=}"; shift ;; --limit=*) LIMIT="${1#*=}"; shift ;; --skip-import) SKIP_IMPORT=1; shift ;; - --full) SKIP_IMPORT=0; shift ;; # 真 baseline clone (export+import+release) + --full) SKIP_IMPORT=0; shift ;; # 真 baseline clone (export+import+release) 到 testspace -h|--help) sed -n '2,40p' "$0" | sed 's/^# \?//' exit 0 diff --git a/skills/dacli-ts/examples/baseline/template.sh b/skills/dacli-ts/examples/baseline/template.sh index 058c879..781ff8f 100644 --- a/skills/dacli-ts/examples/baseline/template.sh +++ b/skills/dacli-ts/examples/baseline/template.sh @@ -5,14 +5,14 @@ set -e # ========== 配置 (必改) ========== -APP_CODE="developSystem" # 源 app: developSystem | workSystem +APP_CODE="${APP_CODE:-}" # 源 app: developSystem | workSystem (JNPF 只读 baseline, 仅供复刻/查 schema, 不要改里面数据) ORIGINAL_ID="469065268790880645" # 源表单 id (从 dacli form list 查) ENCODE="leaveApply" # 源表单 enCode CLONE_ENCODE="${ENCODE}_clone" # 克隆 enCode (避免冲突) # ========== 可选配置 ========== SKIP_PLAYWRIGHT="${SKIP_PLAYWRIGHT:-0}" # 1=跳过浏览器验证 (调试用) -TARGET_APP="tds" # 目标 app (通常 tds) +TARGET_APP="${TARGET_APP:-testspace}" # 目标 app = 统一测试场 testspace (默认; 也可改 tds/业务 app) # ========== 1. 切到源 app, 导出 ========== echo "▶ [1/6] 导出 $APP_CODE / $ENCODE (id=$ORIGINAL_ID) ..." diff --git a/skills/dacli-ts/references/anti-patterns.md b/skills/dacli-ts/references/anti-patterns.md index 5a00723..3220345 100644 --- a/skills/dacli-ts/references/anti-patterns.md +++ b/skills/dacli-ts/references/anti-patterns.md @@ -197,8 +197,8 @@ dacli form update --enCode=资产 **正确**: ```bash -# baseline 只读, 调试全在 tds / 测试 app -dacli app switch --appCode=tds +# baseline 只读, 调试全在 testspace (统一测试场) +dacli app switch --appCode=testspace dacli form export --out=/tmp/test.json dacli form import /tmp/test.json --enCode=test dacli form update --enCode=资产 diff --git a/skills/dacli-ts/references/blindspots.md b/skills/dacli-ts/references/blindspots.md new file mode 100644 index 0000000..21c27ae --- /dev/null +++ b/skills/dacli-ts/references/blindspots.md @@ -0,0 +1,145 @@ +# dacli 已知盲点 (16 BS, 跨 appCode 通用, 2026-06-30 实战) + +> **v0.12+ 强约束**: 这是 jnpf 平台 + dacli 跨项目核心规范, AI 会话开始**自动加载**. 新 appCode 跑 ssw-loop 阶段 4 (执行) 前必读. +> +> **来源**: jxcj (28 form 实战) + jxcj1 (干净子代理 7 阶段实战, 阶段 13) + +--- + +## 1. P0 必修 (高 ROI, 影响所有 form) + +### BS-101: codegen 输出 model 文件 **package 路径错位** +- **症状**: codegen 给 `package ssw.jxcj.model.team;` (snake_case 子目录), 实际应平铺 `package ssw.jxcj.model;` +- **影响**: 27 form 全部要手动 sed 改 package (否则编译 NPE) +- **修复方案**: codegen 输出时统一用 mainClassName 作为目录 OR 强制平铺 `--flat-model` +- **jxcj 临时修复**: `sed -i 's/^package ssw.jxcj.model.[a-z_].*/package ssw.jxcj.model;/' */entity/*.java` + +### BS-102: codegen Entity 缺 `@TableId(type=IdType.ASSIGN_ID)` ✅ 自动化 +- **症状**: `@TableId(value = "f_id")` 缺 type → jnpf 雪花 ID 写入失败 → "Type handler was null on parameter mapping for property 'id'" +- **影响**: 27 form 全部 entity 需手动 sed +- **自动化**: `dacli form fix-entity --type=entity` (主仓命令, 阶段 9 沉淀) +- **jxcj 临时修复**: `for f in */entity/*.java; do sed -i '/@JSONField.*"f_id"/i @TableId(value = "f_id", type = IdType.ASSIGN_ID)' $f; done` + +### BS-103: codegen Service 调 `ServletUtil.getHeader("jnpf-origin")` 未做 null check ✅ 自动化 +- **症状**: `servletUtil.getHeader("jnpf-origin").equals("pc")` NPE +- **影响**: 浏览器外调 (curl/没有 jnpf-origin header) 100% 报"System abnormality" +- **自动化**: `dacli form fix-entity --type=biz` (主仓命令, 阶段 9 沉淀) +- **jxcj 临时修复**: 已在 27 ServiceImpl 用 sed 批量加 null check + +### BS-104: workflow id vs versionId 混淆 ✅ 自动化 +- **症状**: `dacli workflow list` 返 id=TemplateEntity.id, 但 launchFlow 用 id 报 "Process does not exist" +- **真正需要的 id**: TemplateJsonEntity.id (= FlowList 返的, 最新 version) +- **自动化**: `dacli workflow list` 加 `FLOW_ID` 列 (阶段 9 沉淀, 主仓) +- **使用**: + ```bash + FLOW_ID=$(dacli workflow list | grep sswtestwf01 | awk '{print $2}') + curl -X POST /api/visualdev/OnlineDev/{formId}/actionLaunchFlow \ + -d "{\"template\":\"$FLOW_ID\", ...}" + ``` + +--- + +## 2. P1 重要 (中 ROI, 需改 dacli 主仓) + +### BS-56: 字典 enCode 含下划线 ✅ 已固化 +- **症状**: 字典 enCode 含下划线 → step machine BS-56 校验失败 +- **修复**: 改 camelCase, e.g. `jxcjpublishstate` 不是 `jxcj_publish_state` +- **代码位置**: `dacli/src/commands/dict/_validate.ts` + +### BS-201: form update 后 `flowId` 字段**不存在** (后端 VisualdevEntity 不含) +- **症状**: `dacli form update --enableFlow=1 --flowId=xxx` 报"form 端无 flowId 字段" +- **正确流程**: `dacli workflow update --id= --enableMark=1` (自动绑 start node formId) +- **修复方案**: 报错信息应明确告诉用户正确路径 (jnpf 平台约束) + +### BS-202: tables 子目录 vs 平铺 (PascalCase vs snake_case) +- **症状**: 28 form 表是 snake_case (`competition_info`), jnpf-workable Insert 时表名来自 `t1.getTableName()`, 但 j62 实际表名要看 jnpf-visualdev 是否自动转 PascalCase +- **影响**: form list 报"Failed to add data" (建表用 PascalCase, jnpf-workable 找 snake_case) +- **修复方案**: codegen 时统一 PascalCase 表名 (跟 jnpf visualdev 默认行为一致) + +### BS-203: TC-A/B/C 术语混淆 +- **症状**: jnpf skill 文档没明确 TC-A/TC-B/TC-C 精确定义, AI 误用 TCC (Test Case Container) 当作"Test Case Browser" +- **修复方案**: dacli-ts/SKILL.md + ssw-loop/SKILL.md + ssw-e2e-test/SKILL.md 加 "TC-A/TC-B/TC-C 精确定义" 段 + +### BS-204: form create "category 不能为空" +- **症状**: 新会话必须查 crmOrder 通用 category (`8f65bbe3bce341c8b3625d93544a044a`) +- **自动化** (阶段 1 沉淀): `autoDeriveCategoryFromBusinessType` (workSystem→行政管理, jxcj→项目管理) +- **可强化**: 加 `--auto-category` 选项, 自动从 `businessType` 字典派生 + +--- + +## 3. P2 nice-to-have + +### BS-301: workflow `${auditUser}` 占位符解析 +- **症状**: codegen 时填的占位符, jnpf-workflow 流程启动时不解析 +- **修复方案**: codegen 时直接 hardcode admin userId 而不是占位符, 或加 `--assignee=` 选项 +- **jxcj 临时修复**: POST form data 时加 `f_auditUser: '349057407209541'` (admin userId) + +### BS-302: LaunchFlow 异步后 List total=0 +- **症状**: POST 返 200 + List 返 0 (异步未完成 / 写错库) +- **修复方案**: TC-B 加 `sleep 3` + retry list 3 次 + +### BS-303: form dbLinkId 配 stale (form 实际配 2070978720649048064 不存在) +- **症状**: form dbLinkId 是老 config 的 (已被 datamodel 删), jnpf-workable 找不到物理库 +- **修复方案**: codegen 后检查 form.dbLinkId, 提示用户更新到当前 dbLinkId +- **jxcj 临时修复**: `dacli form update --dbLinkId=2071492464356302848` (j62 业务库) + +--- + +## 4. P3 jxcj1 子代理新发现 (阶段 13, 2026-06-30) + +### BS-104 (P0): `dacli form info ` 报 "Data does not exist" +- **症状**: 跑 `dacli form info jxcj1statetype` 报 400 "Data does not exist", 即使 form 已建好 (state=1) +- **临时修复**: 用 `dacli form list` 拿 formId 后 `dacli form info {id}` +- **dacli 修复方案**: `dacli form info ` 应内部 fallback 到 enCode → id 转换 + +### BS-105 (P2): `dacli dict typeCreate --dbLinkId=...` 报 "unknown option" +- **症状**: `dacli dict typeCreate --enCode=... --dbLinkId=...` 报 "unknown option" +- **临时修复**: 移除 `--dbLinkId` 参数 (字典本就主库, 不需要 dbLinkId) +- **dacli 修复方案**: dict typeCreate 不应该有 `--dbLinkId` 选项, 应去除 + +### BS-106 (P2): `dacli menu create --pcParents=-1` 失败 +- **症状**: `dacli menu create --pcParents=-1` 报 "父菜单不存在" +- **临时修复**: 先建顶级父菜单 `dacli menu create --enCode=testModule --type=1 --icon=... --parentId=0` +- **dacli 修复方案**: `dacli menu create` 应自动建顶级父菜单 (如果 pcParents=0/-1) + +### BS-107 (P2): `dacli menu create` 警告 BS-37 (误报) +- **症状**: `dacli menu create --formId=...` 报 BS-37 "form 未挂菜单" (实际已挂) +- **临时修复**: 忽略, 挂完即消 +- **dacli 修复方案**: BS-37 检测逻辑有 bug, 应检测 form 是否已挂, 挂过则不报 + +### BS-108 (P2): `dacli menu create` 低级模式必传 --icon +- **症状**: 走低级模式 (type=3) 必传 --icon, 否则失败 +- **临时修复**: 传 `--icon="icon-ym icon-ym-module"` +- **dacli 修复方案**: 默认给个 icon (e.g. "icon-ym icon-ym-menu"), 让 --icon 可选 + +--- + +## 5. 自动化命令速查 (跨 appCode 通用) + +| BS | 自动化命令 | 备注 | +|---|---|---| +| BS-101 | (待 codegen 加 `--flat-model` 选项) | 暂用 sed | +| BS-102 | `dacli form fix-entity --type=entity` | 阶段 9 沉淀 ✅ | +| BS-103 | `dacli form fix-entity --type=biz` | 阶段 9 沉淀 ✅ | +| BS-104 | `dacli workflow list` 看 FLOW_ID 列 | 阶段 9 沉淀 ✅ | +| BS-56 | 字典 enCode 改 camelCase | 沉淀 | +| BS-201 | `dacli workflow update --id= --enableMark=1` | 沉淀 | +| BS-301 | POST form data 时加 `f_auditUser: 'admin userId'` | 沉淀 | +| BS-302 | TC-B 加 `sleep 3` + retry list 3 | 沉淀 | +| BS-303 | `dacli form update --dbLinkId=<正确 dbLinkId>` | 沉淀 | +| BS-104 | `dacli form list | grep enCode | awk` 拿 id | 待修 | +| BS-105 | 不用 `--dbLinkId` | 待修 | +| BS-106 | 先建顶级父菜单 | 待修 | +| BS-107 | 忽略 BS-37 警告 | 待修 | +| BS-108 | 传 `--icon="icon-ym icon-ym-module"` | 待修 | + +--- + + + \ No newline at end of file diff --git a/skills/dacli-ts/references/errors.md b/skills/dacli-ts/references/errors.md index 306fb3a..5a436eb 100644 --- a/skills/dacli-ts/references/errors.md +++ b/skills/dacli-ts/references/errors.md @@ -127,7 +127,7 @@ ## 15. 浏览器层 tdd 应用 404 **检查项** → **修复** -- `/api/oauth/Login` 返回 404(nginx 代理阻塞)→ 切到 workSystem 验证:`dacli app switch --appCode=workSystem` +- `/api/oauth/Login` 返回 404(nginx 代理阻塞)→ 切到 testspace 验证:`dacli app switch --appCode=testspace` (不是 workSystem, 它是 JNPF 只读 baseline) - 或仅做 API + 结构验证(不依赖浏览器) ## 16. `code 400 + JNPF 限流` @@ -166,8 +166,8 @@ sleep 30 # 3. 装浏览器 npx playwright install chromium -# 4. 切到 developSystem 兜底(避免 tds 阻塞) -PLAYWRIGHT_TARGET=developSystem npx playwright test +# 4. 切到 testspace 测试场(避免 tds 阻塞;禁止切到 developSystem/workSystem 改 baseline) +PLAYWRIGHT_TARGET=testspace npx playwright test ``` **预防**: 进 spec 前先 `curl http://127.0.0.1:13880/` 探活;不并发跑高耗时命令把 API 线程池占满。 @@ -247,8 +247,8 @@ await page.locator('button[type="primary"]').first().click() # 1. 看当前 app dacli app status -# 2. 切到正确 app -dacli app switch --appCode=developSystem +# 2. 切到正确 app (developSystem/workSystem 是 JNPF baseline, 改会污染) +dacli app switch --appCode=testspace # 统一测试场 # 3. 列全部(带 limit) dacli form list --pageSize=100 # TS v0.7+ 默认 100 diff --git a/skills/dacli-ts/references/platform-mechanisms.md b/skills/dacli-ts/references/platform-mechanisms.md index 62b87f2..6cd4e34 100644 --- a/skills/dacli-ts/references/platform-mechanisms.md +++ b/skills/dacli-ts/references/platform-mechanisms.md @@ -30,10 +30,11 @@ Header: App-Code: tds **当前应用清单**(CLAUDE.md): -| appCode | 说明 | -|---------|------| -| `developSystem` | 开发系统示例(21 表单/3 流程,只读) | -| `workSystem` | 工作系统示例(53 表单,含工作流,只读) | +| appCode | 用途 | 说明 | +|---------|------|------| +| `testspace` | ✅ **测试场** | 项目统一测试场, 新会话默认登录, 自由 CRUD 不会污染业务 | +| `developSystem` | ⚠️ **JNPF baseline** | 开发系统示例(21 表单/3 流程, **只读, 禁止当测试场**) | +| `workSystem` | ⚠️ **JNPF baseline** | 工作系统示例(53 表单, 含工作流, **只读, 禁止当测试场**) | --- @@ -79,7 +80,7 @@ JNPF 后端在以下 API 中自动通过 App-Code 解析并写入 systemId: | `--dbLinkId=default` | 强制主库(平台库,dbLinkId=0) | | `--dbLinkId=2056521674462703616` | 强制指定业务库 | -**多应用隔离**:`dacli app login --appCode=developSystem` 后 dbLinkId 自动指向 developSystem 业务库;切到 workSystem 自动切换。 +**多应用隔离**:`dacli app login --appCode=testspace` (新会话默认) 后 dbLinkId 自动指向 testspace 业务库;切到 developSystem/workSystem (JNPF baseline, 只读) 自动切换。 **⚠️ 涉及 dbLinkId 的命令**:`dacli dm create` / `dacli dm list` / `dacli form create` / `dacli di create`。 diff --git a/skills/dacli-ts/references/troubleshooting.md b/skills/dacli-ts/references/troubleshooting.md index 4ffa84d..e5c7e61 100644 --- a/skills/dacli-ts/references/troubleshooting.md +++ b/skills/dacli-ts/references/troubleshooting.md @@ -184,8 +184,8 @@ sleep 30 # 3. 装浏览器 npx playwright install chromium -# 4. 改用 developSystem 兜底 (不走 tds) -PLAYWRIGHT_TARGET=developSystem npx playwright test +# 4. 改用 testspace 测试场 (不走 tds; 禁止用 developSystem/workSystem 改 baseline) +PLAYWRIGHT_TARGET=testspace npx playwright test ``` --- @@ -253,8 +253,8 @@ await page.locator('button[type="primary"]').first().click() dacli app status # → 显示当前 app_code -# 切到正确 app -dacli app switch --appCode=developSystem +# 切到正确 app (developSystem/workSystem 是 JNPF baseline, 改会污染) +dacli app switch --appCode=testspace # 统一测试场 # 列所有 dacli form list --pageSize=100 diff --git a/skills/ssw-e2e-test/references/tc-ab-real-test.md b/skills/ssw-e2e-test/references/tc-ab-real-test.md new file mode 100644 index 0000000..449af5d --- /dev/null +++ b/skills/ssw-e2e-test/references/tc-ab-real-test.md @@ -0,0 +1,169 @@ +# TC-B 真实端到端实战模板 (jxcj1 阶段 13, 2026-06-30) + +> **v0.12+ 实战验证**: 这是 ssw-e2e-test skill 的 TC-B 实战模板, 来自 jxcj1 干净子代理 7 阶段跑通. 跨 appCode 通用. + +--- + +## 1. 真实 TC-B 5 步 (jxcj1 实战验证) + +### 步骤 1: 浏览器登录 jnpf-app + 拿 session token + +```bash +playwright -s={app_code} open http://nginx/jnpf_app_{app_code}/login +sleep 2 +playwright -s={app_code} fill "input#account" "admin" +playwright -s={app_code} fill "input[type='password']" "123456" +playwright -s={app_code} click "button:has(span:text-is('登 录'))" +sleep 5 +# 验证 +playwright -s={app_code} eval "() => document.title" --raw +# 期望: "首页 - {app_code}" (Vue 接管) +``` + +### 步骤 2: 调 currentUserInfo API 推路由 (jnpj-app 上下文) + +```bash +TOKEN=$(cat ~/.dacli-token/token.json | python3 -c "import json,sys;print(json.load(sys.stdin)['token'])") +# 调 jnpj-app 的 CurrentUser (systemCode={app_code}, isBackend=0) +curl -s "http://nginx/api/oauth/CurrentUser?systemCode={app_code}&isBackend=0" \ + -H "Authorization: $TOKEN" | python3 -c " +import json,sys +d=json.loads(sys.stdin.read()) +# 找 model/{enCode} 路由 +def find_model(menu): + out=[] + for m in menu: + url=str(m.get('urlAddress','')) + if 'model/' in url: + enc=url.split('model/')[-1] + out.append({'name':m.get('fullName'),'enCode':enc,'url':url}) + if m.get('children'): + out.extend(find_model(m['children'])) + return out +forms=find_model(d.get('data',{}).get('menuList',[])) +print(f'jxcj1 form 路由 ({len(forms)} 条):') +for f in forms[:3]: print(f' {f[\"name\"]} → {f[\"url\"]}')" +# 期望: 27+ form 路由 (model/{enCode}) +``` + +### 步骤 3: 真实点击 menu (触发 vue router 跳转) + +```bash +# 展开"大赛管理"父菜单 +playwright -s={app_code} click "aside >> text=大赛管理" +sleep 2 +# 点"参赛团队" (Vue router 跳转到 /model/teamXXX) +playwright -s={app_code} click "aside >> text=参赛团队" +sleep 4 +# 验证路由 + 渲染 +playwright -s={app_code} eval "() => JSON.stringify({ + url: location.href, + title: document.title, + asideCount: document.querySelectorAll('aside').length, + menuItems: document.querySelectorAll('aside a').length +})" --raw +# 期望: url 含 model/team, title="参赛团队 - {app_code}" +``` + +### 步骤 4: 检测真实 DOM 渲染 (Vue 接管) + +```bash +# 检测 list 页面 (table + rows + "新增" 按钮) +playwright -s={app_code} eval "() => JSON.stringify({ + tables: document.querySelectorAll('table').length, + rows: document.querySelectorAll('tr').length, + addBtns: [...document.querySelectorAll('button')].filter(b => /新增|添加/.test(b.textContent)).length, + rowsData: [...document.querySelectorAll('tr')].slice(1,3).map(r => r.textContent?.slice(0,50)) +})" --raw +# 期望: tables≥1, rows≥2 (含表头), addBtns=1 ("新增" 按钮) +``` + +### 步骤 5: 真实点击"新增" → 填表单 → 提交 (行数 +1) + +```bash +# 1. 点"新增" → 弹窗打开 +playwright -s={app_code} click "button:has-text('新增')" +sleep 2 +playwright -s={app_code} eval "() => JSON.stringify({ + modalTitle: document.querySelector('.ant-modal-title, .jnpf-modal-title')?.textContent, + inputs: document.querySelectorAll('.ant-modal input, .jnpf-modal input').length +})" --raw +# 期望: modalTitle="新增", inputs≥2 + +# 2. 填必填 (找第一个 input) +TS=$(date +%s) +playwright -s={app_code} fill ".ant-modal input[type='text']:first-of-type" "TC-B-${TS}" +sleep 1 + +# 3. 点"确定" → 弹窗关闭, list +1 +playwright -s={app_code} click ".ant-modal-footer button.ant-btn-primary" +sleep 3 +ROWS=$(playwright -s={app_code} eval "() => document.querySelectorAll('tr').length" --raw) +# 期望: rows +1 (真实业务数据持久化) +``` + +### 步骤 6: 截图去重 (4 铁律之一) + +```bash +# 截 4 张 (list / modal / filled / after) → md5 必须不全相同 +SHOTS=/home/ubuntu/ccWorkDir/docs/{app_code}/test_logs +mkdir -p $SHOTS +playwright -s={app_code} open http://nginx/jnpf_app_{app_code}/model/{enCode} +playwright -s={app_code} screenshot --filename $SHOTS/TC-{enCode}-1-list.png +playwright -s={app_code} click "button:has-text('新增')" +playwright -s={app_code} screenshot --filename $SHOTS/TC-{enCode}-2-modal.png +playwright -s={app_code} fill ".ant-modal input[type='text']:first-of-type" "test" +playwright -s={app_code} screenshot --filename $SHOTS/TC-{enCode}-3-filled.png +playwright -s={app_code} click ".ant-modal-footer button.ant-btn-primary" +playwright -s={app_code} screenshot --filename $SHOTS/TC-{enCode}-4-after.png +# 验证 md5 不全相同 +md5sum $SHOTS/TC-{enCode}-*.png +``` + +--- + +## 2. TC-B 反模式 (jxcj 2026-06-29 踩坑) + +| ❌ 反模式 | ✅ 正路 | +|---|---| +| `page.evaluate(async () => fetch('/api/...').then(r => r.json()))` 注入 fetch | 真实 click + 真实 DOM 检测 + 真实业务反馈 | +| 只看 API status code 200 | 真实 UI 状态 (行数 +1, 弹窗关闭, DOM 更新) | +| 不截图, 只 log | 截图 md5 去重 (4 张图, md5 不全相同) | +| 用 `eval "() => location.href"` 验证路由 | 真实点击 menu → 检测 vue 渲染 | +| 单 form 验证就报"全过" | 必须 form 0 + form 28 都跑 (jxcj 阶段 5 模式) | +| 跟 TC-A 一样用 fetch 调 API | TC-A 是 dacli test run, TC-B 是真实浏览器 | + +--- + +## 3. 4 铁律 + 截图去重 (关卡 B 检测) + +| 铁律 | 检测方式 | 实战通过条件 | +|---|---|---| +| 1. 按钮存在性 | `document.querySelectorAll('button')` 含 "新增" | addBtns≥1 | +| 2. 跳过 modal ≠ PASS | 真实打开 modal + 填表 + 提交 | 行数 +1 | +| 3. CREATE failed ≠ PASS | 真实 fetch + GET 反查 | hits≥1 | +| 4. 截图去重 (md5 不全相同) | 4 张截图 md5 比较 | 4/4 md5 唯一 | + +--- + +## 4. 跨 appCode 复用清单 + +| 资产 | 位置 | +|---|---| +| TC-B 真实 5 步 (本文档) | `references/tc-ab-real-test.md` | +| TC-A/B/C 精确定义 | `ssw-e2e-test/SKILL.md` | +| 关卡 C 接受新模板 | `ssw-loop/scripts/check_subagent_learnings.sh` | +| 16 盲点 (含 BS-104~BS-108) | `dacli-ts/references/blindspots.md` | +| jxcj1 实战跑通命令 | `ssw-loop/references/lessons-from-apps.md` | + +--- + + + \ No newline at end of file diff --git a/skills/ssw-e2e-test/scripts/config.py b/skills/ssw-e2e-test/scripts/config.py index 5d73358..eefcc01 100644 --- a/skills/ssw-e2e-test/scripts/config.py +++ b/skills/ssw-e2e-test/scripts/config.py @@ -20,8 +20,9 @@ import json from pathlib import Path # Default values +# APP_CODE 默认指向 testspace 统一测试场 (developSystem/workSystem 是 JNPF 只读 baseline, 禁止当测试目标) DEFAULT_BASE_URL = os.environ.get("JNPF_BASE_URL", "http://localhost:13880") -DEFAULT_APP_CODE = os.environ.get("JNPF_APP_CODE", "workSystem") +DEFAULT_APP_CODE = os.environ.get("JNPF_APP_CODE", "testspace") DEFAULT_USERNAME = os.environ.get("JNPF_USERNAME", "admin") DEFAULT_PASSWORD = os.environ.get("JNPF_PASSWORD", "123456") DEFAULT_TEMP_DIR = os.environ.get("JNPF_TEMP_DIR", "/tmp/jnpf_test")