test: 完成全量32个UI交互测试与侧边栏核心出海业务菜单收敛
这个提交包含在:
70
admin/tests/routes-menu.test.ts
普通文件
70
admin/tests/routes-menu.test.ts
普通文件
@@ -0,0 +1,70 @@
|
||||
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';
|
||||
import { routes } from '../src/routes.ts';
|
||||
|
||||
const adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const layoutPath = path.join(adminRoot, 'src/layout.tsx');
|
||||
|
||||
const CORE_BIZ_MODULES = [
|
||||
'dashboard',
|
||||
'card',
|
||||
'crm',
|
||||
'ai',
|
||||
'nfc',
|
||||
'team',
|
||||
'settings-biz',
|
||||
'user',
|
||||
];
|
||||
|
||||
const UNRELATED_DEMO_MODULES = [
|
||||
'visualization',
|
||||
'list',
|
||||
'form',
|
||||
'profile',
|
||||
'result',
|
||||
'exception',
|
||||
];
|
||||
|
||||
test('1. 核心出海业务菜单必须保留在侧边栏正常展示 (ignore !== true)', () => {
|
||||
for (const key of CORE_BIZ_MODULES) {
|
||||
const route = routes.find((item) => item.key === key);
|
||||
assert.ok(route, `routes.ts 必须存在核心业务模块: ${key}`);
|
||||
assert.notEqual(
|
||||
route.ignore,
|
||||
true,
|
||||
`核心业务模块 ${key} 不应被 ignore,必须展示在菜单中`
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('2. 与出海业务无关的模板演示 Demo 菜单必须配置 ignore: true 进行隐藏', () => {
|
||||
for (const key of UNRELATED_DEMO_MODULES) {
|
||||
const route = routes.find((item) => item.key === key);
|
||||
if (route) {
|
||||
assert.equal(
|
||||
route.ignore,
|
||||
true,
|
||||
`与需求无关的模板模块 ${key} 必须配置 ignore: true 隐藏`
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('3. layout.tsx 必须为核心业务模块配置对应的 Arco 矢量图标', () => {
|
||||
assert.ok(fs.existsSync(layoutPath), '必须存在 layout.tsx');
|
||||
const content = fs.readFileSync(layoutPath, 'utf-8');
|
||||
|
||||
// 必须映射业务模块图标
|
||||
assert.ok(content.includes("'card'"), "layout.tsx 必须为 'card' 模块配置图标");
|
||||
assert.ok(content.includes("'crm'"), "layout.tsx 必须为 'crm' 模块配置图标");
|
||||
assert.ok(content.includes("'ai'"), "layout.tsx 必须为 'ai' 模块配置图标");
|
||||
assert.ok(content.includes("'nfc'"), "layout.tsx 必须为 'nfc' 模块配置图标");
|
||||
assert.ok(content.includes("'team'"), "layout.tsx 必须为 'team' 模块配置图标");
|
||||
assert.ok(
|
||||
content.includes("'settings-biz'"),
|
||||
"layout.tsx 必须为 'settings-biz' 模块配置图标"
|
||||
);
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户