Files
ssw-mvp/docs/e2e/cases/TC-CONTRACT-004.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
2.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-CONTRACT-004 · 重复办理策略模板时不会重复处理
* REQ-011 [FL-5.1] 反向/状态迁移 P1
*
* 前置:已存在一条可以办理的策略模板记录。
* 步骤:1. 正常办理一次策略模板
* 2. 再次提交相同操作
* 3. 查看状态、列表和相关记录
* 预期:第一次按正常流程处理;第二次不会生成重复数据,状态和相关记录正确。
*
* 注:本用例对应【使用控制策略】模板页(/tds/policies)。
* 「重复处理」在策略模板上的具体含义:相同 templateCode 不能被新建第二次。
*/
export const meta = {
tc: 'TC-CONTRACT-004',
req: 'REQ-011',
title: '重复办理策略模板时不会重复处理',
type: '反向/状态迁移',
priority: 'P1',
route: '/tds/policies',
needs: ['fe', 'be']
}
export async function run(t) {
const code = t.uid('E2E-POL-DUP')
await t.step('前置:登录并打开【使用控制策略】', async () => {
await t.login()
await t.goto('/tds/policies')
await t.pickSpace()
})
await t.step('第一次办理:用唯一策略标识新建一条模板', async () => {
await t.openCreate()
await t.fillForm({
策略标识: code,
策略名称: `重复策略-${t.runId}`,
策略类型: '频次',
适用场景: '1 分钟 1 次',
规则内容: '{"rateLimit":1}'
})
await t.save()
await t.expectToast('新增成功')
})
await t.step('核对第一次落库成功', async () => {
const list = await t.apiList('/api/ssw/tds/PolicyTemplate', { keyword: code })
t.assert(list.some((r) => r.templateCode === code), `后端已记录 ${code}`)
})
await t.step('第二次办理:用相同 templateCode 再次提交被拒', async () => {
const r = await t.api('POST', '/api/ssw/tds/PolicyTemplate', {
templateCode: code,
name: `重复策略-2-${t.runId}`,
category: 'CONSTRAINT',
policyType: '频次',
enforcePoint: 'TDC',
denyAction: 'REJECT',
ruleContent: '{"rateLimit":1}'
})
t.assert(r.code !== 200, `重复 templateCode 被拒(实际 code=${r.code})`)
t.assert(/已存在|重复/i.test(r.msg || ''), `错误信息说明重复原因(实际「${r.msg}」)`)
})
await t.step('页面侧:再次新建相同标识也走拦截', async () => {
await t.openCreate()
await t.fillForm({
策略标识: code,
策略名称: `重复策略-3-${t.runId}`,
策略类型: '频次',
适用场景: '1 分钟 1 次',
规则内容: '{"rateLimit":1}'
})
await t.save()
await t.expectReject('已存在')
await t.cancelDrawer()
})
await t.step('核对没有产生重复数据', async () => {
const list = await t.apiList('/api/ssw/tds/PolicyTemplate', { keyword: code })
t.assert(list.length === 1, `库里只有 1 条 ${code}(实际 ${list.length})`)
})
t.expectConsoleClean()
}