import test from 'node:test' import assert from 'node:assert/strict' import fs from 'node:fs' import path from 'node:path' import { fileURLToPath } from 'node:url' const scriptDir = path.dirname(fileURLToPath(import.meta.url)) const dashboardPath = path.resolve(scriptDir, '../src/views/dashboard/index.vue') const dashboardSource = fs.readFileSync(dashboardPath, 'utf8') test('首页包含仓储运营总览的核心模块', () => { for (const label of [ '仓储运营总览', '当前库存托盘', '剩余包数', '今日入库单', '今日出库单', '待确认单据', '新增入库', '托盘填充', '发货出库', '托盘使用', '托盘退回', '托盘追踪', '近 7 天入库 / 出库趋势', '托盘流转状态分布', '仓库库存排行', '最近入库单', '最近出库单', '扫码异常', '待确认业务' ]) { assert.match(dashboardSource, new RegExp(label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) } }) test('首页不再包含通用模板示例内容', () => { for (const sample of [ '项目数', '团队内排名', '项目访问', 'Alipay', 'Angular', 'Ant Design', 'XX 指数', '吴彦祖' ]) { assert.doesNotMatch(dashboardSource, new RegExp(sample.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) } }) test('首页使用现有业务报表接口并保留空状态策略', () => { for (const dependency of [ '@/api/business/inbound', '@/api/business/shipment', '@/api/business/return', '@/api/report/palletInventory', '@/api/report/shipment' ]) { assert.match(dashboardSource, new RegExp(dependency.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))) } assert.match(dashboardSource, /暂无扫码异常记录/) assert.match(dashboardSource, /loadDashboardData/) }) test('首页快捷入口使用动态菜单注册的页面路径', () => { for (const route of [ '/businessOperation/inbound', '/businessOperation/filling', '/businessOperation/shipment', '/businessOperation/usage', '/businessOperation/return', '/businessReport/palletInventory', '/businessReport/palletTrace', '/businessMaster/warehouse' ]) { assert.match(dashboardSource, new RegExp(route.replace(/[.*+?^${}()|[\\]\\]/g, '\\$&'))) } })