Files
ssw-mvp/docs/e2e/scripts/fix-tdc-order.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

39 lines
2.0 KiB
JavaScript

/**
* TDC 接口用例补充必填字段:connection 系接口需要 connectorId/spaceId 等。
*/
import fs from 'node:fs'
import path from 'node:path'
let n = 0
function patch(file, transform) {
const fp = path.join('cases', file)
if (!fs.existsSync(fp)) return
const orig = fs.readFileSync(fp, 'utf8')
const next = transform(orig)
if (next !== orig) { fs.writeFileSync(fp, next); n++; console.log(' ✓ ' + file) }
}
// REL-007: Contract POST 缺必填字段
patch('TC-REL-007.mjs', (s) => {
const re = /const r = await t\.api\('POST', '\/api\/ssw\/tds\/Contract', \{([\s\S]*?)\}\)/
return s.replace(re, (m, body) => `const spaces = await t.apiList('/api/ssw/tds/Space'); const conns = await t.apiList('/api/ssw/tds/Connector'); const prods = await t.apiList('/api/ssw/tds/DataProduct');
const r = await t.api('POST', '/api/ssw/tds/Contract', { contractCode: 'E2E-REL-'+t.runId, name: '可靠性烟测', spaceId: spaces[0]?.id, productId: prods[0]?.id, providerConnectorId: conns[0]?.id, consumerConnectorId: conns[0]?.id, providerOrgName:'A', consumerOrgName:'B', purpose:'P0', deliveryType:'API', priceMode:'FREE'${body}})
`)
})
// PLATFORM-004: Product /Publish 缺必填字段
patch('TC-PLATFORM-004.mjs', (s) => {
// 找到 PUT /Publish 调用,补 productCode / spaceId / providerConnectorId / providerOrgName
return s.replace(
/const r = await t\.api\('PUT', `\/api\/ssw\/tdc\/Product\/\$\{target\.id\}\/Publish`, \{/,
"const r = await t.api('PUT', `/api/ssw/tdc/Product/${target.id}/Publish`, { productCode: target.productCode||('E2E-PUB-'+t.runId), spaceId: target.spaceId||'default', providerConnectorId: target.providerConnectorId||'con-x', providerOrgName: target.providerOrgName||'尚数网',"
)
})
// IDENTITY_API-003: User create 缺必填字段
patch('TC-IDENTITY_API-003.mjs', (s) => s.replace(
/body: \{[^}]*\}/,
"body: { account: 'e2e-'+t.runId, password: '123456', realName: 'E2E'+t.runId, enabledMark: 1, isAdministrator: 0 }"
))
console.log(`已修 ${n} 个文件`)