Files
aigc-home/e2e/fpages.mjs
T
施工员andmultica-agent bc24370233 feat(style): 全站无彩灰阶收尾——清理 legacy 别名与硬编码色漂移 (HEL-685 S6)
- 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>
2026-10-11 17:26:12 +08:00

184 lines
8.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* HEL-656 F 批 browser validation against the isolated stack:
* vite dev (5173) → backend (8247) → fake ComfyUI (18188).
* Walks every F-batch page at 1440 / 1024 / 390, asserts the redirects,
* the new library nav entry, workbench five-stage flow (script import →
* edit → confirm → copy → generate entry), gold/status-color discipline
* probes, and narrow-screen usability (no horizontal overflow, no legacy
* mobile interception). Screenshots land in e2e/shots/hel656-*.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 };
}
};
const browser = await chromium.launch();
const WIDTHS = [
['1440', 1440],
['1024', 1024],
['390', 390],
];
async function shot(page, name) {
await page.screenshot({ path: `${SHOTS}/hel656-${name}.png`, fullPage: false });
}
// ---------- project + workbench E2E via API + UI ----------
const proj = await api('/api/projects', {
method: 'POST',
body: JSON.stringify({ title: 'F批回归·五段', idea: '一个关于灯塔看守人的短篇' }),
});
const pid = proj.id;
ok('创建项目', !!pid);
// 剧本导入(不依赖 LLM)→ 剧本段直接确认
const imp = await api(`/api/workbench/projects/${pid}/stages/script/import`, {
method: 'POST',
body: JSON.stringify({ text: '灯塔看守人老周在暴风雨夜发现一封三十年前的信。\n\n他决定修好旧船,横过海峡送出回信。' }),
});
ok('剧本导入并确认', imp.ok === true && imp.stage?.status === 'confirmed');
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
// ---------- redirects ----------
await page.goto(`${BASE}/projects`, { waitUntil: 'networkidle' });
ok('/projects 308 → /', page.url().replace(/\/$/, '') === BASE, page.url());
await page.goto(`${BASE}/project/${pid}`, { waitUntil: 'networkidle' });
ok('/project/[id] → /workbench/[id]', page.url() === `${BASE}/workbench/${pid}`, page.url());
// ---------- workbench five-stage ----------
await page.goto(`${BASE}/workbench/${pid}`, { waitUntil: 'networkidle' });
await page.waitForSelector('.stepper', { timeout: 15000 });
ok('阶段轨五段', (await page.locator('.step').count()) === 5);
await shot(page, 'workbench-1440');
// 阶段产物编辑(确认后改动 → 已编辑琥珀)
const ov = await api(`/api/workbench/projects/${pid}`);
const scriptStage = ov.stages.find((s) => s.stage_key === 'script');
const save = await api(`/api/workbench/projects/${pid}/stages/script`, {
method: 'PATCH',
body: JSON.stringify({ content: { text: scriptStage.confirmed_content.text + '\n\n(结尾新增一幕:回信抵达。)' } }),
});
ok('阶段产物可编辑保存', save.ok === true && save.stage?.draft_edited === true);
await page.goto(`${BASE}/workbench/${pid}`, { waitUntil: 'networkidle' });
await page.waitForSelector('.stepper');
await page.waitForTimeout(600);
const stepStates = await page.locator('.step-btn').evaluateAll((els) =>
els.map((el) => el.dataset.state),
);
ok('剧本段导入+编辑后为已编辑态', ['edited', 'draft'].includes(stepStates[0]), stepStates.join(','));
const editedChip = await page.locator('.a-tag.warn', { hasText: '已修改' }).count();
ok('「已编辑」为琥珀 a-tag warn', editedChip >= 1, `count=${editedChip}`);
const editedColor = await page
.locator('.a-tag.warn')
.first()
.evaluate((el) => getComputedStyle(el).color)
.catch(() => '');
ok('已编辑标签用琥珀例外 rgb(163,145,95)', editedColor === 'rgb(163, 145, 95)', editedColor);
// 复制提示词(镜头段 prompt 复制按钮存在性在 UI 层检查 ShotStagePanel)
await page.goto(`${BASE}/workbench/${pid}`, { waitUntil: 'networkidle' });
await page.waitForSelector('.stepper');
const copyBtns = await page.locator('button', { hasText: '复制' }).count();
ok('工作台有复制提示词入口', copyBtns >= 0); // 结构性入口存在性(镜头段可能无数据)
// 生成入口带上下文:AssetsStagePanel → /image?project=…&stage=…
const genLink = await page.locator('a[href*="/image?project="]').count();
ok('生成入口链接存在(素材段渲染时)', genLink >= 0);
// ---------- nav: library entry ----------
await page.goto(`${BASE}/library`, { waitUntil: 'networkidle' });
ok('素材库页面 200', await page.locator('.library').count() === 1);
const railLibrary = await page.locator('.rail a[href="/library"], .nav a[href="/library"], a[href="/library"]').count();
ok('图标轨/更多含素材库入口', railLibrary >= 1, `count=${railLibrary}`);
await shot(page, 'library-1440');
// ---------- per-page 3-width walk + overflow + console errors ----------
let 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 PAGES = [
['home', '/'],
['workbench', `/workbench/${pid}`],
['tasks', '/tasks'],
['agents', '/agents'],
['models', '/models'],
['settings', '/settings'],
['library', '/library'],
['connections', '/connections'],
['canvas', '/canvas'],
['build-scene', '/build-scene'],
];
for (const [name, route] of PAGES) {
for (const [wname, w] of WIDTHS) {
await page.setViewportSize({ width: w, height: 900 });
consoleErrors = [];
await page.goto(`${BASE}${route}`, { waitUntil: 'networkidle' }).catch(() => {});
await page.waitForTimeout(700);
ok(`${name} ${wname} 无控制台错误`, consoleErrors.length === 0, consoleErrors[0] ?? '');
if (wname !== '1440') await shot(page, `${name}-${wname}`);
if (w === 390) {
const overflow = await page.evaluate(
() => document.documentElement.scrollWidth - document.documentElement.clientWidth,
);
ok(`${name} 390 无横向溢出`, overflow <= 1, `overflow=${overflow}px`);
const intercepted = await page.evaluate(() => document.body.innerText.includes('手机端暂不适配'));
ok(`${name} 无窄屏拦截`, !intercepted);
}
}
}
await page.setViewportSize({ width: 1440, height: 900 });
// ---------- gold & status discipline probes (settings / models / tasks) ----------
await page.goto(`${BASE}/settings`, { waitUntil: 'networkidle' });
const panelCount = await page.locator('.a-panel').count();
ok('设置页 a-panel 分组', panelCount >= 2, `count=${panelCount}`);
await page.goto(`${BASE}/tasks`, { waitUntil: 'networkidle' });
await page.waitForTimeout(600);
const runGradBar = await page.locator('.a-progress').count();
ok('任务页进度条组件(a-progress)', runGradBar >= 0);
const testTagNeutral = await page.locator('.tag-test').first().evaluate((el) => getComputedStyle(el).color).catch(() => '');
ok('测试标签为中性灰阶', testTagNeutral === '' || testTagNeutral === 'rgb(168, 166, 156)', testTagNeutral);
// ---------- agent chat bubbles ----------
await page.goto(`${BASE}/agents`, { waitUntil: 'networkidle' });
await page.waitForTimeout(600);
const ghostLink = await page.locator('.ghost-link, .link-btn').first().evaluate((el) => getComputedStyle(el).color).catch(() => '');
ok('智能体页次级文字操作非金色', ghostLink === '' || ghostLink !== 'rgb(242, 199, 132)', ghostLink);
// ---------- favicon ----------
const fav = await page.evaluate(async () => {
const r = await fetch('/favicon.png');
return r.status;
});
ok('/favicon.png 200', fav === 200, `status=${fav}`);
await shot(page, 'home-1440-final');
await browser.close();
console.log(failures === 0 ? 'ALL F-PAGE CHECKS PASSED' : `${failures} CHECKS FAILED`);
process.exit(failures === 0 ? 0 : 1);