6d835e947e
三家公司的密钥挤在一页上,而"筛选"是拿当前页那 10 行在前端筛的:total 不动, 第 2 家的令牌要翻到它所在页才筛得出来。操作列给 160px 装不下三颗按钮, 最后一颗(删除)被 td 的 overflow:hidden + table-layout:fixed 整颗裁掉—— DOM 里在、事件也在,就是看不见点不到,这就是"没有删除功能"的真相。 - GET /api/admin/shop-keys 新增 keyword / token / whitelist_status,在公司读范围之内 由服务端筛。keyword 那组 OR 必须括起来:不括就被后续 AND 短路成 「备注名命中 OR (账号命中 AND 本公司)」,第 2 家的 tab 能读到第 1 家的令牌。 - create 的归属改为过读门(认当前 tab),不再只认操作者会话那一家。 读认 tab、写认会话=两把尺子:admin 是 super_admin 且 company_id=1, 他在别家 tab 点新增会"提示已新增、行却落进米椿花名下",再点一次就撞令牌唯一键。 这一条推翻 10-06 定案,controller 的反向钉子(create 不许碰读门)同步换成 「tab 必须过门 + 不许把请求原值直传下去」。 - 操作列 160→270px,.ops-cell 补 flex-wrap: wrap,把"超宽=静默消失"退化成"多占一行"; 同族结构隐患一次扫过 8 个页面(宽度够不够是像素账,会不会消失是结构账)。 - 护栏:ops-cell-must-wrap 钉跨页结构,shop-key-filter-params 钉参数下发与列宽; source-pin 棘轮补第二把尺子 reads=全文读点(体内+体外), pins 降而 reads 不同步降=把 readSource 挪出用例体冒充改进,当场红。 验证:将要提交的树(HEAD + 本批白名单)在独立 worktree 实跑——前端 1762 例 0 红、 vue-tsc rc=0、Java 41 例 0 红且 959 主源 + 498 测试源全量编译过(证明不依赖并行会话 未提交的符号);主树全量 1766 例 0 红。变异自证三支全杀:摘掉一页的 flex-wrap ⇒ 恰好 1 红点名该页;把体内读盘挪进 helper ⇒ 棘轮 1 红且文案点名"不算改进"; 归属退回按会话、controller 绕门直传原值 ⇒ 各自红。
120 lines
5.4 KiB
TypeScript
120 lines
5.4 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import {
|
|
SHOP_PAGE_DEFAULT_SIZE,
|
|
SHOP_PAGE_MAX_SIZE,
|
|
SHOP_PAGE_MIN_PAGE,
|
|
emptyShopKeyPageResult,
|
|
emptyShopPageResult,
|
|
normalizeKeyListParams,
|
|
normalizeShopListParams,
|
|
toKeyPageQuery,
|
|
toShopManagePageQuery,
|
|
} from '../src/pages/shop/shop-dto.ts'
|
|
|
|
test('test_task_081_shop_dto_normal_primary_path', () => {
|
|
// 正常主路径:完整店铺筛选/分页归一后序列化为 Java camelCase 查询参数(page/pageSize/groupId/shopName)。
|
|
const params = normalizeShopListParams({
|
|
page: 2,
|
|
pageSize: 20,
|
|
groupId: 3,
|
|
shopName: ' 主 店 ',
|
|
})
|
|
assert.equal(params.page, 2)
|
|
assert.equal(params.pageSize, 20)
|
|
assert.equal(params.groupId, 3)
|
|
assert.equal(params.shopName, '主 店')
|
|
const query = toShopManagePageQuery(params)
|
|
assert.equal(query.page, 2)
|
|
assert.equal(query.pageSize, 20)
|
|
assert.equal(query.groupId, 3)
|
|
assert.equal(query.shopName, '主 店')
|
|
})
|
|
|
|
test('test_task_081_shop_dto_normal_variant_input', () => {
|
|
// 正常变体:一个筛选词都不给时,店铺密钥列表的下发查询只可能有 page/pageSize
|
|
// (三个筛选维度见 shop-key-filter-params.test.ts:给了才下发,空白与非法值都不占参数位)。
|
|
const params = normalizeKeyListParams({ page: 3, pageSize: 30 })
|
|
const query = toKeyPageQuery(params)
|
|
assert.deepEqual(Object.keys(query).sort(), ['page', 'pageSize'])
|
|
assert.equal(query.page, 3)
|
|
assert.equal(query.pageSize, 30)
|
|
// 店铺列表可选条件缺省时不下发对应字段。
|
|
const manageQuery = toShopManagePageQuery(normalizeShopListParams({ page: 1, pageSize: 15 }))
|
|
assert.deepEqual(Object.keys(manageQuery).sort(), ['page', 'pageSize'])
|
|
})
|
|
|
|
test('test_task_081_shop_dto_normal_repeated_operation_is_idempotent', () => {
|
|
// 正常重复:归一不改输入、结果稳定;空结果默认值相互独立。
|
|
const input = { page: 2, pageSize: 25, groupId: 7, shopName: 'A店' }
|
|
assert.deepEqual(normalizeShopListParams(input), normalizeShopListParams(input))
|
|
assert.equal(input.shopName, 'A店')
|
|
const first = emptyShopPageResult()
|
|
const second = emptyShopPageResult()
|
|
first.items.push({} as never)
|
|
assert.equal(second.items.length, 0, '每次空结果返回独立列表,避免污染')
|
|
})
|
|
|
|
test('test_task_081_shop_dto_boundary_empty_input', () => {
|
|
// 边界空值:空入参回默认分页(第 1 页/15 条),无可选筛选。
|
|
const params = normalizeShopListParams({})
|
|
assert.equal(params.page, SHOP_PAGE_MIN_PAGE)
|
|
assert.equal(params.pageSize, SHOP_PAGE_DEFAULT_SIZE)
|
|
assert.equal(params.groupId, null)
|
|
assert.equal(params.shopName, undefined)
|
|
const query = toShopManagePageQuery(params)
|
|
assert.deepEqual(Object.keys(query).sort(), ['page', 'pageSize'])
|
|
})
|
|
|
|
test('test_task_081_shop_dto_boundary_single_item', () => {
|
|
// 边界单元素:页大小 1 保留为最小单行页;单行空结果 DTO 结构完整。
|
|
assert.equal(normalizeShopListParams({ page: 1, pageSize: 1 }).pageSize, 1)
|
|
const key = emptyShopKeyPageResult()
|
|
assert.deepEqual(key.items, [])
|
|
assert.equal(key.total, 0)
|
|
assert.equal(key.page, SHOP_PAGE_MIN_PAGE)
|
|
assert.equal(key.pageSize, SHOP_PAGE_DEFAULT_SIZE)
|
|
const shop = emptyShopPageResult()
|
|
assert.deepEqual(shop.items, [])
|
|
assert.equal(shop.total, 0)
|
|
})
|
|
|
|
test('test_task_081_shop_dto_boundary_limit_or_missing_field', () => {
|
|
// 边界上限:页码 <1 归 1;页大小超上限/非正被夹取;负分组 id 视为无筛选。
|
|
assert.equal(normalizeShopListParams({ page: 0, pageSize: 999 }).page, 1)
|
|
assert.equal(normalizeShopListParams({ page: 0, pageSize: 999 }).pageSize, SHOP_PAGE_MAX_SIZE)
|
|
assert.equal(normalizeShopListParams({ page: 0, pageSize: 0 }).pageSize, SHOP_PAGE_DEFAULT_SIZE)
|
|
assert.equal(normalizeShopListParams({ page: 1, pageSize: 15, groupId: -5 }).groupId, null)
|
|
const params = normalizeShopListParams({ page: 1, pageSize: 15, groupId: undefined })
|
|
assert.equal(params.shopName, undefined)
|
|
})
|
|
|
|
test('test_task_081_shop_dto_invalid_input_rejected', () => {
|
|
// 异常输入:非数字/NaN/空白筛选取缺省;字符串分组 id 不接受。
|
|
const params = normalizeShopListParams({
|
|
page: 'x' as never,
|
|
pageSize: Number.NaN,
|
|
groupId: '3' as never,
|
|
shopName: ' ',
|
|
})
|
|
assert.equal(params.page, SHOP_PAGE_MIN_PAGE)
|
|
assert.equal(params.pageSize, SHOP_PAGE_DEFAULT_SIZE)
|
|
assert.equal(params.groupId, null)
|
|
assert.equal(params.shopName, undefined)
|
|
})
|
|
|
|
test('test_task_081_shop_dto_dependency_failure_returns_actionable_message', () => {
|
|
// 依赖失败/可操作:DTO 为纯逻辑、无框架/http;敏感字段与店铺/密钥边界有明确类型。
|
|
const mod = readSource('src/pages/shop/shop-dto.ts')
|
|
assert.equal(/axios|http\.|from '\.\/http'|vue/.test(mod), false, 'DTO 模块保持纯逻辑')
|
|
assert.match(mod, /export interface ShopKeyItem/)
|
|
assert.match(mod, /export interface ShopSummary/)
|
|
assert.match(mod, /export interface ShopCredential/)
|
|
assert.match(mod, /export type SensitiveString/)
|
|
assert.match(mod, /ziniaoToken\s*:/, '紫鸟令牌以敏感字段建模')
|
|
assert.match(mod, /password\s*:\s*SensitiveString/, '凭证明文必须落在 SensitiveString')
|
|
assert.match(mod, /passwordMasked\s*\?/, '列表行只有掩码密码')
|
|
assert.equal(/group_id|created_by_id/.test(mod), false, '店铺接口为 camelCase,不应出现 snake 字段名')
|
|
})
|