Files
aigc-home/e2e/fpages.mjs
T
总工andmultica-agent d882fd62d8 feat(ui): F批——其余页面融合收口与整站规范统一 (HEL-656)
- 移除 Calliope 旧壳死代码:/project/[id] 旧四段编辑器页面与 9 个遗留组件
  (NavRail/StoryStage/AssetsStage/ScriptStage/QueueStage/ActivityPanel/
  JobRow/AssetThumb/ProjectCard),/projects 死页面(308→/ 已有)
- 素材库 /library 迁入 AppShell 新壳:a-chip 筛选、ui/Modal、ConfirmDialog
  实心红两级删除、窄屏单列;移除 A 时期 308→/ 重定向;导航轨/更多菜单新增入口
- 智能体子系统去杂色:agentPalette 默认紫→中性、回退色板收敛为 avatar 五色族;
  AgentChat 气泡按 §3.2/3.6(用户 bg-3/Agent bg-2+line)、进行中指示改青、
  紫色空态图标清除;AgentComposer 天蓝/金芯片收敛
- 首页/工作台/五面板/StageStepper/PromptBlock/JobChip 类名收敛到全局 a-btn/
  a-input/a-tag/field;Stepper 补金色当前下划+已确认✓;镜头序号按规范用
  accent-lo+mono;分页/工作台选择页金色越界改中性或青
- 金色纪律修正:次级文字操作(重试/测试/链接)与必填星标、任务「测试」标签
  去金色;「默认」金标签按 §3.9 保留
- 断点收敛:1023/1279/900/780/700/640 → 1180/760(1440 增强保留)
- canvas/build-scene 可用级 ≤760 纵向堆叠适配 + 硬编码色/旧 fallback 清理;
  AppHeader 去 Calliope 品牌与死链
- favicon 收口:static/favicon.png 金色品牌图标,移除 204 stub 与构建豁免
- i18n 七语种 +3 key(shell.navLibrary/library.loadError/library.subtitle)全对齐
- 新增 e2e/fpages.mjs:F 页面三档走查/重定向/五段导入编辑/规范色断言 38 项

Co-authored-by: multica-agent <github@multica.ai>
2026-09-30 16:29:47 +08:00

177 lines
7.7 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(240,180,92)', editedColor === 'rgb(240, 180, 92)', 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 ----------
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 });
await page.goto(`${BASE}${route}`, { waitUntil: 'networkidle' }).catch(() => {});
await page.waitForTimeout(700);
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(170, 178, 197)', 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);