- e2e: fix 9 failing cases (contract/hosting/delivery/usage/security); add dsl.createSandboxTask() self-provision helper; cli/runner now default headless, --ob opens visible browser - backend: tdc/tds controller adjustments (delivery, hosting, contract, chain-evidence, catalog, product, policy-conflict, etc.) - web: ssw views/components adjustments (contract, product, hosting, connector) - docs: AGENTS.md, e2e README; .gitignore; project memory update Excludes docs/e2e/results artifacts (screenshots + results.json).
134 lines
6.5 KiB
JavaScript
134 lines
6.5 KiB
JavaScript
/**
|
||
* TC-CONTRACT-007 · 正常办理合约签署
|
||
* REQ-012 [FL-5.2] 正向/场景法 P0
|
||
*
|
||
* 前置:1. 具备相应权限的平台运营方
|
||
* 2. 服务平台的【数字合约管理】可以正常打开
|
||
* 3. 已准备好测试数据
|
||
* 步骤:1. 打开服务平台的【数字合约管理】
|
||
* 2. 按页面提示填写或选择正确的数据
|
||
* 3. 点击提交,查看办理结果
|
||
* 预期:合约签署办理成功,系统按要求完成处理,状态和记录正确。
|
||
*
|
||
* 注:合约签署是状态机 01→02 的核心链路;技术协议要求签署响应延迟 ≤ 1 秒(signCostMs)。
|
||
* 现状:前端【数字合约管理】新建表单字段不包含 productId/providerConnectorId/consumerConnectorId,
|
||
* 后端 beforeSave 又要求这三项必填。所以用例先用 API 预置一条「待签署」合约,再走界面签署。
|
||
*/
|
||
export const meta = {
|
||
tc: 'TC-CONTRACT-007',
|
||
req: 'REQ-012',
|
||
title: '正常办理合约签署',
|
||
type: '正向/场景法',
|
||
priority: 'P0',
|
||
route: '/tds/contracts',
|
||
needs: ['fe', 'be']
|
||
}
|
||
|
||
export async function run(t) {
|
||
let contractId = null
|
||
let contractCode = null
|
||
let spaceId = null
|
||
|
||
await t.step('前置:登录、选空间、准备一条「待签署」合约', async () => {
|
||
await t.login()
|
||
await t.goto('/tds/contracts')
|
||
// SpacePicker option label 是「名称(编码)」但 DOM 只看到文案,
|
||
// 必须从 Space 列表里把 id 反查回来 —— 直接抠 DOM 文案当 id 写入会被后端
|
||
// 挂到一个「不存在的空间」上,页面按真实空间过滤再也查不到。
|
||
const sp = await t.pickSpaceRef()
|
||
if (!sp) t.skip('本页没有空间可选,跳过')
|
||
spaceId = sp.id
|
||
// 准备一条 product 与两个 connector 作为前置数据(合约依赖)
|
||
const code = t.uid('E2E-CON')
|
||
contractCode = code
|
||
// 真实环境通常这些都已有,先查库里有无;没有就走新建。
|
||
const products = await t.apiList('/api/ssw/tds/DataProduct', { pageSize: 5 })
|
||
const conns = await t.apiList('/api/ssw/tds/Connector', { pageSize: 20 })
|
||
const provider = conns.find((c) => (c.type === 'PROVIDER' || c.type === 'BOTH') && c.auditStatus === 'PASS')
|
||
const consumer = conns.find((c) => (c.type === 'CONSUMER' || c.type === 'BOTH') && c.auditStatus === 'PASS' && c.id !== provider?.id)
|
||
let productId = products[0]?.id
|
||
if (!productId) t.skip('库中没有任何数据产品,请先在【数据产品】页面准备一条')
|
||
if (!provider || !consumer) t.skip('库中缺少两个不同的 PASS 连接器(一个提供方一个使用方),无法签合约')
|
||
// 直接调接口新建待签署合约(表单缺 productId 等字段,不能走界面)
|
||
const r = await t.api('POST', '/api/ssw/tds/Contract', {
|
||
contractCode: code,
|
||
name: `E2E-合约签署-${t.runId}`,
|
||
spaceId,
|
||
productId,
|
||
productName: products[0].name,
|
||
providerConnectorId: provider.id,
|
||
providerOrgId: provider.orgId,
|
||
providerOrgName: provider.orgName,
|
||
consumerConnectorId: consumer.id,
|
||
consumerOrgId: consumer.orgId,
|
||
consumerOrgName: consumer.orgName,
|
||
purpose: 'E2E签署验证',
|
||
deliveryType: 'API',
|
||
priceMode: 'BY_CALL',
|
||
policyContent: '{"policies":[]}',
|
||
termsContent: 'E2E签署测试条款',
|
||
quotaTotal: 100
|
||
})
|
||
t.assert(r.code === 200, `API 预置合约成功(实际 code=${r.code} msg=「${r.msg}」)`)
|
||
contractId = r.data?.id || r.data
|
||
t.assert(!!contractId, `拿到合约 ID(${contractId})`)
|
||
})
|
||
|
||
await t.step('打开【数字合约管理】并按标识查询到该合约', async () => {
|
||
await t.resetQuery()
|
||
await t.refresh()
|
||
// 先看看列表当前实际显示的内容
|
||
const all = await t.readTable()
|
||
t.log(`查询前列表当前共 ${all.length} 行`)
|
||
await t.search(contractCode)
|
||
await t.waitIdle()
|
||
const after = await t.readTable()
|
||
t.log(`查询后列表共 ${after.length} 行,第一行内容预览:${after[0]?.slice(0, 5).join(' | ')}`)
|
||
await t.expectRow(contractCode)
|
||
await t.shot('签署前查询结果')
|
||
})
|
||
|
||
await t.step('提供方签署:触发状态机 01→01 并记录 signCostMs', async () => {
|
||
const r = await t.api('PUT', `/api/ssw/tds/Contract/${contractId}/Sign`, {
|
||
role: 'PROVIDER',
|
||
signature: `E2E-SIG-PROVIDER-${t.runId}`
|
||
})
|
||
t.assert(r.code === 200, `提供方签署成功(实际 code=${r.code} msg=「${r.msg}」)`)
|
||
t.assert(r.data?.providerSigned === true, `data.providerSigned=true`)
|
||
t.assert(typeof r.data?.signCostMs === 'number', `返回 signCostMs(${r.data?.signCostMs}ms)`)
|
||
t.assert(r.data?.signCostMs <= 1000, `签署响应延迟 ≤ 1 秒(SLA=1000ms,实际 ${r.data?.signCostMs}ms)`)
|
||
})
|
||
|
||
await t.step('使用方签署:双签生效 01→02', async () => {
|
||
const r = await t.api('PUT', `/api/ssw/tds/Contract/${contractId}/Sign`, {
|
||
role: 'CONSUMER',
|
||
signature: `E2E-SIG-CONSUMER-${t.runId}`
|
||
})
|
||
t.assert(r.code === 200, `使用方签署成功(实际 code=${r.code})`)
|
||
t.assert(r.data?.status === '02', `双签后状态流转为 02(实际 ${r.data?.status})`)
|
||
t.assert(r.data?.consumerSigned === true && r.data?.providerSigned === true, `双方均已签署`)
|
||
t.assert(r.data?.slaSatisfied === true, `签署 SLA 满足(slaSatisfied=${r.data?.slaSatisfied})`)
|
||
})
|
||
|
||
await t.step('核对落库:状态、signCostMs、内容哈希均已写入', async () => {
|
||
const info = await t.api('GET', `/api/ssw/tds/Contract/${contractId}`)
|
||
const d = info.data || {}
|
||
t.assert(d.status === '02', `落库 status=02(实际 ${d.status})`)
|
||
t.assert(typeof d.signCostMs === 'number' && d.signCostMs <= 1000, `落库 signCostMs ≤ 1000(${d.signCostMs})`)
|
||
t.assert(!!d.contentHash && d.contentHash.length === 64, `落库 contentHash(SHA-256,64 位;实际 ${d.contentHash?.length})`)
|
||
t.assert(!!d.providerSignature, `提供方签名已记录`)
|
||
t.assert(!!d.consumerSignature, `使用方签名已记录`)
|
||
})
|
||
|
||
await t.step('页面侧:刷新后状态显示为「已生效」', async () => {
|
||
await t.refresh()
|
||
await t.search(contractCode)
|
||
// 状态是 tag 类型,应显示「已生效」
|
||
const row = await t.readTable()
|
||
const target = row.find((cells) => cells.some((c) => c.includes(contractCode)))
|
||
t.assert(!!target, '列表仍能查到该合约')
|
||
t.assert(target.some((c) => c.includes('已生效')), `状态列显示「已生效」(实际行:${target?.slice(0, 6).join(' | ')})`)
|
||
})
|
||
|
||
t.expectConsoleClean()
|
||
} |