ca78bd27e9
批次 1 的 tab 机制半边:默认选中 id 最小的启用公司、不允许「全部」;「该不该画 tab 条」只住 store 一处(组件里再数一遍 length 就是第二把尺子);两家全停用时 activeId 为 null ⇒ 整条不渲染,不画出按钮为零的空 tab 条。 G1 双向对账 + 跨端常量钉子(后端 SUPER_ADMIN_ONLY_KEYS ↔ 前端 SUPER_ADMIN_ONLY_MENU_KEYS 由代码执行地相等,读不到/抽不到/空集三种都判红) + pageFiles↔routes.ts load() 对账,把 Task 8-12 的接线欠债钉成会红的尺子。 §9.3 的「行数会随 tab 变」由既有引导文案承载(8 页 + C 类 2 页各一句,句子抽成 常量防手抄差异),不新做页头控件/提示条。 已知一条刻意红灯:company-tab-wiring.test.ts 的正向半支在 Task 12 接线完成前必红 (plan 19 Step 8 明令),下一条补齐接线的提交收敛它。全量 1726 例仅此 1 红, vue-tsc --noEmit 通过。 AdminLayout.vue / operation-guides.ts / company-config-entry-super-only.test.ts 三支文件此刻同时带着另一路会话的未提交改动,本提交按 hunk 逐行只入自己的部分。
110 lines
5.7 KiB
TypeScript
110 lines
5.7 KiB
TypeScript
import test from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { readSource } from './helpers.ts'
|
||
import { adminPages } from '../src/router/routes.ts'
|
||
import { COMPANY_SCOPED_PAGES } from '../src/config/company-scope.ts'
|
||
import {
|
||
OPERATION_GUIDES,
|
||
OPERATION_GUIDE_FALLBACK,
|
||
OPERATION_GUIDE_STORAGE_KEY,
|
||
operationGuideFor,
|
||
} from '../src/layout/operation-guides.ts'
|
||
|
||
/** 对齐旧版 admin-interactions.js guides 表:每业务菜单页顶部展示可折叠「当前页面操作提示」,文案沿用旧版原文;店铺撞款监控(例外)不展示。 */
|
||
|
||
const EXCEPTED_KEY = 'admin_shop_data_duplicate_check'
|
||
|
||
test('align_guide_users_matches_reference_text', () => {
|
||
const g = operationGuideFor('admin_users')
|
||
assert.ok(g)
|
||
assert.equal(g.text, '先用筛选定位账号,再编辑角色和菜单权限;删除账号会要求二次确认。')
|
||
assert.deepEqual(g.steps, ['筛选账号', '编辑权限', '确认保存'])
|
||
})
|
||
|
||
test('align_guide_history_and_version_reference_text', () => {
|
||
assert.match(operationGuideFor('admin_history')!.text, /生成记录可按用户和时间范围回溯/)
|
||
assert.deepEqual(operationGuideFor('admin_version')!.steps, ['上传压缩包', '检查版本记录', '维护历史版本'])
|
||
})
|
||
|
||
test('align_guide_group_manage_own_text', () => {
|
||
// 2026-10-05 公司 tab(spec §9.3):这页从"沿用旧版通用 fallback"改成自带文案——
|
||
// 上一行"对齐旧版 guides 表原文"的约定在这一页是**故意破的**,因为那句 tab 说明
|
||
// 不能塞进 fallback(fallback 会被没进 tab 的页共用,等于把 tab 端给它们)。
|
||
const g = operationGuideFor('admin_group_manage')
|
||
assert.ok(g)
|
||
assert.notEqual(g, OPERATION_GUIDE_FALLBACK)
|
||
assert.match(g.text, /超级管理员可用页面上方的公司 tab 切换公司/)
|
||
assert.deepEqual(g.steps, ['选择分组', '维护负责人与归属账号', '核对店铺可见范围'])
|
||
})
|
||
|
||
test('align_guide_duplicate_check_not_present', () => {
|
||
// 例外页:不展示提示条(不参与本轮对齐)。
|
||
assert.equal(operationGuideFor(EXCEPTED_KEY), null)
|
||
assert.equal(EXCEPTED_KEY in OPERATION_GUIDES, false)
|
||
})
|
||
|
||
test('align_guide_unknown_key_null', () => {
|
||
assert.equal(operationGuideFor(undefined), null)
|
||
assert.equal(operationGuideFor(null), null)
|
||
assert.equal(operationGuideFor('not-a-menu'), null)
|
||
assert.equal(operationGuideFor(''), null)
|
||
})
|
||
|
||
test('align_guide_every_router_page_has_guide_except_duplicate_check', () => {
|
||
// 路由注册表里的业务页除例外页外都应有独立/兜底提示。
|
||
const without = adminPages.filter((p) => p.menuKey !== EXCEPTED_KEY)
|
||
assert.ok(without.length >= 15, '业务页至少 15')
|
||
for (const page of without) {
|
||
assert.ok(operationGuideFor(page.menuKey), `缺少 guide: ${page.menuKey}`)
|
||
}
|
||
})
|
||
|
||
test('align_guide_storage_key_matches_legacy', () => {
|
||
assert.equal(OPERATION_GUIDE_STORAGE_KEY, 'shufuAdminGuideCollapsed')
|
||
})
|
||
|
||
test('align_guide_component_in_layout_headline', () => {
|
||
const layout = readSource('src/layout/AdminLayout.vue')
|
||
assert.match(layout, /OperationGuide/, '壳层引用 OperationGuide 组件')
|
||
const comp = readSource('src/layout/OperationGuide.vue')
|
||
assert.match(comp, /当前页面操作提示/, '标题对齐旧版 adminOperationGuide 语义')
|
||
assert.match(comp, /收起提示/, '折叠按钮文案')
|
||
assert.match(comp, /展开提示/, '展开按钮文案')
|
||
assert.match(comp, /operationGuideFor\(route\.meta\.menuKey\)/, '按菜单 key 查文案')
|
||
assert.match(comp, /OPERATION_GUIDE_STORAGE_KEY/, '折叠态读写同一 localStorage key')
|
||
})
|
||
|
||
test('align_guide_fallback_shape', () => {
|
||
assert.equal(OPERATION_GUIDE_FALLBACK.steps.length, 3)
|
||
assert.ok(OPERATION_GUIDE_FALLBACK.text.length > 10)
|
||
})
|
||
|
||
test('guide_copy_carries_company_tab_note_for_every_scoped_page', () => {
|
||
// spec §9.3:tab 会改行数观感,承载方式是既有引导文案(不新做控件)。
|
||
// 分母=COMPANY_SCOPED_PAGES,杜绝"加了一页忘了补文案"。
|
||
const need = COMPANY_SCOPED_PAGES.map((p) => p.menuKey)
|
||
assert.ok(need.length >= 8, '取样集非空自检:注册表应当至少有 8 页进了 tab 范围')
|
||
for (const key of need) {
|
||
const g = operationGuideFor(key)
|
||
assert.ok(g, `注册表页缺 guide: ${key}`)
|
||
assert.match(g.text, /超级管理员可用页面上方的公司 tab 切换公司/, `${key} 缺 §9.3 那句`)
|
||
}
|
||
// C 类两页(spec §5):它们要的是**另一句**——"这页不参与",不是"会随 tab 变"。
|
||
// 分母**取注册表里显式写 companyScoped:false 的页**,不抄名单:漏写一条 ⇒ 这支在自检那句红。
|
||
const scoped = new Set(COMPANY_SCOPED_PAGES.map((p) => p.menuKey))
|
||
const cClass = adminPages.filter((p) => p.companyScoped === false).map((p) => p.menuKey)
|
||
assert.ok(cClass.length >= 2, '取样集非空自检:注册表里显式 companyScoped:false 的至少 C 类那两页')
|
||
for (const key of cClass) {
|
||
assert.equal(scoped.has(key), false, `${key} 既声明 false 又在清单里,两处口径打架`)
|
||
const g = operationGuideFor(key)
|
||
assert.ok(g, `不参与 tab 的页缺 guide: ${key}`)
|
||
assert.match(g.text, /全平台共享,不按公司区分/, `${key} 缺 §5 那句`)
|
||
assert.equal(g.text.includes('公司 tab 切换公司'), false, `${key} 不该带 tab 那句(它不参与)`)
|
||
}
|
||
// 反向钉:这句话只能由文案承载。tab 组件里再长出"当前公司:X"就是第二处表达(§12 第 5 条未批)。
|
||
const tabs = readSource('src/layout/CompanyTabs.vue')
|
||
assert.ok(tabs.length > 0, '取样集非空自检:CompanyTabs.vue 读到了')
|
||
assert.equal(tabs.includes('company-tab-hint'), false, '不许有页头"当前公司"提示条')
|
||
assert.equal(tabs.includes('当前公司'), false, '同上:当前公司只由 is-active 的 tab 表达')
|
||
})
|