Files
claude-config/skills/ssw-e2e-test
sswandClaude ab5502aa46 feat(test): 文档化 dacli test render 源码渲染验证 (替代浏览器验证)
用户拍板: 把 06-27 Batch 1 字典验证的'读 vue + 调 API'方法
固化到 dacli test render 子命令, 替代浏览器验证.

新增子命令 (2026-06-27):
  dacli test render --module=dict [--typeId=X] [--id=Y]

算法 (镜像 web 端渲染契约, 替代浏览器验证):
  - @vue/compiler-sfc 解析 web/.../sysData/dictionary/*.vue
  - list mode: 提取 BasicColumn[].dataIndex
  - form mode: 提取 useForm({schemas:[{field}]}).field
  - 调对应 API (DictionaryType / DictionaryData/{typeId})
  - 对比: 渲染字段 ⊆ API 字段 ? PASS : FAIL
  - 4 个页面覆盖: 类型列表 / 类型编辑 / 数据列表 / 数据编辑

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

源码镜像 (web 端):
  - 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 (4 API)

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

阶段 5 测试 (v0.11+ 推荐):
  - API 层: dacli test run (~5s)
  - 源码渲染层: dacli test render (~2s) ★ 新
  - Schema 层: webapi 镜像自动保证
  - 浏览器层: ssw-e2e-test (visual regression)

Co-Authored-By: Claude <[email protected]>
2026-06-27 17:24:54 +08:00
..
2026-05-18 09:28:27 +08:00
2026-05-18 09:28:27 +08:00
2026-05-18 09:28:27 +08:00

SSW E2E Test Skill

E2E testing toolkit for jnpf low-code platform using Playwright.

Installation

Prerequisite: Install webapp-testing skill first (ssw-e2e-test extends it):

# Clone webapp-testing skill
cd ~/.claude/skills
git clone https://github.com/anthropics/skills.git temp_skills
cp -r temp_skills/skills/webapp-testing .
rm -rf temp_skills

# Or manually download from:
# https://github.com/anthropics/skills/tree/main/skills/webapp-testing

Configuration

IMPORTANT: All configuration is via environment variables. Do not hardcode values.

# Required
export JNPF_HOST="192.168.1.18:13880"      # jnpf server address
export JNPF_APP_CODE="dr"                    # app code (dr, workSystem, etc.)
export JNPF_USERNAME="admin"                 # username
export JNPF_PASSWORD="123456"               # password

# Optional
export JNPF_TEMP_DIR="/tmp/jnpf_test"       # temp directory

Structure

ssw-e2e-test/
├── SKILL.md           # Main skill documentation
├── README.md          # This file
├── LICENSE.txt       # MIT License
├── scripts/
│   ├── config.py          # Configuration loader (env vars)
│   ├── dacli_web_session.py  # Web session login/restore (v0.11+ 保留)
│   ├── jnpf_browser_e2e.py   # Browser E2E helper (v0.11+ 保留)
│   ├── lib/                  # TS/Python 双语言标准库 (v0.11+ 保留)
│   └── with_server.py     # Server lifecycle (from webapp-testing)
├── examples/
│   ├── real_crud_test.py       # Full CRUD workflow
│   ├── use_vxe_selectors.py     # vxe-table selector patterns
│   ├── explore_login_and_menu.py # Login + menu exploration
│   └── analyze_add_modal.py     # Form field analysis
└── docs/
    └── 平台测试方法.md          # Platform testing methodology

Quick Start

from scripts.config import get_config
from scripts.jnpf_client import JnpfClient

# Load configuration
config = get_config()

# Use client
with JnpfClient() as client:
    client.login()
    client.click_menu("数据资产台账")
    client.crud.add("资产名称", "测试数据")

Run Examples

# Set environment variables first
export JNPF_HOST="192.168.1.18:13880"
export JNPF_APP_CODE="dr"
export JNPF_USERNAME="admin"
export JNPF_PASSWORD="123456"

# Run CRUD test
python examples/real_crud_test.py

# Run menu exploration
python examples/explore_login_and_menu.py

Key Patterns

Pattern Selector
vxe-table rows .vxe-body--row
Modal form .ant-modal
Delete confirm .ant-modal-confirm
Menu items .jnpf-menu-item
Click hidden element page.evaluate('el => el.click()', handle)
Dropdown (ant-select) .ant-select + .ant-select-dropdown:visible
Form field by ID input#f_field_name
Form field by label input[fullname="字段名称"]

API Testing

Token 通过 UI 登录自动获取,然后可用于 API 请求:

# See docs/api-testing.md for full API patterns
import os
from docs.api_testing import JnpfApiClient

# 方式1: 自动 UI 登录获取 token
client = JnpfApiClient.from_ui_login(
    host=os.environ["JNPF_HOST"],
    app_code=os.environ["JNPF_APP_CODE"]
)

# 方式2: 手动传入已获取的 token
client = JnpfApiClient(
    host=os.environ["JNPF_HOST"],
    app_code=os.environ["JNPF_APP_CODE"],
    token="bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
)

# API 查询
result = client.query_list(model_id, menu_id)
print(f"Total: {result['data']['pagination']['total']}")

Hybrid approach: Use UI for login/navigation, API for data operations.

Critical Patterns Discovered Through Testing

1. Dropdown Selection (ant-select)

# Click the dropdown trigger
page.evaluate('el => el.click()', selects[0].element_handle())
time.sleep(1)

# Wait for and click the option
dropdown = page.locator('.ant-select-dropdown:visible')
dropdown.first.locator('.ant-select-item').nth(0).click()

2. Form Field Identification

# Fields have fullname attribute with Chinese label
input#f_asset_name
input#f_category_code
input#f_applicant

# Or use placeholder
input[placeholder="请输入申请人"]

3. Save Success Detection

# CRITICAL: Check BOTH modal closed AND data saved
initial_count = page.locator('.vxe-body--row').count()
save_btn.click()
time.sleep(3)

modal_closed = page.locator('.ant-modal').count() == 0
data_saved = page.locator('.vxe-body--row').count() > initial_count

if not modal_closed and data_saved:
    # This happens! Modal stays open but data IS saved
    print("Save succeeded but modal didn't close")

Known Issues

Issue Workaround
Dropdown click intercepted Use JS click via page.evaluate()
Modal doesn't close after save Check data saved, not just modal state
Unknown form field IDs Use fullname attribute or explore modal first
Partial menu text matches many Use exact menu name

Dependencies

  • playwright
  • Python 3.8+