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

85 lines
4.3 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-TRADE-009 · 正常办理交易订单
* REQ-022 [FL-17.2] 正向/场景法 P0
*
* 前置:1. 已登录且具备该功能权限的用户
* 2. 服务平台的【数据交易】可以正常打开
* 3. 已准备好测试数据
* 步骤:1. 打开服务平台的【数据交易】
* 2. 按页面提示填写或选择正确的数据
* 3. 点击提交,查看办理结果
* 预期:交易订单办理成功,系统按要求完成处理,状态和记录正确。
*
* 注:交易订单位于 /tds/market 「供需订单」tab。
* 后端 OrderController.beforeSave 通过 productId 自动从 TDC 产品快照填充
* 价格、卖方、交付方式,因此前置需要库里有一条 ENABLED 状态的 TDC 产品。
*/
export const meta = {
tc: 'TC-TRADE-009',
req: 'REQ-022',
title: '正常办理交易订单',
type: '正向/场景法',
priority: 'P0',
route: '/tds/market',
needs: ['fe', 'be']
}
export async function run(t) {
let product = null
await t.step('前置:登录并挑选一条 ENABLED 且有价格的 TDC 产品', async () => {
await t.login()
const list = await t.apiList('/api/ssw/tdc/Product', { pageSize: 50 })
// 正常下单场景需产品带价格;price=null 会导致后端快照填充崩溃(系统异常),属后端健壮性缺陷,本用例不覆盖
product = list.find((r) => r.status === 'ENABLED' && r.price != null)
if (!product) {
const nullPrice = list.some((r) => r.status === 'ENABLED' && r.price == null)
if (nullPrice) t.log('⚠ 存在 ENABLED 但 price=null 的产品,后端 Order.beforeSave 对其会抛「系统异常」,属产品健壮性缺陷,建议单独登记')
t.skip('库里没有「ENABLED 且有价格」的 TDC 产品,无法走 OrderController 的产品快照前置')
}
t.assert(true, `已选定产品:${product.productCode} / ${product.name} / price=${product.price}`)
})
await t.step('打开【数据交易】并切到「供需订单」tab', async () => {
await t.goto('/tds/market')
// antd tabs 默认 v-show 隐藏未激活 tab,激活 tab-pane 会带 .ant-tabs-tabpane-active
await t.page.getByRole('tab', { name: '供需订单' }).click()
await t.page.locator('.ant-tabs-tabpane-active .page-title').first().waitFor({ state: 'visible', timeout: 8000 })
const title = await t.page.locator('.ant-tabs-tabpane-active .page-title').first().innerText()
t.assert(title.includes('供需订单'), `切到供需订单 tab 后标题包含「供需订单」(实际「${title.trim()}」)`)
await t.expectVisible('.ant-tabs-tabpane-active .ant-table', '供需订单表格已渲染')
})
await t.step('通过 API 登记一笔订单并核对前后端', async () => {
// 订单页表单只显示「订单号」与只读列;后台 beforeSave 自动填充单价/卖方等
const orderCode = `ORD-${t.runId}`
const r = await t.api('POST', '/api/ssw/tdc/Order', {
orderCode,
productId: product.id,
quantity: 1,
buyerName: '尚数网测评',
desc: `测评订单 ${t.runId}`
})
t.assert(r.code === 200, `登记订单成功(实际 code=${r.code} msg=${r.msg||''})`)
const list = await t.apiList('/api/ssw/tdc/Order', { keyword: orderCode })
const row = list.find((x) => x.orderCode === orderCode)
t.assert(!!row, `后端已落库订单 ${orderCode}`)
t.assert(row.status === 'PENDING', `新建订单状态为 PENDING(实际 ${row.status})`)
t.assert(row.productId === product.id, `订单关联产品 ID 一致`)
t.assert(!!row.sellerName, `订单卖方由产品快照填充(${row.sellerName})`)
t.assert(Number(row.totalAmount) === Number(product.price), `订单金额等于产品价格(${row.totalAmount} = ${product.price})`)
await t.shot('订单落库')
})
await t.step('订单能在 UI 列表中看到', async () => {
// 关键字搜索的 input 在两个 tab pane 里都有,必须限定到激活 tab
await t.refresh()
const input = t.page.locator('.ant-tabs-tabpane-active .ant-input[placeholder="关键字搜索"]')
await input.fill(`ORD-${t.runId}`)
await t.page.locator('.ant-tabs-tabpane-active').locator('button').filter({ hasText: /查\s*询/ }).first().click()
await t.waitIdle()
await t.expectRow(`ORD-${t.runId}`)
})
t.expectConsoleClean()
}