Files
ssw-mvp/docs/e2e/cases/TC-CONTRACT_API-004.mjs
admin 3247e9fd15 init: ssw-mvp initial commit
- boot/ (Java/Maven, JNPF 7.0) — 移除旧的 boot/.git,源码直接纳入仓库
- web/ (Vue 3 + Vite + Ant Design Vue, pnpm)
- docs/, scard/, nax/
- refs/INDEX.md + refs/国标/(其余 refs/* 开源子仓库不纳入)
- 已忽略: connector_data/, jweb/, log/, web/{dist,node_modules,.pnpm}, boot/*/target/, .DS_Store, .idea, .vscode
2026-08-05 18:29:12 +08:00

59 lines
2.6 KiB
JavaScript
Raw Permalink 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.
/**
* TC-CONTRACT_API-004 · 重复办理合约签订时不会重复处理
* REQ-056 [FL-5.2] 反向/状态迁移 P1
*
* 前置:已存在一条可以办理的合约签订记录。
* 步骤:1. 正常办理一次合约签订
* 2. 再次提交相同操作
* 3. 查看状态、列表和相关记录
* 预期:第一次按正常流程处理;第二次不会生成重复数据,状态和相关记录正确。
*/
export const meta = {
tc: 'TC-CONTRACT_API-004',
req: 'REQ-056',
title: '重复办理合约签订时不会重复处理',
type: '反向/状态迁移',
priority: 'P1',
route: '',
needs: ['be']
}
export async function run(t) {
let created = null
let totalBefore = 0
await t.step('前置:取一条可签约的待签署合约(自带数据),并记录列表总数', async () => {
await t.login()
const before = await t.apiList('/api/ssw/tds/Contract', { pageSize: 1, currentPage: 1 })
totalBefore = before.length ? null : null // 不会真有 list.length=0,这里只用作对照
const pending = await t.apiList('/api/ssw/tds/Contract', { status: '01', pageSize: 5 })
if (!pending.length) t.skip('库中没有待签署合约,无法验证重复办理拦截')
created = pending[0]
t.assert(true, `选定合约 ${created.contractCode}(id=${created.id})`)
})
await t.step('提交首次签署(PROVIDER)应成功', async () => {
const r = await t.api('PUT', `/api/ssw/tds/Contract/${created.id}/Sign`, {
role: 'PROVIDER', signature: 'sig-p-' + t.runId
})
// 该合约可能已是 PROVIDER 已签过的(来自其他测试用例),允许「已签署」作为前置断言
if (r.code === 200) {
t.assert(r.data.providerSigned === true, 'PROVIDER 已签署')
} else {
t.assert(r.msg.includes('已签署'), `首次 PROVIDER 签署若已签过也应明确告知(${r.msg})`)
}
})
await t.step('再次以 PROVIDER 重复签署 → 应被「请勿重复签署」拒绝', async () => {
const r = await t.api('PUT', `/api/ssw/tds/Contract/${created.id}/Sign`, {
role: 'PROVIDER', signature: 'sig-p-dup'
})
t.assert(r.code === 400 || r.msg.includes('重复'), `重复签署被拒绝(code=${r.code} msg=${r.msg})`)
})
await t.step('列表条数未因重复操作而增加', async () => {
const list = await t.apiList('/api/ssw/tds/Contract', { keyword: created.contractCode })
const sameCode = list.filter((x) => x.contractCode === created.contractCode)
t.assert(sameCode.length === 1, `按标识过滤后只有 1 条(实际 ${sameCode.length}),未生成重复数据`)
})
}