Files
ssw-mvp/docs/e2e/cases/TC-PLATFORM-004.mjs
T
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

84 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.
/**
* TC-PLATFORM-004 · 重复办理数据产品封装时不会重复处理
* REQ-036 [FL-10.1] 反向/状态迁移 P1
*
* 前置:已存在一条可以办理的数据产品封装记录。
* 步骤:1. 正常办理一次数据产品封装
* 2. 再次提交相同操作
* 3. 查看状态、列表和相关记录
* 预期:第一次按正常流程处理;第二次不会生成重复数据,状态和相关记录正确。
*
* 注:产品的「办理」以「发布到 TDS」动作为代表(DRAFT → PUBLISHING → PUBLISHED)。
* 第二次发布同一产品应被「产品已提交或已发布」拒绝。
*/
export const meta = {
tc: 'TC-PLATFORM-004',
req: 'REQ-036',
title: '重复办理数据产品封装时不会重复处理',
type: '反向/状态迁移',
priority: 'P1',
route: '/tdc/products',
needs: ['fe', 'be']
}
export async function run(t) {
let target = null
let resource = null
const code = `E2E-DUP-${t.runId}`
const name = `重复办理-${t.runId}`
await t.step('前置:登录并挑一条 DRAFT 产品作「重复办理」目标', async () => {
await t.login()
const all = await t.apiList('/api/ssw/tdc/Product', { pageSize: 50 })
target = all.find((r) => r.publishStatus === 'DRAFT')
if (!target) {
// 没现成的 DRAFT,先建一个
const res = await t.apiList('/api/ssw/tdc/Resource', { pageSize: 50 })
resource = res[0]
if (!resource) t.skip('库里既没有 DRAFT 产品,也没有可绑定的资源,跳过')
const r = await t.api('POST', '/api/ssw/tdc/Product', {
productCode: code,
name,
resourceId: resource.id,
publishStatus: 'DRAFT'
})
t.assert(r.code === 200, `新建 DRAFT 产品成功(实际 code=${r.code})`)
target = (await t.apiList('/api/ssw/tdc/Product', { keyword: code }))[0]
}
t.assert(true, `已就绪产品:${target.productCode} / publishStatus=${target.publishStatus}`)
})
await t.step('第一次发布:DRAFT → PUBLISHING', async () => {
// 发布需指定目标可信数据空间(tdsSpaceId)与提供方连接器
const tdsSpaces = await t.apiList('/api/ssw/tds/Space', { pageSize: 10 })
const tsid = tdsSpaces[0]?.id
const conns = await t.apiList('/api/ssw/tds/Connector', { pageSize: 20 })
const pcid = target.providerConnectorId || conns.find((c) => c.type === 'BOTH' || c.type === 'PROVIDER')?.id
const r = await t.api('PUT', `/api/ssw/tdc/Product/${target.id}/Publish`, {
productCode: target.productCode || ('E2E-PUB-' + t.runId),
spaceId: target.spaceId || tsid,
providerConnectorId: pcid || 'con-x',
providerOrgName: target.providerOrgName || '尚数网',
tdsSpaceId: target.tdsSpaceId || tsid
})
t.assert(r.code === 200, `首次 Publish 返回 200(实际 code=${r.code} msg=${r.msg})`)
const row = (await t.apiList('/api/ssw/tdc/Product', { keyword: target.productCode })).find((r) => r.id === target.id)
t.assert(row.publishStatus === 'PUBLISHING', `首次发布后状态为 PUBLISHING(实际 ${row.publishStatus})`)
})
await t.step('第二次发布同一产品:应被「产品已提交或已发布」拒绝', async () => {
const r = await t.api('PUT', `/api/ssw/tdc/Product/${target.id}/Publish`, {
tdsSpaceId: target.tdsSpaceId ?? ''
})
t.assert(r.code !== 200, `重复 Publish 被拒(实际 code=${r.code})`)
t.assert(/已提交|已发布|失败/i.test(r.msg || ''), `错误信息说明原因(实际「${r.msg}」)`)
// 状态保持不变(未被错误修改)
const row = (await t.apiList('/api/ssw/tdc/Product', { keyword: target.productCode })).find((r) => r.id === target.id)
t.assert(row.publishStatus === 'PUBLISHING', `二次拒绝后状态仍为 PUBLISHING(实际 ${row.publishStatus})`)
// 不应产生重复数据
const all = await t.apiList('/api/ssw/tdc/Product', { keyword: target.productCode })
t.assert(all.filter((r) => r.productCode === target.productCode).length === 1, `产品记录唯一,未产生重复数据`)
})
t.expectConsoleClean()
}