补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。 Co-authored-by: Cursor <cursoragent@cursor.com>
178 行
7.5 KiB
TypeScript
178 行
7.5 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';
|
|
|
|
const adminRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const financialPagePath = path.join(adminRoot, 'src/pages/dashboard/financial/index.tsx');
|
|
const financialLocalePath = path.join(adminRoot, 'src/pages/dashboard/financial/locale/index.ts');
|
|
const mainLocalePath = path.join(adminRoot, 'src/locale/index.ts');
|
|
const routesPath = path.join(adminRoot, 'src/routes.ts');
|
|
|
|
const EMOJI_RE =
|
|
/[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/u;
|
|
|
|
test('1. routes.ts 必须在 dashboard 下注册 dashboard/financial 且未被 ignore', () => {
|
|
const content = fs.readFileSync(routesPath, 'utf-8');
|
|
assert.ok(content.includes("key: 'dashboard/financial'"), '必须注册 dashboard/financial');
|
|
assert.ok(
|
|
!/key:\s*'dashboard\/financial'[\s\S]{0,80}ignore:\s*true/.test(content),
|
|
'financial 路由必须在侧边栏正常展示'
|
|
);
|
|
});
|
|
|
|
test('2. 主词典与多语言包必须包含 menu.dashboard.financial 翻译', () => {
|
|
const content = fs.readFileSync(mainLocalePath, 'utf-8');
|
|
|
|
assert.ok(
|
|
content.includes("'menu.dashboard.financial'"),
|
|
'主词典必须包含 menu.dashboard.financial 词条'
|
|
);
|
|
});
|
|
|
|
test('3. dashboard/financial 页面必须存在,且具备 COO/CFO 视角切换与 API 对接', () => {
|
|
assert.ok(fs.existsSync(financialPagePath), '必须存在 financial/index.tsx 页面');
|
|
const content = fs.readFileSync(financialPagePath, 'utf-8');
|
|
|
|
// 必须请求商业化分析接口
|
|
assert.ok(
|
|
content.includes('/admin/team/billing/analytics') ||
|
|
content.includes('team/billing/analytics'),
|
|
'必须调用 /admin/team/billing/analytics 统计接口'
|
|
);
|
|
|
|
// 必须按 Cool-Admin code === 1000 判断成功
|
|
assert.ok(
|
|
content.includes('code === 1000') || content.includes('code ===1000'),
|
|
'必须按 Cool-Admin code === 1000 判断成功'
|
|
);
|
|
|
|
// 必须具备运营官 (coo) 与财务官 (cfo) 双视角
|
|
assert.ok(
|
|
content.includes("'coo'") && content.includes("'cfo'"),
|
|
'页面必须支持 coo 与 cfo 视角状态切换'
|
|
);
|
|
|
|
assert.ok(!content.includes('14500'), '禁止硬编码演示 MRR');
|
|
assert.ok(!content.includes('Vanguard Global'), '禁止硬编码演示账单');
|
|
assert.ok(!content.includes('Acme Corp'), '禁止硬编码演示客户');
|
|
assert.ok(!content.includes('Demo Tenant'), '禁止硬编码演示租户');
|
|
assert.ok(!/mrr\s*:\s*[1-9]/.test(content), '禁止写死非零 mrr 演示值');
|
|
assert.ok(
|
|
!/totalInvoiced\s*:\s*[1-9]/.test(content),
|
|
'禁止写死非零 totalInvoiced 演示值'
|
|
);
|
|
assert.ok(
|
|
!/recentLedger\s*:\s*\[[\s\S]*tenantName\s*:/.test(content),
|
|
'禁止在页面内联写死 recentLedger 示例客户'
|
|
);
|
|
|
|
// 必须使用 Arco 核心组件
|
|
assert.ok(content.includes('@arco-design/web-react'), '必须引入 Arco Design');
|
|
assert.ok(content.includes('Table'), '必须包含 Table 表格展示账目流水');
|
|
assert.ok(content.includes('Statistic'), '必须包含 Statistic 核心指标统计组件');
|
|
assert.ok(content.includes('Card'), '必须使用 Card 卡片容器');
|
|
});
|
|
|
|
test('3b. 数字仅来自 analytics 成功 data;失败/非 1000/无 data 必须清空为空态', () => {
|
|
const content = fs.readFileSync(financialPagePath, 'utf-8');
|
|
|
|
assert.ok(
|
|
content.includes('EMPTY_ANALYTICS') || content.includes('emptyAnalytics'),
|
|
'必须具备 EMPTY_ANALYTICS / emptyAnalytics 空态结构'
|
|
);
|
|
assert.ok(
|
|
/mrr\s*:\s*0/.test(content) || /totalInvoiced\s*:\s*0/.test(content),
|
|
'空态汇总指标必须为 0'
|
|
);
|
|
assert.ok(
|
|
/recentLedger\s*:\s*\[\s*\]/.test(content) ||
|
|
/planDistribution\s*:\s*\[\s*\]/.test(content),
|
|
'空态列表必须为空数组'
|
|
);
|
|
assert.ok(
|
|
/setAnalyticsData\(\s*(EMPTY_ANALYTICS|emptyAnalytics)/.test(content),
|
|
'接口失败或非 1000 必须 setAnalyticsData 清空为空态'
|
|
);
|
|
// 禁止非 1000 仍写入 data 的兜底分支(避免残留假数据)
|
|
assert.ok(
|
|
!/else if\s*\([^)]*response\.data\.data[^)]*\)\s*\{[\s\S]*?setAnalyticsData/.test(
|
|
content
|
|
),
|
|
'禁止在 code 非 1000 时仍 setAnalyticsData(response.data.data)'
|
|
);
|
|
});
|
|
|
|
test('3c. 无真实导出接口时不得假 Message.success;须禁用或提示暂不可导出', () => {
|
|
const content = fs.readFileSync(financialPagePath, 'utf-8');
|
|
const localeContent = fs.readFileSync(financialLocalePath, 'utf-8');
|
|
|
|
assert.ok(
|
|
localeContent.includes("'dashboardFinancial.export.unavailable'"),
|
|
'locale 必须包含 dashboardFinancial.export.unavailable'
|
|
);
|
|
assert.ok(
|
|
content.includes("t['dashboardFinancial.export.unavailable']") ||
|
|
content.includes('dashboardFinancial.export.unavailable'),
|
|
'页面必须引用 export.unavailable 文案'
|
|
);
|
|
|
|
// 不得在无真实文件时假装导出成功
|
|
const hasFakeSuccess =
|
|
/Message\.success\s*\(\s*t\[['"]dashboardFinancial\.export\.success['"]\]/.test(
|
|
content
|
|
) ||
|
|
(/handleExport[\s\S]{0,200}Message\.success/.test(content) &&
|
|
!content.includes('/export'));
|
|
assert.ok(!hasFakeSuccess, '无导出接口时禁止 Message.success 假装导出成功');
|
|
|
|
const exportDisabled =
|
|
/disabled[\s\S]{0,80}export|export[\s\S]{0,120}disabled/i.test(content) ||
|
|
content.includes('disabled={true}') ||
|
|
/Button[\s\S]{0,300}disabled/.test(content);
|
|
const exportUnavailableHint =
|
|
content.includes("t['dashboardFinancial.export.unavailable']") ||
|
|
content.includes('dashboardFinancial.export.unavailable');
|
|
assert.ok(
|
|
exportDisabled || exportUnavailableHint,
|
|
'无导出接口时必须禁用导出按钮或提示暂不可导出'
|
|
);
|
|
});
|
|
|
|
test('4. dashboard/financial 必须遵循瑞士国际主义设计规范、Token 与零 any、零 emoji 约束', () => {
|
|
const pageContent = fs.readFileSync(financialPagePath, 'utf-8');
|
|
const localeContent = fs.readFileSync(financialLocalePath, 'utf-8');
|
|
|
|
// 零 any
|
|
assert.ok(!/\bany\b/.test(pageContent), '页面中严禁使用 any 类型');
|
|
assert.ok(!/\bany\b/.test(localeContent), '语言包中严禁使用 any 类型');
|
|
|
|
// 零 emoji
|
|
assert.ok(!EMOJI_RE.test(pageContent), '页面中严禁使用 emoji 符号');
|
|
assert.ok(!EMOJI_RE.test(localeContent), '语言包中严禁使用 emoji 符号');
|
|
|
|
// 单一主 CTA (如导出对账单按钮为唯一的 type="primary")
|
|
const primaryButtons = pageContent.match(/type=["']primary["']/g) || [];
|
|
assert.ok(
|
|
primaryButtons.length <= 1,
|
|
`一屏只允许最多 1 个主 CTA 按钮,当前包含: ${primaryButtons.length}`
|
|
);
|
|
});
|
|
|
|
test('5. 专属语言包 financial/locale/index.ts 必须完备覆盖 COO 与 CFO 专业词汇', () => {
|
|
assert.ok(fs.existsSync(financialLocalePath), '必须存在 financial/locale/index.ts');
|
|
const localeContent = fs.readFileSync(financialLocalePath, 'utf-8');
|
|
|
|
// 核心字段涵盖
|
|
assert.ok(localeContent.includes('cooView'), '必须包含运营官视角词条');
|
|
assert.ok(localeContent.includes('cfoView'), '必须包含财务官视角词条');
|
|
assert.ok(localeContent.includes('mrr'), '必须包含 MRR 词条');
|
|
assert.ok(localeContent.includes('totalInvoiced'), '必须包含开票总额词条');
|
|
assert.ok(localeContent.includes('agingAnalysis'), '必须包含账龄分析词条');
|
|
assert.ok(
|
|
localeContent.includes('export.unavailable'),
|
|
'必须包含导出暂不可用词条'
|
|
);
|
|
});
|