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 [ '扫描托盘码', '快捷作业', '新建作业', '在库托盘', '客户现场在用', '今日发货', '待处理', '托盘流转', '装填与发货', '临期预警', '仓库库存', '最近动态', '仓库入库', '工厂装填', '发货出库', '现场使用', '退回仓库', '托盘追溯', '扫码异常' ]) { 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, '\\$&'))) } })