Files
dacli/tests/e2e/_tds1_flow.mjs
T
sswandClaude a5063bb115 fix(blindspot): BS-5 + BS-47 false-positive (jxcj 28 form 重跑实战)
- BS-5: 仅 ctx 完全缺失时阻塞, 不再因 existingEnCodes.length===0 误报
  (场景: 全删 form 后重建, AppContext 仍有但 list 空, 旧逻辑会无限循环阻断)
- BS-47: 仅 dict typeCreate 命令触发, 不再在 menu create 时误判
  (场景: menu enCode 与 form enCode 共享合法, 但 BS-47 把 form enCode 看作 dict 冲突)

Co-Authored-By: Claude <[email protected]>
2026-06-22 23:42:47 +08:00

106 lines
4.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// tds1 数据流通标准流程测试 — 6 步端到端
import { chromium } from 'playwright'
const browser = await chromium.launch({ headless: true })
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } })
const FLOW_STEPS = [
{ key: 'identity', title: '1. 身份注册申请', expected: 'tds_user_apply' },
{ key: 'space', title: '2. 逻辑空间创建', expected: 'tds_space_v3' },
{ key: 'connector', title: '3. 连接器注册认证', expected: 'tds_connector_v3' },
{ key: 'product', title: '4. 数据产品登记', expected: 'tds_product_v3' },
{ key: 'contract', title: '5. 数字合约签订', expected: 'tds_contract_v3' },
{ key: 'control', title: '6. 数据使用控制', expected: 'tds_policy_template_v3' },
]
const results = []
try {
await page.goto('http://nginx/ssw/tds1/dashboard.html', { waitUntil: 'domcontentloaded' })
await page.waitForTimeout(3000)
// 点击"数据流通流程" tab
await page.evaluate(() => {
const tabs = Array.from(document.querySelectorAll('.nav-tab'))
for (const t of tabs) if ((t.textContent || '').trim() === '数据流通流程') { t.click(); return }
})
await page.waitForTimeout(1500)
await page.screenshot({ path: '/home/ubuntu/ccWorkDir/docs/tds1/screenshots/flow_01_initial.png', fullPage: true })
// 检查初始 6 步 label 可见
const initialLabels = await page.evaluate(() => {
return Array.from(document.querySelectorAll('.step-title')).map(el => (el.textContent || '').trim())
})
console.log('初始 6 步:', JSON.stringify(initialLabels))
// 点击"开始流程"按钮
await page.evaluate(() => {
const btns = Array.from(document.querySelectorAll('button'))
for (const b of btns) {
const t = (b.textContent || '').trim()
if (t === '开始流程' || t === '开始' || t.includes('开始流程')) {
b.click()
return true
}
}
return false
})
console.log('已点击"开始流程"')
// 等 6 步跑完(每步 800ms + 一些缓冲 = 6s)
await page.waitForTimeout(7000)
// 截图完成状态
await page.screenshot({ path: '/home/ubuntu/ccWorkDir/docs/tds1/screenshots/flow_02_completed.png', fullPage: true })
// 验证每个 step 完成状态
for (const step of FLOW_STEPS) {
const stepState = await page.evaluate((title) => {
const titles = Array.from(document.querySelectorAll('.step-title'))
for (const t of titles) {
if ((t.textContent || '').trim() === title) {
const stepDiv = t.closest('.flow-step')
const numDiv = stepDiv?.querySelector('.step-num')
const detailDiv = stepDiv?.querySelector('.step-detail')
return {
classes: stepDiv?.className || '',
numText: (numDiv?.textContent || '').trim(),
detailText: (detailDiv?.textContent || '').trim(),
}
}
}
return null
}, step.title)
const isDone = stepState?.classes.includes('done') || stepState?.numText === '✓'
const detailOK = stepState?.detailText?.includes(step.expected) || (stepState?.detailText?.length || 0) > 20
const passed = isDone && detailOK
results.push({
step: step.key,
title: step.title,
passed,
isDone,
detail: stepState?.detailText,
})
console.log(`${passed ? '✓' : '✗'} ${step.title}: classes=${JSON.stringify(stepState?.classes)} num=${stepState?.numText} len=${stepState?.detailText?.length} detail="${stepState?.detailText}" expected=${step.expected}`)
}
// 检查流程日志
const flowLogs = await page.evaluate(() => {
return Array.from(document.querySelectorAll('.flow-log div')).map(el => el.textContent || '')
})
console.log(`\n流程日志 ${flowLogs.length} 条:`)
for (const log of flowLogs) console.log(` ${log}`)
console.log('\n=== 汇总 ===')
const passed = results.filter(r => r.passed).length
console.log(`共 ${results.length} 步骤, 通过 ${passed}, 失败 ${results.length - passed}`)
for (const r of results) console.log(` ${r.passed ? '✓' : '✗'} ${r.title}`)
process.exit(passed === results.length ? 0 : 1)
} finally {
await browser.close()
}