Files
crawler-plugin/admin-frontend-vue/tests/align-dup-console.test.ts
T
huangzd1997 16583f578d feat(公司tab): 批次 2/3/4 再接 8 页,注册表收到 16 页——用户页回流 company_id 按新边界改写反向钉
「切 tab 数据还一样」的根因一直是分母小于现实:批次 1 只登记 8 页,本轮按控制方
三次点名扩到 16 页(company-scope.ts 是唯一清单,routes.ts 的 companyScoped 逐页对平)。

批次 2(五页 ASIN 中心):去重总数据 / 不符合ASIN / 查询ASIN / 最低价ASIN / 商品类目。
批次 3(两页店铺中心):撞款监控、店铺数据记录。这两页没有归属列可筛,归属口径是
「本公司账号名下的店铺」——后端由 DataReadScope 推公司 → 成员账号 → biz_shop_manage.
created_by_id,前端只把 activeId 当 company_id 送下去。空成员集必须交空集合,绝不能
退化成 null(null 在这里=全量,那样第二家会看到全部数据)。
批次 4(用户管理):后端早就认 company_id(只对站点超管生效,公司超管恒锁本公司),
断的是前端——UserListQuery 里连这个字段都没有,三家 tab 看的是同一份全量列表。

三处口径改动,逐条说明:
1)company-user-list.test.ts 的反向钉被改写。2026-10-04 定案把公司维度从用户页整体摘掉,
   那条钉的原文是「列表查询/筛选/行渲染不允许出现公司维度」。控制方 2026-10-05 明确要
   用户管理区分公司 tab,所以钉的边界收窄成两半:渲染层(行级公司列、「所属公司」标签、
   筛选状态、顶栏公司名)仍不得回流;请求层的 company_id 是这次加回来的,尺子换成
   「取值口唯一」——页面每处 companyId 都必须等于 companyTab.requestCompanyId,且
   normalizeUserPageParams/toUserListQuery 两只白名单构造器体内不许出现公司值。
   新增一支行为钉:往归一化里传 companyId 必须被丢掉,这是 users.ts 读原始入参的全部理由
   (写成 normalized.companyId 时 TS 照样绿、运行时恒 undefined)。
2)align-dup-console 那条 watch 看守的 token 扩到含 reload。变异自证里「删掉 void
   loadConsole()」当场全绿:体里的清筛选项守住了,重新取数那半没人守。批次 3/4 三对
   token 一起写到 reload 为止(批次 1/2 的老条目不动)。
3)公司管理页补正/反向两把尺子:company-config-entry-super-only 新增「吃公司 tab 的页面
   集合恰好等于 COMPANY_SCOPED_PAGES 的 pageFiles」——按代码真值比,不按清单比,所以
   清单不改一字而往 CompaniesPage.vue 里塞 store 也会红。谓词带括号,否则 import 行也算消费者。

菜单权限(admin_columns)本轮不动:MenusPage 只消费 /api/admin/permission-menus 这一份全局
菜单字典,切 tab 一样是数据本身全局,不是筛选坏了。真问题在写侧——PermissionMenuService
create/update/delete 只有 ensureAdminOperatorIfPresent(isAdmin 即放行),公司管理员改的是
全平台的菜单行。收窄为仅站点超管 vs 给 permission_menu 加归属列,两种改法代价差一个量级,
留给控制方定档。

护栏:G1 发送口 22 个 / 页面分组 17、watch 体看守 10 对、operation-guide 的 tab 文案 15 页
(撞款监控是显式豁免,另有一条自检盯「豁免落空」)。
变异自证 12/12 全杀(前端 10 + 公司管理反向钉 2),分母钉死在 27 例。
门禁:后端全量 3823 例 / 0 失败 / 0 错误 / 7 skipped,BUILD SUCCESS;admin-frontend-vue
1741 例 / 0 红;vue-tsc rc=0。首轮后端 4 红是另一路 task_partial 改动与本轮编译抢跑,
单跑 13 例已绿,本笔不含他们的任何文件。

未上线:jar 与 admin-vue 都没出包,V147 未在生产执行。
2026-10-06 02:32:59 +08:00

107 lines
7.4 KiB
TypeScript
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.
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { aggregateDrawerRows, drawerSummaryOf } from '../src/pages/tasks/duplicate-console-logic.ts'
// 验收反馈:店铺重复检测对齐 reference —— 本轮补齐 P0 缺口:
// 分组筛选生效、抽屉聚合+汇总徽章、台账计数打开即显示、撞款计数走后端 total_dup、矩阵表头吸顶。
test('align_dup_console_group_filter_wired', () => {
const api = readSource('src/pages/tasks/duplicate-console-api.ts')
assert.match(api, /query\.group = group/, 'console 查询携带 group 参数')
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /group: filter\.group\.trim\(\)/, '页面筛选把 group 传给查询')
})
test('align_dup_console_group_filter_backend', () => {
const ctrl = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/controller/AdminShopDataDuplicateCheckController.java')
assert.match(ctrl, /@RequestParam\(name = "group"/, '后端 console/ledger 接收 group 参数')
assert.match(ctrl, /withGroupFilter\(visibleKeys, scan, group\)/, '端点按分组裁剪可见店铺')
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
assert.match(service, /withGroupFilter/, 'service 提供分组裁剪方法')
assert.match(service, /分组筛选/, '分组筛选留中文排查日志')
})
test('align_dup_console_drawer_aggregation', () => {
const rows = aggregateDrawerRows([
{ asin: 'A', date: '2026-09-02 10:00', price: '1', brand: 'B', shopName: '店1', groupName: '组1', countryCodes: [], country: 'DE' },
{ asin: 'A', date: '2026-09-01 10:00', price: '1', brand: 'B', shopName: '店1', groupName: '组1', countryCodes: [], country: 'DE' },
{ asin: 'A', date: '2026-09-03 10:00', price: '1', brand: 'B', shopName: '店2', groupName: '组1', countryCodes: [], country: 'UK' },
])
assert.equal(rows.length, 2, '按店铺×站点聚合')
assert.equal(rows[0].count, 2, '同店同站次数累加')
assert.deepEqual(rows[0].times, ['2026-09-01 10:00', '2026-09-02 10:00'], '时间升序')
const summary = drawerSummaryOf(rows.flatMap((row) => row.times.map((time) => ({ asin: 'A', date: time, price: '1', brand: 'B', shopName: row.shopName, groupName: '组1', countryCodes: [], country: row.country }))))
assert.equal(summary.shopCount, 2)
assert.equal(summary.totalRecords, 3)
assert.equal(summary.earliest, '2026-09-01 10:00')
})
test('align_dup_console_drawer_template', () => {
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /drawerAggRows/, '抽屉渲染聚合行')
assert.match(page, /drawerSummary/, '抽屉渲染汇总徽章')
assert.match(page, /次上架/, '汇总含 N 次上架')
assert.match(page, /<th[^>]*>次数<\/th>/, '聚合表含次数列')
assert.match(page, /v-for="row in drawerRows"/, '抽屉聚合表绑定分页切片')
assert.match(page, /:total="drawerAggRows\.length"/, '抽屉聚合表有分页器')
})
test('align_dup_console_pagination_all_lists', () => {
// 全站统一收官:撞款页四处列表(分布/矩阵/撞款详情卡片/抽屉明细)均挂共享 OldPagination,
// 且分布/矩阵/详情常显(不足一页也显示分页器,反馈:数据少时看不到分页)。
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /:total="distCount"/, '店铺上架分布有分页器(常显)')
assert.match(page, /:total="dupRows\.length"/, '撞款覆盖矩阵有分页器(常显)')
assert.match(page, /v-for="item in dupCardRows"/, '撞款详情卡片绑定分页切片')
assert.match(page, /:total="dupRows\.length"[\s\S]*dupCardPageSize/, '撞款详情卡片有分页器(常显)')
assert.match(page, /<OldPagination[^>]*:total="distCount"/, '分布分页器无 v-if 条件')
assert.match(page, /<OldPagination[^>]*:total="dupRows\.length"/, '矩阵/详情分页器无 v-if 条件')
assert.match(page, /v-for="group in pagedGroupStats"/, '分组说明抽屉表绑定分页切片')
assert.match(page, /:total="groupStats\.length"/, '分组说明抽屉表有分页器')
})
test('align_dup_console_ledger_total_preload', () => {
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /onMounted\(\(\) => \{\s*loadConsole\(\).*loadLedger\(1\)/s, '挂载即预取台账计数')
assert.match(page, /totalDup/, '撞款计数走后端 total_dup 字段')
})
test('align_dup_console_matrix_sticky', () => {
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /table\.matrix th\s*\{[^}]*position:\s*sticky/, '矩阵表头吸顶')
assert.match(page, /\.matrix-wrap\s*\{[^}]*max-height/, '矩阵容器限高滚动')
})
test('align_dup_console_role_scope_group_filter_only_super', () => {
// 角色范围:分组筛选下拉仅超管需要;管理员数据由后端裁到本组。
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /useAdminSessionStore/, '页面读取登录会话取角色')
assert.match(page, /const isSuper = computed\(\(\) => session\.isSuperAdmin\)/, 'isSuper 由会话角色推导')
assert.match(page, /<div v-if="isSuper" class="f-group">\s*<label>分组<\/label>/s, '分组筛选仅超管可见')
assert.match(page, /group: filter\.group\.trim\(\)/, '分组筛选仍参与查询参数')
})
test('align_dup_console_role_scope_group_controls_only_super', () => {
// 分组撞款/分组说明为超管专属交互;后端超管全量、管理员所管分组店铺。
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /<div v-if="isSuper" class="scope-bar">/, '分组撞款分段仅超管可见')
assert.match(page, /v-if="isSuper" class="btn btn-ghost btn-sm" type="button" @click="groupInfoVisible = true"/, '分组说明按钮仅超管可见')
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
// 2026-10-05 批次 3 之后「超管全量」不再是 `if (superAdmin) return null`,而是"超管且没切公司 tab(成员集为 null)"。
// 逐字判据 + 空成员集那支一起钉:后者一旦退化成 null,第二家公司会看到全部店铺(语义由
// ShopDataDuplicateCheckCompanyScopeTest 用真调用验,这里只保证源码形状没被顺手改回去)。
assert.match(service, /if \(companyMemberIds == null\) \{\s*return null;/, '超管未切公司 tab=全量(null)')
assert.match(service, /companyMemberIds\.isEmpty\(\)\s*\?\s*new LinkedHashSet<>\(\)/,
'公司一个账号都没有=空可见集,不许退化成 null')
assert.match(service, /selectManagedShopNames\(operatorId\)/, '管理员可见范围=所管分组店铺')
})
test('align_dup_console_country_labels_chinese', () => {
// 反馈:国家显示一定要用中文——站点/国家一律经 asinCountryLabel 映射,禁止裸国家码直出。
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.match(page, /asinCountryLabel\(/, '站点显示走中文映射函数')
assert.doesNotMatch(page, /\{\{\s*(row|item)\.country\s*\}\}/, '表格/抽屉无裸国家码直出')
assert.match(page, /asinCountryLabel\(code\)/, '筛选下拉站点显示中文')
})