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

81 lines
3.9 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-001 · 正常办理数据产品登记
* REQ-051 [FL-4.1] 正向/场景法 P0
*
* 前置:1. 已绑定连接器的机构用户或已认证连接器
* 2. 通过已认证的调用方连接器调用"数据产品登记"接口可以正常打开
* 3. 已准备好测试数据
* 步骤:1. 打开通过已认证的调用方连接器调用"数据产品登记"接口
* 2. 按页面提示填写或选择正确的数据
* 3. 点击提交,查看办理结果
* 预期:数据产品登记办理成功,系统按要求完成处理,状态和记录正确。
*
* 注:后端 DataProductController.beforeSave 校验:
* 产品标识 / 产品名称 / 所属空间 / 提供方连接器 必填;
* 产品标识 65 位内;空间内唯一;默认 status/auditStatus=DRAFT、priceMode=FREE、deliveryType=API。
* 本用例以 API 方式直连后端建产品,断言业务流结果(落库、状态、默认值)。
*/
export const meta = {
tc: 'TC-PRODUCT_API-001',
req: 'REQ-051',
title: '正常办理数据产品登记',
type: '正向/场景法',
priority: 'P0',
route: '/tds/products',
needs: ['be']
}
export async function run(t) {
const productCode = t.uid('E2E-PROD')
const productName = `产品登记-测评-${t.runId}`
await t.step('前置:登录并取一个空间与一个提供方连接器', async () => {
await t.login()
const spaces = await t.apiList('/api/ssw/tds/Space', { pageSize: 10 })
const space = spaces.find((s) => s.status === 'ONLINE' || s.status === 'ENABLED') || spaces[0]
if (!space) t.skip('库中无任何空间,无法新建产品')
t._spaceId = space.id
const conns = await t.apiList('/api/ssw/tds/Connector', { pageSize: 50 })
const conn = conns.find((c) => c.auditStatus === 'PASS' && (c.status === 'ONLINE' || c.status === 'ENABLED'))
|| conns.find((c) => c.auditStatus === 'PASS')
|| conns[0]
if (!conn) t.skip('库中无任何连接器,无法新建产品(DataProductController 要求提供方连接器必填)')
t._connectorId = conn.id
})
await t.step('正向:按接口建一条数据产品', async () => {
const res = await t.api('POST', '/api/ssw/tds/DataProduct', {
productCode,
name: productName,
spaceId: t._spaceId,
providerConnectorId: t._connectorId,
category: '交通物流',
tags: 'e2e,测评',
deliveryType: 'API',
priceMode: 'FREE',
classifyLevel: 'INTERNAL',
desc: '产品登记正向用例'
})
t.assert(res.code === 200, `产品登记成功(code=${res.code}, msg=${res.msg || ''})`)
t._newId = res.data
})
await t.step('核对办理结果:列表可见 + 落库默认值正确', async () => {
const list = await t.apiList('/api/ssw/tds/DataProduct', { keyword: productCode, pageSize: 20 })
const row = list.find((r) => r.productCode === productCode)
t.assert(!!row, `关键字查询命中新建产品(id=${row?.id})`)
t.assert(row.name === productName, `落库名称一致(${row.name})`)
t.assert(row.status === 'DRAFT', `新建默认 status=DRAFT(实际 ${row.status})`)
t.assert(row.auditStatus === 'DRAFT', `新建默认 auditStatus=DRAFT(实际 ${row.auditStatus})`)
t.assert(row.priceMode === 'FREE', `默认 priceMode=FREE(实际 ${row.priceMode})`)
t.assert(row.spaceId === t._spaceId, `所属空间落库正确(${row.spaceId})`)
t.assert(row.providerConnectorId === t._connectorId, `提供方连接器落库正确(${row.providerConnectorId})`)
})
await t.step('核对 info 接口回显与登记一致', async () => {
const info = await t.api('GET', `/api/ssw/tds/DataProduct/${t._newId}`)
t.assert(info.code === 200 && info.data, `info 可查(code=${info.code})`)
t.assert(info.data.productCode === productCode, `info productCode 一致`)
t.assert(info.data.deliveryType === 'API', `info deliveryType=API(实际 ${info.data.deliveryType})`)
})
}