- app.css 删除 8 个无引用 legacy 别名,新增 --id-1..5 身份灰阶实色阶 - 画布去紫罗兰二级 palette(tokens.css 删除,改用全站 token) - 画布/镜头台/智能体/omni/视频组件硬编码色全部归位 token - agentPalette 彩色身份色改为显影灰阶 --id 阶;修复 3 处相纸白底白字不可读 - WorkflowLibrary 试运行抽屉焦点还原(异步禁用触发键丢焦)修复 - e2e: fpages/import 色值断言对齐现行 token;新增 hel685 走查脚本 (1440/1024/390 截图 + 控制台错误 + 减动效 + 键盘焦点 + 对比度探针); pagination 空库自举;fpages 增加逐页控制台错误检查 Co-authored-by: multica-agent <github@multica.ai>
211 lines
8.4 KiB
JavaScript
211 lines
8.4 KiB
JavaScript
/* HEL-685 S6 全站走查:1440/1024/390 截图 + 减动效 / 键盘焦点 / 对比度探针。
|
||
* Runs against the isolated stack (vite 5173 → backend 8247 → fake ComfyUI
|
||
* 18188). Screenshots land in e2e/shots/hel685-*.png. */
|
||
import { chromium } from 'playwright';
|
||
import fs from 'node:fs';
|
||
import path from 'node:path';
|
||
import { fileURLToPath } from 'node:url';
|
||
|
||
const ROOT = path.dirname(fileURLToPath(import.meta.url));
|
||
const SHOTS = path.join(ROOT, 'shots');
|
||
fs.mkdirSync(SHOTS, { recursive: true });
|
||
const BASE = 'http://127.0.0.1:5173';
|
||
const API = 'http://127.0.0.1:8247';
|
||
|
||
let failures = 0;
|
||
function ok(name, cond, extra = '') {
|
||
const line = `${cond ? 'PASS' : 'FAIL'} ${name}${extra ? ' — ' + extra : ''}`;
|
||
console.log(line);
|
||
if (!cond) failures++;
|
||
}
|
||
|
||
const api = async (p, init) => {
|
||
const r = await fetch(API + p, { headers: { 'Content-Type': 'application/json' }, ...init });
|
||
const body = await r.text();
|
||
try {
|
||
return JSON.parse(body);
|
||
} catch {
|
||
return { raw: body, status: r.status };
|
||
}
|
||
};
|
||
|
||
// ---------- fixtures: project + confirmed script + canvas ----------
|
||
const proj = await api('/api/projects', {
|
||
method: 'POST',
|
||
body: JSON.stringify({ title: 'S6走查·灯塔', idea: '灯塔看守人的短篇' }),
|
||
});
|
||
const pid = proj.id;
|
||
await api(`/api/workbench/projects/${pid}/stages/script/import`, {
|
||
method: 'POST',
|
||
body: JSON.stringify({
|
||
text: '灯塔看守人老周在暴风雨夜发现一封三十年前的信。\n\n他修好旧船,横过海峡,把回信送到对岸。',
|
||
}),
|
||
});
|
||
const canvas = await api('/api/canvas', { method: 'POST', body: JSON.stringify({ project_id: pid }) });
|
||
const cid = canvas.canvas?.id ?? canvas.id;
|
||
ok('走查项目与画布就绪', !!pid && !!cid, `pid=${pid} cid=${cid}`);
|
||
|
||
const browser = await chromium.launch();
|
||
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||
const page = await ctx.newPage();
|
||
const consoleErrors = [];
|
||
page.on('console', (m) => {
|
||
if (m.type() === 'error') consoleErrors.push(m.text().slice(0, 160));
|
||
});
|
||
page.on('pageerror', (e) => consoleErrors.push(String(e).slice(0, 160)));
|
||
|
||
const shot = (name) => page.screenshot({ path: `${SHOTS}/hel685-${name}.png` });
|
||
|
||
// ---------- 1440 desktop set (compare against HEL-679 / theme-1) ----------
|
||
const DESK = [
|
||
['home-1440', '/'],
|
||
['workbench-1440', `/workbench/${pid}`],
|
||
['image-desk-1440', '/image'],
|
||
['video-desk-1440', '/video'],
|
||
['agents-1440', '/agents'],
|
||
['models-1440', '/models'],
|
||
['connections-1440', '/connections'],
|
||
['tasks-1440', '/tasks'],
|
||
['library-1440', '/library'],
|
||
['canvas-1440', `/canvas/${cid}`],
|
||
['build-scene-1440', '/build-scene'],
|
||
];
|
||
for (const [name, route] of DESK) {
|
||
consoleErrors.length = 0;
|
||
await page.goto(`${BASE}${route}`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(700);
|
||
ok(`${name} 无控制台错误`, consoleErrors.length === 0, consoleErrors[0] ?? '');
|
||
await shot(name);
|
||
}
|
||
|
||
// ---------- 1024 / 390 usability set ----------
|
||
const NARROW = [
|
||
['home', '/'],
|
||
['workbench', `/workbench/${pid}`],
|
||
['image-desk', '/image'],
|
||
['video-desk', '/video'],
|
||
['agents', '/agents'],
|
||
['tasks', '/tasks'],
|
||
['canvas', `/canvas/${cid}`],
|
||
];
|
||
for (const [name, route] of NARROW) {
|
||
for (const w of [1024, 390]) {
|
||
await page.setViewportSize({ width: w, height: 900 });
|
||
await page.goto(`${BASE}${route}`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(600);
|
||
await shot(`${name}-${w}`);
|
||
if (w === 390) {
|
||
const overflow = await page.evaluate(
|
||
() => document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
||
);
|
||
ok(`${name} 390 无横向溢出`, overflow <= 1, `overflow=${overflow}px`);
|
||
}
|
||
}
|
||
}
|
||
await page.setViewportSize({ width: 1440, height: 900 });
|
||
|
||
// ---------- reduce-motion probes (顶栏开关 data-reduce=1) ----------
|
||
await page.goto(`${BASE}/`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(400);
|
||
await page.evaluate(() => (document.documentElement.dataset.reduce = '1'));
|
||
const dur = await page.locator('.a-btn').first().evaluate((el) => getComputedStyle(el).transitionDuration);
|
||
ok('减动效:过渡时长塌缩到 ≤120ms', parseFloat(dur) <= 0.12, dur);
|
||
const spinRule = await page.evaluate(() => {
|
||
const ring = document.createElement('div');
|
||
ring.className = 'a-tile-ring';
|
||
ring.innerHTML = '<i></i>';
|
||
document.body.appendChild(ring);
|
||
const name = getComputedStyle(ring.firstChild).animationName;
|
||
ring.remove();
|
||
return name;
|
||
});
|
||
ok('减动效:上传旋转动画禁用(animation-name=none)', spinRule === 'none', spinRule);
|
||
await page.evaluate(() => delete document.documentElement.dataset.reduce);
|
||
|
||
// ---------- keyboard focus probe ----------
|
||
await page.goto(`${BASE}/tasks`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(400);
|
||
await page.keyboard.press('Tab');
|
||
const focusRing = await page.evaluate(() => {
|
||
const el = document.activeElement;
|
||
if (!el) return null;
|
||
const cs = getComputedStyle(el);
|
||
return cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) >= 1.5 ? cs.outlineColor : null;
|
||
});
|
||
ok('键盘焦点显示相纸白焦点圈', focusRing === 'rgb(245, 244, 238)', String(focusRing));
|
||
|
||
// ---------- text contrast probes (WCAG AA on real elements) ----------
|
||
await page.goto(`${BASE}/`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(600);
|
||
const lum = (rgbStr) => {
|
||
const m = rgbStr.match(/\d+/g).map(Number);
|
||
const [r, g, b] = m.map((v) => {
|
||
const c = v / 255;
|
||
return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
|
||
});
|
||
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||
};
|
||
const ratio = (a, b) => {
|
||
const l1 = lum(a);
|
||
const l2 = lum(b);
|
||
const [hi, lo] = l1 > l2 ? [l1, l2] : [l2, l1];
|
||
return (hi + 0.05) / (lo + 0.05);
|
||
};
|
||
const probeText = async (sel, label, min = 4.5) => {
|
||
const el = page.locator(sel).first();
|
||
if (!(await el.count())) return ok(`${label} 探针元素存在`, false, sel);
|
||
const { color, bg } = await el.evaluate((e) => {
|
||
const bgOf = (node) => {
|
||
let n = node;
|
||
while (n && n !== document.documentElement) {
|
||
const bg = getComputedStyle(n).backgroundColor;
|
||
if (bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') return bg;
|
||
n = n.parentElement;
|
||
}
|
||
return 'rgb(33, 33, 32)';
|
||
};
|
||
return { color: getComputedStyle(e).color, bg: bgOf(e) };
|
||
});
|
||
const r = ratio(color, bg);
|
||
ok(`${label} 对比度 ${r.toFixed(2)}:1 ≥ ${min}`, r >= min, `${color} on ${bg}`);
|
||
};
|
||
await probeText('body', '首页正文文字');
|
||
await page.goto(`${BASE}/settings`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(600);
|
||
await probeText('.a-panel-lead', '面板次要文字(--text-2 级)');
|
||
await page.goto(`${BASE}/`, { waitUntil: 'networkidle' }).catch(() => {});
|
||
await page.waitForTimeout(400);
|
||
// .a-btn.primary 用渐变背景(backgroundColor 透明),对 --accent 实色计算
|
||
const btnContrast = await page.evaluate(() => {
|
||
const cs = getComputedStyle(document.documentElement);
|
||
const hex = (h) => {
|
||
const s = h.replace('#', '');
|
||
const n = parseInt(s.length === 3 ? s.split('').map((c) => c + c).join('') : s, 16);
|
||
return `rgb(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255})`;
|
||
};
|
||
return { ink: hex(cs.getPropertyValue('--accent-ink').trim()), accent: hex(cs.getPropertyValue('--accent').trim()) };
|
||
});
|
||
const btnRatio = ratio(btnContrast.ink, btnContrast.accent);
|
||
ok(`主按钮文字对比度 ${btnRatio.toFixed(2)}:1 ≥ 4.5`, btnRatio >= 4.5, `${btnContrast.ink} on ${btnContrast.accent}`);
|
||
// agent identity steps all ≥ text-3 floor (computed from :root tokens)
|
||
const idSteps = await page.evaluate(() =>
|
||
['--id-1', '--id-2', '--id-3', '--id-4', '--id-5', '--text-3'].map((v) =>
|
||
getComputedStyle(document.documentElement).getPropertyValue(v).trim(),
|
||
),
|
||
);
|
||
const bg2 = await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('--bg-2').trim());
|
||
const toRgb = (hex) => {
|
||
const h = hex.replace('#', '');
|
||
const n = parseInt(h.length === 3 ? h.split('').map((c) => c + c).join('') : h, 16);
|
||
return `rgb(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255})`;
|
||
};
|
||
for (let i = 0; i < idSteps.length; i++) {
|
||
const r = ratio(toRgb(idSteps[i]), toRgb(bg2));
|
||
const label = i < 5 ? `身份灰阶 --id-${i + 1}` : '--text-3 下限';
|
||
ok(`${label} 在面板底上 ≥4.5:1(${r.toFixed(2)}:1)`, r >= 4.5);
|
||
}
|
||
|
||
await browser.close();
|
||
console.log(failures === 0 ? 'ALL HEL-685 WALKTHROUGH CHECKS PASSED' : `${failures} CHECKS FAILED`);
|
||
process.exit(failures === 0 ? 0 : 1);
|