navConfig.test.ts 1.5 KB
// REQ-USR-003: 导航静态配置(复刻原型 navSide / navCols,D1/D4)
import { describe, it, expect } from 'vitest';
import { NAV_SIDE, NAV_COLS } from '../../src/layouts/AppLayout/navConfig';

describe('navConfig', () => {
  it('NAV_SIDE has 20 items with 系统设置 active', () => {
    expect(NAV_SIDE).toHaveLength(20);
    const sys = NAV_SIDE.find((s) => s.label === '系统设置');
    expect(sys).toBeDefined();
    expect(sys!.active).toBe(true);
    // 仅「系统设置」一项 active
    expect(NAV_SIDE.filter((s) => s.active).length).toBe(1);
  });

  it('NAV_COLS has 7 groups with exact titles', () => {
    expect(NAV_COLS).toHaveLength(7);
    expect(NAV_COLS.map((c) => c.title)).toEqual([
      '期初设置',
      '用户管理',
      '系统参数',
      '计算方案',
      '日志',
      '开发平台',
      'API对接管理',
    ]);
  });

  it('用户列表 leaf has routePath /usr/users and star', () => {
    const userMgmt = NAV_COLS.find((c) => c.title === '用户管理')!;
    const userList = userMgmt.items.find((it) => it.label === '用户列表')!;
    expect(userList.routePath).toBe('/usr/users');
    expect(userList.star).toBe(true);
  });

  it('系统功能模块设置 leaf has star and no routePath (placeholder)', () => {
    const devCol = NAV_COLS.find((c) => c.title === '开发平台')!;
    const leaf = devCol.items.find((it) => it.label === '系统功能模块设置')!;
    expect(leaf.star).toBe(true);
    expect(leaf.routePath).toBeUndefined();
  });
});