- 模块一: 出海案例作品集、博客动态发布、人名发音语音条、RTL阿语多语言切换 - 模块二: AI顾问人设配置、行业术语库润色、RAG切片沙盒调试、流式会话与意向留资卡片 - 模块三: 全球访客雷达大屏、多维加权意向算分、外部CRM对接推送、团队公海池流转 - 模块四: 移动端NFC安全挂失、NFC动态路由规则配置、动态防伪验签、展会制卡Zip批量导出 - 模块五: 组织架构与名片分配、移动端个人中心设置、离职交接与历史线索迁移、安全审计日志 - 模块六: Stripe国际信用卡订阅Webhook、独立二级域名与SSL检测、坐席配额预警、多币种发票 - 模块七: 纸质名片OCR解析入库、国际商务日程RFC 5545 ICS日历、微官网离线SWR预加载、展会实时排行榜大屏 - 模块八: 全球出海SEO OpenGraph元标签注入与社交爬虫探测、30点端到端全链路业务流集成测试套件
117 行
4.2 KiB
TypeScript
117 行
4.2 KiB
TypeScript
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 defaultI18n from '../src/locale/index.ts';
|
|
|
|
const adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const auditPagePath = path.join(adminRoot, 'src/pages/settings/audit-logs/index.tsx');
|
|
const auditLocalePath = path.join(
|
|
adminRoot,
|
|
'src/pages/settings/audit-logs/locale/index.ts'
|
|
);
|
|
const routesPath = path.join(adminRoot, 'src/routes.ts');
|
|
|
|
function readPage(): string {
|
|
assert.ok(fs.existsSync(auditPagePath), '安全审计日志页面文件必须存在');
|
|
return fs.readFileSync(auditPagePath, 'utf-8');
|
|
}
|
|
|
|
test('1. 路由配置中必须包含 settings/audit-logs 并在主语言包中声明菜单词条', () => {
|
|
assert.ok(fs.existsSync(routesPath), 'routes.ts 必须存在');
|
|
const routesContent = fs.readFileSync(routesPath, 'utf-8');
|
|
|
|
assert.ok(
|
|
routesContent.includes("'settings/audit-logs'") ||
|
|
routesContent.includes('"settings/audit-logs"'),
|
|
'routes.ts 必须注册 settings/audit-logs'
|
|
);
|
|
assert.ok(
|
|
routesContent.includes('menu.settings.auditLogs'),
|
|
'routes.ts 必须使用 menu.settings.auditLogs 作为国际化 key'
|
|
);
|
|
|
|
assert.equal(
|
|
defaultI18n['en-US']['menu.settings.auditLogs'],
|
|
'Audit Logs',
|
|
'en-US 主词典必须包含 menu.settings.auditLogs'
|
|
);
|
|
assert.ok(
|
|
defaultI18n['zh-CN']['menu.settings.auditLogs'] === '安全审计' ||
|
|
defaultI18n['zh-CN']['menu.settings.auditLogs'] === '审计日志',
|
|
'zh-CN 主词典必须包含 menu.settings.auditLogs'
|
|
);
|
|
});
|
|
|
|
test('2. settings/audit-logs 页面必须采用 Arco Table, DatePicker, Select, Tag, Input 等官方组件', () => {
|
|
const content = readPage();
|
|
|
|
assert.ok(content.includes('Table'), '必须使用 Arco Table');
|
|
assert.ok(content.includes('DatePicker'), '必须使用 Arco DatePicker');
|
|
assert.ok(content.includes('Select'), '必须使用 Arco Select');
|
|
assert.ok(content.includes('Tag'), '必须使用 Arco Tag');
|
|
assert.ok(content.includes('Input'), '必须使用 Arco Input/Input.Search');
|
|
assert.ok(
|
|
content.includes("from '@arco-design/web-react'"),
|
|
'必须从 @arco-design/web-react 引入组件'
|
|
);
|
|
assert.ok(
|
|
content.includes('admin/base/audit/page') ||
|
|
content.includes('/api/admin/base/audit/page'),
|
|
'必须请求 POST /api/admin/base/audit/page'
|
|
);
|
|
assert.ok(
|
|
content.includes('code === 1000') || content.includes('code ===1000'),
|
|
'必须按 Cool-Admin code === 1000 判断成功'
|
|
);
|
|
});
|
|
|
|
test('3. 严格遵循瑞士国际主义风格、单一主 CTA、引用设计 Token,且零 any、零 emoji', () => {
|
|
const content = readPage();
|
|
|
|
// 单一主 CTA: 统计 type="primary"
|
|
const primaryButtons = content.match(/type=["']primary["']/g) || [];
|
|
assert.equal(
|
|
primaryButtons.length,
|
|
1,
|
|
'页面必须严格保持单一主 CTA (仅有 1 个 type="primary")'
|
|
);
|
|
|
|
// 严格 Token 引用,禁止硬编码颜色与纯黑
|
|
assert.ok(content.includes('lightColors'), '必须引用 lightColors token');
|
|
assert.ok(
|
|
!/#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})\b/.test(content),
|
|
'禁止硬编码 HEX 颜色值'
|
|
);
|
|
assert.ok(!content.includes('#000'), '禁止纯黑 #000');
|
|
|
|
// 零 any
|
|
assert.ok(!/\bany\b/.test(content), '页面严禁使用 any');
|
|
|
|
// 零 emoji
|
|
assert.ok(
|
|
!/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(content),
|
|
'页面严禁包含 emoji'
|
|
);
|
|
});
|
|
|
|
test('4. settings/audit-logs 语言包必须包含中英文案且零 emoji、零 any', () => {
|
|
assert.ok(fs.existsSync(auditLocalePath), '审计日志语言包文件必须存在');
|
|
const localeContent = fs.readFileSync(auditLocalePath, 'utf-8');
|
|
|
|
assert.ok(localeContent.includes("'en-US'"), '必须包含英文词典');
|
|
assert.ok(localeContent.includes("'zh-CN'"), '必须包含中文词典');
|
|
assert.ok(
|
|
localeContent.includes('menu.settings.auditLogs'),
|
|
'必须声明 menu.settings.auditLogs'
|
|
);
|
|
assert.ok(!/\bany\b/.test(localeContent), '语言包严禁使用 any');
|
|
assert.ok(
|
|
!/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u.test(
|
|
localeContent
|
|
),
|
|
'语言包严禁包含 emoji'
|
|
);
|
|
});
|