72 行
2.6 KiB
TypeScript
72 行
2.6 KiB
TypeScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
|
|
function read(rel: string): string {
|
|
return fs.readFileSync(path.join(adminRoot, rel), 'utf8');
|
|
}
|
|
|
|
test('1. 登录表单样式必须大气宽适并符合设计规范', () => {
|
|
const style = read('src/pages/login/style/index.module.less');
|
|
|
|
// 必须扩展表单宽度至 400px 以上,杜绝 320px 局促感
|
|
assert.ok(
|
|
/width:\s*(400|420|440|460|480)px/.test(style),
|
|
'登录表单宽度必须在 400px 以上,显得更宽适大气'
|
|
);
|
|
|
|
// 必须包含输入框或按钮高度 44px 标准尺寸
|
|
assert.ok(
|
|
style.includes('44px'),
|
|
'交互元素必须包含 44px 触控尺寸'
|
|
);
|
|
|
|
// 严禁纯黑 #000
|
|
assert.ok(!style.includes('#000;'), '严禁使用纯黑 #000');
|
|
});
|
|
|
|
test('2. 彻底去除模板化 AI 味与外部廉价插画', () => {
|
|
const banner = read('src/pages/login/banner.tsx');
|
|
|
|
// 彻底移除 byteimg 外部模板插画
|
|
assert.ok(
|
|
!banner.includes('p1-arco.byteimg.com'),
|
|
'严禁使用 Arco 外部模板图纸插画'
|
|
);
|
|
|
|
// 必须包含 OmniCard 全球商务品牌核心能力(全球覆盖、访客雷达、安全合规)
|
|
assert.ok(
|
|
banner.includes('Global') || banner.includes('global') || banner.includes('Radar') || banner.includes('radar'),
|
|
'左侧品牌看板必须包含全球商业与访客雷达相关能力陈列'
|
|
);
|
|
|
|
// 严禁 emoji 作为图标
|
|
const emojiRegex = /[\u{1F300}-\u{1F6FF}\u{1F900}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;
|
|
assert.ok(!emojiRegex.test(banner), 'Banner 中严禁使用 emoji');
|
|
});
|
|
|
|
test('3. 登录主页面必须支持多语言切换与品牌标识', () => {
|
|
const index = read('src/pages/login/index.tsx');
|
|
|
|
// 页面必须包含多语言选择入口
|
|
assert.ok(
|
|
index.includes('Select') || index.includes('Dropdown') || index.includes('Radio') || index.includes('lang'),
|
|
'登录主页面必须支持语言切换'
|
|
);
|
|
|
|
// 严禁 any
|
|
assert.ok(!/\bany\b/.test(index), 'index.tsx 严禁使用 any');
|
|
});
|
|
|
|
test('4. 登录表单核心逻辑依然与 Cool-Admin 契约兼容且无 any', () => {
|
|
const form = read('src/pages/login/form.tsx');
|
|
|
|
assert.ok(form.includes('/api/admin/base/open/login'), '接口路径保持不变');
|
|
assert.ok(form.includes('size="large"') || form.includes("size={'large'}"), '输入框采用大尺寸以显大气');
|
|
assert.ok(!/\bany\b/.test(form), 'form.tsx 严禁使用 any');
|
|
});
|