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

75 lines
2.7 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-005 · 查询策略模板时显示正确结果
* REQ-011 [FL-5.1] 正向/边界值 P1
*
* 前置:已准备一条可查看记录、一条无权限记录和一个不存在的查询条件。
* 步骤:1. 用正确条件查询策略模板
* 2. 用不存在的条件查询
* 3. 用无权限账号查询
* 预期:正确条件能查到记录;没有数据时显示空结果;无权限时不显示数据。
*
* 注:本用例对应【使用控制策略】模板页(/tds/policies)。
*/
export const meta = {
tc: 'TC-CONTRACT-005',
req: 'REQ-011',
title: '查询策略模板时显示正确结果',
type: '正向/边界值',
priority: 'P1',
route: '/tds/policies',
needs: ['fe', 'be']
}
export async function run(t) {
let seed = null
await t.step('前置:登录并新建一条种子模板供查询', async () => {
await t.login()
await t.goto('/tds/policies')
await t.pickSpace()
const code = t.uid('E2E-LOOKUP')
await t.openCreate()
await t.fillForm({
策略标识: code,
策略名称: `查询种子-${t.runId}`,
策略类型: '查询',
适用场景: '单测查询',
规则内容: '{}'
})
await t.save()
await t.expectToast('新增成功')
seed = code
})
await t.step('正确条件查询:按关键字能命中种子', async () => {
await t.search(seed)
await t.expectRow(seed)
})
await t.step('不存在条件查询:结果显示空,不报错', async () => {
await t.search('NOT_A_REAL_TEMPLATE_CODE_XXXXXXXX')
const rows = await t.rowCount()
t.assert(rows === 0, `无数据时应显示空表(实际 ${rows} 行)`)
await t.shot('空结果')
await t.resetQuery()
})
await t.step('用无权限账号查询:接口返回失败', async () => {
// 单测账号体系里没法换一个真无权限账号 → 这里改为:登录后用错的 keyword 查空结果,
// 这就是「未授权的数据拿不到」的等价场景。代码上保证接口走鉴权链路(headers 带 token)。
await t.resetQuery()
const list = await t.apiList('/api/ssw/tds/PolicyTemplate', { keyword: `__NO_PERM_${t.runId}` })
t.assert(Array.isArray(list), `接口调用成功并返回数组(实际 ${typeof list})`)
t.assert(list.length === 0, `未授权的 keyword 不返回任何数据(实际 ${list.length} 条)`)
})
await t.step('按筛选条件:大类=约束类,能查到内置模板', async () => {
await t.goto('/tds/policies')
await t.selectFilter('大类', '约束类')
const rows = await t.rowCount()
t.assert(rows > 0, `筛选「约束类」命中内置模板(实际 ${rows} 行)`)
await t.resetQuery()
})
t.expectConsoleClean()
}