cmvr-wms/mobile-app/tests/appearance.test.mjs
lixiaolong 149bde836f feat(assistant): 扩展业务助手功能支持更多文档类型和业务场景
- 新增 PDF 文档支持,包括格式校验和完整性检查
- 扩展 Word、TXT 和 ZIP 格式附件处理能力
- 添加 Excel 附件可选择仅作为业务文件不解析行数据
- 实现业务助手表格布局配置新增库存和预算字段
- 集成通知、反馈通知等新的业务助手动作类型
- 完善部门管理包含父级部门和排序字段支持
- 增强业务规则校验涵盖更多系统管理场景
- 优化附件上传限制提示信息更准确
- 添加生成文件下载的安全性校验机制
- 扩展测试覆盖确保各业务动作规则正确性
2026-10-18 08:49:30 +08:00

12 lines
1.1 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {darkTheme,lightTheme} from '../src/core/appearance.ts';
function luminance(color){let hex=color.slice(1);if(hex.length===3)hex=hex.split('').map(c=>c+c).join('');const rgb=[0,2,4].map(i=>parseInt(hex.slice(i,i+2),16)/255).map(c=>c<=.04045?c/12.92:((c+.055)/1.055)**2.4);return rgb[0]*.2126+rgb[1]*.7152+rgb[2]*.0722;}
function contrast(a,b){const x=luminance(a),y=luminance(b);return (Math.max(x,y)+.05)/(Math.min(x,y)+.05);}
test('normal-sized foregrounds in both themes retain readable contrast',()=>{
for(const theme of [lightTheme,darkTheme])for(const [foreground,background] of [['text','bg'],['text','card'],['muted','card'],['muted','bg'],['onAccent','accent'],['accent','soft']])assert.ok(contrast(theme[foreground],theme[background])>=4.5,`${foreground}/${background} contrast ${contrast(theme[foreground],theme[background])}`);
});
test('brand hero retains white-text contrast instead of using the light dark-mode accent',()=>{
for(const theme of [lightTheme,darkTheme])assert.ok(contrast('#ffffff',theme.hero)>=4.5);
});