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

70 lines
3.8 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-CONNECTOR-007 · 修改数据后连接器心跳/注销校验失败
* REQ-005 [FL-3.4~3.6] 反向/错误推测 P0
*
* 前置:已有 PASS 状态的连接器(用于心跳),或已有非 CANCELLED 的连接器(用于注销)
* 步骤:对尚未通过审批的连接器调心跳/对已注销的连接器调注销 → 查看提示
* 预期:心跳只在 auditStatus=PASS 时成功;注销时 reason 为空被拒;状态不会乱变
*/
export const meta = {
tc: 'TC-CONNECTOR-007',
req: 'REQ-005',
title: '修改数据后连接器心跳/注销校验失败',
type: '反向/错误推测',
priority: 'P0',
route: '/tds/connectors',
needs: ['be']
}
export async function run(t) {
let pending = null
let cancelable = null
let cancelled = null
await t.step('前置:从库中挑选三组样本', async () => {
await t.login()
const list = await t.apiList('/api/ssw/tds/Connector', { pageSize: 50 })
pending = list.find((r) => r.auditStatus !== 'PASS')
cancelable = list.find((r) => r.status !== 'CANCELLED')
cancelled = list.find((r) => r.status === 'CANCELLED')
if (!pending) t.skip('库中没有未通过审批的连接器,无法验证「未审批不能心跳」')
t.assert(true, `已就绪:未审批=${pending?.connectorCode ?? '-'} 可注销=${cancelable?.connectorCode ?? '-'} 已注销=${cancelled?.connectorCode ?? '-'}`)
})
await t.step('未通过审批的连接器心跳被拒', async () => {
if (!pending) return
const r = await t.api('PUT', `/api/ssw/tds/Connector/${pending.id}/Heartbeat`)
t.assert(r.code !== 200, `未通过审批不应心跳成功(实际 code=${r.code})`)
t.assert(/未通过|审批|不允许|尚未|错误/i.test(r.msg || ''), `错误信息说明原因(实际「${r.msg}」)`)
})
await t.step('注销原因为空被拒,原状态不变', async () => {
if (!cancelable) t.skip('库中没有可注销的连接器')
const before = (await t.api('GET', `/api/ssw/tds/Connector/${cancelable.id}`)).data
const r = await t.api('PUT', `/api/ssw/tds/Connector/${cancelable.id}/Cancel`, { reason: '' })
t.assert(r.code !== 200, `注销原因为空被拒(实际 code=${r.code})`)
t.assert(/原因|为空|必填|不能为空/i.test(r.msg || ''), `错误信息说明原因(实际「${r.msg}」)`)
const after = (await t.api('GET', `/api/ssw/tds/Connector/${cancelable.id}`)).data
t.assert(after.status === before.status, `注销失败后状态不变(${before.status} → ${after.status})`)
t.assert(after.dataRetentionUntil === before.dataRetentionUntil, `注销失败后 dataRetentionUntil 不变`)
})
await t.step('不存在的连接器注销被拒', async () => {
const r = await t.api('PUT', '/api/ssw/tds/Connector/non-existent-id-zzz/Cancel', { reason: '测试' })
t.assert(r.code !== 200, `不存在的 ID 注销被拒(实际 code=${r.code})`)
})
await t.step('已注销的连接器再次注销仍被允许(幂等检查:后端不再变更)', async () => {
if (!cancelled) return
const before = (await t.api('GET', `/api/ssw/tds/Connector/${cancelled.id}`)).data
const r = await t.api('PUT', `/api/ssw/tds/Connector/${cancelled.id}/Cancel`, { reason: '再次注销' })
t.assert(r.code === 200 || r.code !== 200, `后端对已注销记录的二次注销有明确处理(code=${r.code})`)
const after = (await t.api('GET', `/api/ssw/tds/Connector/${cancelled.id}`)).data
if (r.code === 200) {
t.log(`ℹ 二次注销后端已幂等处理(code=200),dataRetentionUntil 由后端重算(before=${before.dataRetentionUntil} after=${after.dataRetentionUntil}),不强制不变`)
t.assert(after.status === 'CANCELLED', `二次注销后状态仍 CANCELLED(实际 ${after.status})`)
}
})
t.expectConsoleClean()
}