import { describe, expect, it } from 'vitest'; import { readFileSync } from 'node:fs'; import { MENU_CATALOG } from '../config/menuCatalog'; import { buildRuntimeMenuTree, mergeNavMenuLayout } from './menuLayout'; /** * 本产品的**功能收窄**:隐藏「市场价格监控」(开发者 2026-10-10: * 「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能」)。 * * 四处一起摘才算真隐藏(只删菜单项的话,直接敲 URL 仍能打开): * ① 菜单目录 `MENU_CATALOG`(运行时菜单树的唯一数据源); * ② 基础数据分组的规范条目(否则归位逻辑会把它塞回分组); * ③ 模块注册表 `businessModules` 的 **route** 与 `menuKeys`(URL 不再可达); * ④ 落地路径兜底(否则"只有 market_monitor 权限"的账号会被送到已隐藏的页面)。 * * ⚠️ 权限码 `market_monitor` **保留**(角色/权限目录与后端仍在用,删了会动到角色同步); * 页面文件与 AI 副驾合同也保留(将来要恢复只需把 ①②③④ 加回去)。 */ describe('市场价格监控已在本产品隐藏', () => { const catalog = readFileSync(new URL('../config/menuCatalog.ts', import.meta.url), 'utf8'); const layout = readFileSync(new URL('./menuLayout.ts', import.meta.url), 'utf8'); const modules = readFileSync(new URL('../modules/businessModules.ts', import.meta.url), 'utf8'); const routing = readFileSync(new URL('./authRouting.ts', import.meta.url), 'utf8'); it('① 菜单目录里没有它', () => { expect(MENU_CATALOG.some((entry) => entry.menuKey === 'market-monitor')).toBe(false); expect(catalog).not.toContain("menuKey: 'market-monitor'"); }); it('② 基础数据规范条目里没有它(不会被归位逻辑塞回分组)', () => { expect(layout).not.toContain("menuKey: 'market-monitor'"); }); it('③ 模块注册表没有它的路由与 menuKey', () => { expect(modules).not.toContain("'market-monitor'"); expect(modules).not.toContain('MarketMonitor'); }); it('④ 落地路径兜底不再指向它', () => { expect(routing).not.toContain("hasPermission('market_monitor')"); }); it('老布局(库里存过该项)加载后侧边栏也不显示它', () => { const saved = { version: 1, order: [ { kind: 'standalone', menuKey: 'dashboard' }, { kind: 'group', groupId: 'grp-master-data' }, ], standalone: [{ menuKey: 'dashboard', visible: true }], groups: [ { id: 'grp-master-data', label: '基础数据', icon: 'Store', visible: true, items: [ { menuKey: 'customers-list', visible: true }, { menuKey: 'market-monitor', label: '市场价格监控', visible: true }, { menuKey: 'products-units', visible: true }, ], }, ], }; const tree = buildRuntimeMenuTree(mergeNavMenuLayout(saved)); const flat = JSON.stringify(tree); expect(flat).not.toContain('市场价格监控'); expect(flat).not.toContain('/market-monitor'); // 同组的其它菜单项不受影响 expect(flat).toContain('/customers'); }); });