- system_configs.nav_badge_days 1~365,分支级;超管固定30 - scope=days 默认,10 个 counter 统一滚动窗口;缓存 key 含 days - 系统配置页新增仅分公司管理员可见卡片 - 保留 today/month/all 与切页单菜单刷新
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
const layout = readFileSync(new URL('./Layout.tsx', import.meta.url), 'utf8');
|
|
|
|
describe('Layout 导航角标接线', () => {
|
|
it('调用 hook + 渲染 NavBadge', () => {
|
|
expect(layout).toContain("import { useNavBadgeCounts } from '../hooks/useNavBadgeCounts'");
|
|
expect(layout).toContain("import { NavBadge } from './NavBadge'");
|
|
expect(layout).toContain("useNavBadgeCounts('days', outletKey, location.pathname)");
|
|
});
|
|
|
|
it('二级菜单用 child.menuKey 映射', () => {
|
|
expect(layout).toContain('child.menuKey ? navBadgeCounts[child.menuKey] : 0');
|
|
});
|
|
|
|
it('折叠分组头显示子项合计', () => {
|
|
expect(layout).toContain('groupBadgeCount');
|
|
expect(layout).toContain('Number(navBadgeCounts[child.menuKey');
|
|
expect(layout).toContain('<NavBadge count={!submenuOpen ? groupBadgeCount : 0} />');
|
|
});
|
|
|
|
it('standalone 菜单也显示 item.menuKey 角标', () => {
|
|
expect(layout).toContain('item.menuKey ? navBadgeCounts[item.menuKey] : 0');
|
|
});
|
|
|
|
it('不改变原菜单权限过滤/顺序接线', () => {
|
|
expect(layout).toContain('filterRuntimeMenuByAccess(items, hasPermission, hasRole)');
|
|
});
|
|
});
|