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(relPath: string): string { return fs.readFileSync(path.join(adminRoot, relPath), 'utf-8'); } 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. Workplace 根容器必须全宽自然左对齐,严禁 margin: 0 auto 产生脱节白区', () => { const styles = read('src/pages/dashboard/workplace/style/index.module.less'); // 必须全宽 assert.ok(styles.includes('width: 100%'), 'Workplace 根元素必须 width: 100%'); // 严禁在 .page 根容器使用 margin: 0 auto,防止在大屏产生 200px+ 的左侧留白与错位 const pageRuleMatch = styles.match(/\.page\s*\{([^}]+)\}/); assert.ok(pageRuleMatch, '必须包含 .page 规则'); const pageRule = pageRuleMatch[1]; assert.ok( !pageRule.includes('margin: 0 auto') && !pageRule.includes('margin:0 auto'), 'Workplace .page 严禁使用 margin: 0 auto 导致与面包屑脱节错位' ); assert.ok( !pageRule.includes('max-width: 1200px'), 'Workplace 作为复杂工作台仪表盘不应在宽屏下硬锁 1200px 造成两侧悬空' ); }); test('2. 转化漏斗 (Conversion Funnel) 必须具有高对比度轨道底色、增厚条与流转连贯设计', () => { const styles = read('src/pages/dashboard/workplace/style/index.module.less'); const tsx = read('src/pages/dashboard/workplace/index.tsx'); // 轨道背景不可仅为近乎隐形的 omni-color-surface,必须有明显底色(如 rgba(11, 92, 255, 0.08) 或边框) assert.ok( styles.includes('rgba(11, 92, 255') || styles.includes('--omni-color-primary-soft'), '漏斗条轨道槽必须具备清晰可见的对比度底色' ); // 漏斗条高度提升至至少 6px assert.ok( styles.includes('height: 6px') || styles.includes('height: 8px'), '漏斗条高度必须至少 6px 提升视觉分量' ); // 必须展示漏斗转化比率或流转指标 assert.ok( tsx.includes('funnelRate') || tsx.includes('funnelRatio') || tsx.includes('funnelMeta'), '漏斗各步骤必须展示转化比率或流转说明' ); }); test('3. 快捷导航卡片副标题必须具备单行文本防截断样式', () => { const styles = read('src/pages/dashboard/workplace/style/index.module.less'); assert.ok( styles.includes('text-overflow: ellipsis') || styles.includes('overflow: hidden'), '快捷卡片副标题必须具备溢出隐藏保护' ); assert.ok( styles.includes('white-space: nowrap'), '快捷卡片副标题必须保持单行不发生难看的断字折行' ); }); test('4. 零 any,零 emoji,符合国际化现代商务规范', () => { const tsx = read('src/pages/dashboard/workplace/index.tsx'); const styles = read('src/pages/dashboard/workplace/style/index.module.less'); assert.ok(!/\bany\b/.test(tsx), 'Workplace 代码严禁使用 any'); assert.ok(!EMOJI_RE.test(tsx), 'Workplace 代码严禁使用 emoji'); assert.ok(!EMOJI_RE.test(styles), 'Workplace 样式严禁使用 emoji'); });