Files
ssw-mvp/docs/e2e/cases/TC-PRODUCT_API-002.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

109 lines
4.7 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-PRODUCT_API-002 · 条件不满足时不能办理数据产品登记
* REQ-051 [FL-4.1] 反向/等价类 P0
*
* 前置:1. 通过已认证的调用方连接器调用"数据产品登记"接口可以正常打开
* 2. 已准备无权限账号或错误数据
* 步骤:1. 打开通过已认证的调用方连接器调用"数据产品登记"接口
* 2. 使用无权限账号或错误数据办理数据产品登记
* 3. 点击提交,查看提示和数据
* 预期:系统不允许办理数据产品登记,并说明原因。原有数据和状态不变。
*
* 注:反向用例覆盖 DataProductController.beforeSave 的 4 个硬校验:
* ① 缺 productCode / name / spaceId / providerConnectorId
* ② productCode > 65 位被拒(国标 C 开头编码长度上限)
* ③ productCode 重复被拒(空间内唯一)
* ④ 不存在的 spaceId / providerConnectorId 不影响校验(仅校验非空),所以一并核对脏数据。
*/
export const meta = {
tc: 'TC-PRODUCT_API-002',
req: 'REQ-051',
title: '条件不满足时不能办理数据产品登记',
type: '反向/等价类',
priority: 'P0',
route: '/tds/products',
needs: ['be']
}
export async function run(t) {
let before = 0
await t.step('前置:登录并记录原始产品条数', async () => {
await t.login()
const list = await t.apiList('/api/ssw/tds/DataProduct', { pageSize: 100 })
before = list.length
t.assert(true, `操作前产品共 ${before} 条`)
})
await t.step('反向 1:缺产品标识被拒', async () => {
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
name: '缺产品标识',
spaceId: 'x',
providerConnectorId: 'y'
})
t.assert(res.code !== 200, `缺 productCode 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/产品标识|不能为空/.test(res.msg || ''), `提示指向产品标识(${res.msg})`)
})
await t.step('反向 2:缺产品名称被拒', async () => {
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode: t.uid('E2E-PROD'),
spaceId: 'x',
providerConnectorId: 'y'
})
t.assert(res.code !== 200, `缺 name 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/产品名称|不能为空/.test(res.msg || ''), `提示指向产品名称(${res.msg})`)
})
await t.step('反向 3:缺所属空间被拒', async () => {
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode: t.uid('E2E-PROD'),
name: '缺空间',
providerConnectorId: 'y'
})
t.assert(res.code !== 200, `缺 spaceId 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/所属空间|不能为空/.test(res.msg || ''), `提示指向所属空间(${res.msg})`)
})
await t.step('反向 4:缺提供方连接器被拒', async () => {
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode: t.uid('E2E-PROD'),
name: '缺连接器',
spaceId: 'x'
})
t.assert(res.code !== 200, `缺 providerConnectorId 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/提供方连接器|不能为空/.test(res.msg || ''), `提示指向提供方连接器(${res.msg})`)
})
await t.step('反向 5:产品标识超 65 位被拒', async () => {
const longCode = 'C' + 'x'.repeat(70) // 71 位
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode: longCode,
name: '超长标识',
spaceId: 'x',
providerConnectorId: 'y'
})
t.assert(res.code !== 200, `超长 productCode 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/长度不得|65/.test(res.msg || ''), `提示说明长度上限(${res.msg})`)
})
await t.step('反向 6:产品标识重复被拒', async () => {
// 先拿一条已有产品,复制它的 productCode 再提交
const list = await t.apiList('/api/ssw/tds/DataProduct', { pageSize: 50 })
const existing = list[0]
if (!existing) t.skip('库中无产品,无法测重复')
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode: existing.productCode,
name: '重复标识-测评',
spaceId: existing.spaceId || 'x',
providerConnectorId: existing.providerConnectorId || 'y'
})
t.assert(res.code !== 200, `重复 productCode 被拒(code=${res.code}, msg=${res.msg})`)
t.assert(/产品标识已存在/.test(res.msg || ''), `提示说明标识已存在(${res.msg})`)
})
await t.step('核对原有记录未被篡改', async () => {
const after = (await t.apiList('/api/ssw/tds/DataProduct', { pageSize: 100 })).length
t.assert(after === before, `产品条数不变(${before} → ${after}),未产生脏数据`)
})
}