feat: 修复测试套件问题并添加Woodpecker CI配置

- 修复API测试认证问题:创建全局认证设置,更新Playwright配置
- 优化回归测试稳定性:增加超时时间到15秒,修复定位器
- 创建Woodpecker CI工作流:CI、部署和质量门禁配置
- 添加Jest配置和测试脚本
- 移除登录页面的默认账号密码显示(安全问题修复)
This commit is contained in:
张翔
2026-03-09 10:26:02 +08:00
parent 96c96fe75d
commit 6d92024b63
68 changed files with 5584 additions and 167 deletions
+10 -13
View File
@@ -20,11 +20,11 @@ function hexToRgb(hex: string): ColorRGB {
function getLuminance(rgb: ColorRGB): number {
const { r, g, b } = rgb;
const a = [r, g, b].map(v => {
v /= 255;
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
const values = [r, g, b].map(v => {
const normalized = v / 255;
return normalized <= 0.03928 ? normalized / 12.92 : Math.pow((normalized + 0.055) / 1.055, 2.4);
});
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
return values[0]! * 0.2126 + values[1]! * 0.7152 + values[2]! * 0.0722;
}
export function calculateContrastRatio(foreground: string, background: string): number {
@@ -43,21 +43,18 @@ export function calculateContrastRatio(foreground: string, background: string):
export function meetsWCAGStandard(
foreground: string,
background: string,
level: 'AA' | 'AAA',
textSize: 'normal' | 'large'
level: 'AA' | 'AAA' = 'AA',
textSize: 'normal' | 'large' = 'normal'
): ContrastResult {
const ratio = calculateContrastRatio(foreground, background);
let requiredRatio: number;
if (level === 'AA') {
requiredRatio = textSize === 'normal' ? 4.5 : 3;
} else {
requiredRatio = textSize === 'normal' ? 7 : 4.5;
}
const requiredRatio = level === 'AAA'
? (textSize === 'large' ? 4.5 : 7)
: (textSize === 'large' ? 3 : 4.5);
return {
passes: ratio >= requiredRatio,
ratio,
requiredRatio
requiredRatio,
};
}