550 lines
19 KiB
JavaScript
550 lines
19 KiB
JavaScript
/** Browser evidence for a foreground, isolated HEL-730 server. */
|
|
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
const { chromium } = await import(
|
|
process.env.PLAYWRIGHT_MODULE || "playwright"
|
|
);
|
|
const out = process.env.HEL730_OUT,
|
|
base = process.env.HEL730_URL;
|
|
const browser = await chromium.launch({
|
|
headless: true,
|
|
args: ["--no-sandbox"],
|
|
});
|
|
const evidence = { errors: [], checks: [], measurements: [] };
|
|
const check = (condition, name) => {
|
|
evidence.checks.push({ name, pass: !!condition });
|
|
if (!condition) throw Error(name);
|
|
};
|
|
let activePage;
|
|
try {
|
|
const context = await browser.newContext({
|
|
viewport: { width: 1440, height: 900 },
|
|
recordVideo: {
|
|
dir: path.join(out, "videos"),
|
|
size: { width: 1440, height: 900 },
|
|
},
|
|
});
|
|
const page = await context.newPage();
|
|
activePage = page;
|
|
page.on("pageerror", (error) => evidence.errors.push(error.message));
|
|
await page.goto(base + "/workflows");
|
|
await page.getByRole("button", { name: "试运行", exact: true }).waitFor();
|
|
await page.keyboard.press("/");
|
|
check(
|
|
await page
|
|
.locator(".workflow-search input")
|
|
.evaluate((el) => el === document.activeElement),
|
|
"workflow / focuses search",
|
|
);
|
|
await page.locator(".workflow-search input").fill("missing-result");
|
|
check(
|
|
await page.getByText("没有匹配的工作流", { exact: true }).isVisible(),
|
|
"search empty state",
|
|
);
|
|
await page.locator(".workflow-search input").fill("");
|
|
check(
|
|
(await page
|
|
.locator(".management-header .icon")
|
|
.first()
|
|
.evaluate((el) => getComputedStyle(el).strokeWidth)) === "1.7px",
|
|
"management icon stroke matches approved 1.7",
|
|
);
|
|
await page.locator(".mg-side .mg-filter").nth(1).hover();
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-filter-hover.png"),
|
|
});
|
|
await page.route("**/api/workflows/*/check", async (route) => {
|
|
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
await route.continue();
|
|
});
|
|
await page
|
|
.getByRole("button", { name: "检查节点与模型", exact: true })
|
|
.click();
|
|
await page.locator(".mg-detail .a-btn.loading").waitFor();
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-check-loading.png"),
|
|
});
|
|
check(
|
|
true,
|
|
"real node check exposes loading feedback under 400ms transport delay",
|
|
);
|
|
await page.locator(".mg-detail .a-btn.loading").waitFor({ state: "hidden" });
|
|
await page.unroute("**/api/workflows/*/check");
|
|
const pinButton = page.locator(".mg-pin").first();
|
|
await pinButton.click();
|
|
check(
|
|
(await pinButton.getAttribute("aria-pressed")) === "true",
|
|
"workflow pin is selected",
|
|
);
|
|
await page.goto(base + "/image", { waitUntil: "networkidle" });
|
|
check(
|
|
(await page
|
|
.locator(".sidebar .icon")
|
|
.first()
|
|
.evaluate((el) => getComputedStyle(el).strokeWidth)) === "1.5px",
|
|
"B1 icon stroke remains 1.5",
|
|
);
|
|
check(
|
|
await page.getByText("置顶工作流", { exact: true }).isVisible(),
|
|
"library pin is shared with B1 creation rail",
|
|
);
|
|
await page.goto(base + "/workflows", { waitUntil: "networkidle" });
|
|
await page.locator(".mg-pin").first().click();
|
|
await page.getByRole("button", { name: "批量标注", exact: true }).click();
|
|
await page
|
|
.getByRole("checkbox", { name: "全选当前列表", exact: true })
|
|
.check();
|
|
await page.getByRole("button", { name: "批量标注", exact: true }).click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-batch-metadata.png"),
|
|
});
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
await page.getByRole("button", { name: "取消选择", exact: true }).click();
|
|
check(
|
|
(await page
|
|
.getByRole("checkbox", { name: "全选当前列表", exact: true })
|
|
.count()) === 0,
|
|
"bulk entry preserves a clean default table",
|
|
);
|
|
const importButton = page.getByRole("button", {
|
|
name: "导入工作流",
|
|
exact: true,
|
|
});
|
|
await importButton.click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-import-open.png"),
|
|
});
|
|
for (let i = 0; i < 12; i++) await page.keyboard.press("Tab");
|
|
check(
|
|
await page
|
|
.getByRole("dialog")
|
|
.evaluate((el) => el.contains(document.activeElement)),
|
|
"import focus remains trapped",
|
|
);
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
check(
|
|
await importButton.evaluate((el) => el === document.activeElement),
|
|
"import focus returns",
|
|
);
|
|
await page
|
|
.getByRole("button", { name: "扫描 / 转换 / 批量导入", exact: true })
|
|
.click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({ path: path.join(out, "interaction-scan-open.png") });
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
await page.getByRole("button", { name: "试运行", exact: true }).click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({ path: path.join(out, "interaction-test-open.png") });
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
await page.goto(base + "/connections");
|
|
await page.getByRole("button", { name: "测试连接", exact: true }).click();
|
|
await page.getByText("连接测试通过", { exact: false }).first().waitFor();
|
|
check(true, "ComfyUI test uses real local fake HTTP");
|
|
await page.getByRole("button", { name: "编辑", exact: true }).first().click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
check(true, "ComfyUI edit modal closes and restores card");
|
|
await page
|
|
.getByRole("button", { name: "图片模型 · 后续", exact: true })
|
|
.click();
|
|
await page.waitForURL("**/connections?tab=image");
|
|
check(
|
|
await page.getByRole("button", { name: "等待接入" }).isDisabled(),
|
|
"cloud image remains disabled",
|
|
);
|
|
await page
|
|
.getByRole("button", { name: "视频模型 · 后续", exact: true })
|
|
.click();
|
|
await page.waitForURL("**/connections?tab=video");
|
|
check(
|
|
await page.getByRole("button", { name: "等待接入" }).first().isDisabled(),
|
|
"cloud video remains disabled",
|
|
);
|
|
await page.goto(base + "/models");
|
|
await page.waitForURL("**/connections?tab=llm");
|
|
await page
|
|
.getByRole("button", { name: "添加大语言模型", exact: true })
|
|
.waitFor();
|
|
check(true, "legacy models redirects to LLM tab");
|
|
await page
|
|
.getByRole("button", { name: "添加大语言模型", exact: true })
|
|
.click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.waitForTimeout(350);
|
|
await page.screenshot({ path: path.join(out, "interaction-llm-add.png") });
|
|
await page.keyboard.press("Escape");
|
|
await page.goto(base + "/tasks");
|
|
await page.locator(".mg-table tbody button").first().click();
|
|
check(
|
|
(await page.locator(".mg-detail h2").textContent())?.length > 0,
|
|
"task details selectable",
|
|
);
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-task-detail.png"),
|
|
});
|
|
await page.goto(base + "/settings");
|
|
await page.locator(".queue-fields input").first().waitFor();
|
|
const queue = page.locator(".queue-fields input").first();
|
|
const original = await queue.inputValue();
|
|
await queue.fill(original === "2" ? "3" : "2");
|
|
await page.getByRole("button", { name: /日光棚/ }).click();
|
|
await page.waitForFunction(
|
|
() => document.documentElement.dataset.theme === "day",
|
|
);
|
|
if (await page.evaluate(() => !!document.startViewTransition)) {
|
|
await page.waitForFunction(() =>
|
|
document.getAnimations().some((a) => a.animationName === "theme-lamp"),
|
|
);
|
|
const duration = await page.evaluate(
|
|
() =>
|
|
document
|
|
.getAnimations()
|
|
.find((a) => a.animationName === "theme-lamp")
|
|
?.effect.getTiming().duration,
|
|
);
|
|
check(duration === 520, "theme lamp duration matches 520ms sample");
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-theme-reveal-frame.png"),
|
|
});
|
|
}
|
|
check(
|
|
(await queue.inputValue()) !== original,
|
|
"theme preserves unsaved settings",
|
|
);
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-settings-draft.png"),
|
|
});
|
|
await page.waitForTimeout(600);
|
|
await page.getByRole("button", { name: "放弃修改", exact: true }).click();
|
|
check(
|
|
(await queue.inputValue()) === original,
|
|
"discard settings restores draft",
|
|
);
|
|
await page
|
|
.getByRole("button", { name: "关闭(减少动效)", exact: true })
|
|
.click();
|
|
await page.getByRole("button", { name: /夜片场/ }).click();
|
|
check(
|
|
await page.evaluate(
|
|
() =>
|
|
document.documentElement.dataset.theme === "night" &&
|
|
document.documentElement.dataset.reduce === "1" &&
|
|
!document.getAnimations().some((a) => a.animationName === "theme-lamp"),
|
|
),
|
|
"reduced motion changes theme immediately",
|
|
);
|
|
await page.getByRole("button", { name: "完整", exact: true }).click();
|
|
await page.evaluate(() => {
|
|
for (const id of ["day", "bluehour", "night"])
|
|
document
|
|
.querySelector('.choices .preview[data-theme="' + id + '"]')
|
|
.closest("button")
|
|
.click();
|
|
});
|
|
await page.waitForTimeout(600);
|
|
check(
|
|
await page.evaluate(
|
|
() => document.documentElement.dataset.theme === "night",
|
|
),
|
|
"rapid theme switching keeps the final choice",
|
|
);
|
|
const advanced = page.locator(".advanced");
|
|
await advanced.locator("summary").click();
|
|
check(
|
|
await advanced.evaluate((el) => el.open),
|
|
"settings advanced controls expand",
|
|
);
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-settings-expanded.png"),
|
|
});
|
|
await advanced.locator("summary").click();
|
|
check(
|
|
!(await advanced.evaluate((el) => el.open)),
|
|
"settings advanced controls collapse",
|
|
);
|
|
// Approved sample, downloaded separately through the CLI; do not modify it.
|
|
const sampleFile = path.resolve(
|
|
"..",
|
|
"attachments",
|
|
"夜片场-多主题交互样本.html",
|
|
);
|
|
const ref = await context.newPage();
|
|
await ref.goto(pathToFileURL(sampleFile).href, {
|
|
waitUntil: "domcontentloaded",
|
|
});
|
|
const measure = async (p, selectors) =>
|
|
p.evaluate(
|
|
(selectors) =>
|
|
Object.fromEntries(
|
|
Object.entries(selectors).map(([name, selector]) => {
|
|
const el = document.querySelector(selector);
|
|
if (!el) return [name, null];
|
|
const r = el.getBoundingClientRect(),
|
|
s = getComputedStyle(el);
|
|
return [
|
|
name,
|
|
{
|
|
x: r.x,
|
|
y: r.y,
|
|
width: r.width,
|
|
height: r.height,
|
|
fontSize: s.fontSize,
|
|
fontWeight: s.fontWeight,
|
|
letterSpacing: s.letterSpacing,
|
|
borderRadius: s.borderRadius,
|
|
color: s.color,
|
|
background: s.backgroundColor,
|
|
},
|
|
];
|
|
}),
|
|
),
|
|
selectors,
|
|
);
|
|
for (const [width, height] of process.env.HEL730_SKIP_VISUAL
|
|
? []
|
|
: [
|
|
[1440, 900],
|
|
[1366, 768],
|
|
[1280, 720],
|
|
]) {
|
|
await page.setViewportSize({ width, height });
|
|
await ref.setViewportSize({ width, height });
|
|
for (const theme of ["night", "day", "grade", "bluehour"]) {
|
|
for (const [route, sample] of [
|
|
["workflows", "workflows"],
|
|
["connections", "models"],
|
|
["tasks", "tasks"],
|
|
["library", "library"],
|
|
["settings", "settings"],
|
|
]) {
|
|
await page.goto(base + "/" + route, { waitUntil: "networkidle" });
|
|
await page.evaluate((theme) => {
|
|
localStorage.setItem("aigc-theme", theme);
|
|
window.dispatchEvent(
|
|
new StorageEvent("storage", { key: "aigc-theme", newValue: theme }),
|
|
);
|
|
}, theme);
|
|
await ref.evaluate(
|
|
({ sample, theme }) => {
|
|
go(sample);
|
|
setTheme(theme);
|
|
},
|
|
{ sample, theme },
|
|
);
|
|
await page.waitForTimeout(600);
|
|
await page.screenshot({
|
|
path: path.join(out, `${route}-${theme}-${width}-actual.png`),
|
|
});
|
|
await ref.screenshot({
|
|
path: path.join(out, `${route}-${theme}-${width}-sample.png`),
|
|
});
|
|
const actual = await measure(page, {
|
|
header: ".management-header",
|
|
title: ".management-header>b",
|
|
side: ".mg-side",
|
|
detail: ".mg-detail",
|
|
input: ".mg-search",
|
|
button: ".management-header .a-btn",
|
|
card: ".mg-card",
|
|
seg: ".management-header .mg-seg",
|
|
tag: ".management-page .mg-tag",
|
|
});
|
|
const reference = await measure(ref, {
|
|
header: `#p-${sample} .ph`,
|
|
title: `#p-${sample} .crumb b`,
|
|
side: `#p-${sample} .mg-side`,
|
|
detail: `#p-${sample} .mg-detail`,
|
|
input: `#p-${sample} .input`,
|
|
button: `#p-${sample} .ph .btn`,
|
|
card: `#p-${sample} .mcard`,
|
|
seg: `#p-${sample} .ph .seg`,
|
|
tag: `#p-${sample} .tag`,
|
|
});
|
|
evidence.measurements.push({
|
|
route,
|
|
theme,
|
|
width,
|
|
height,
|
|
actual,
|
|
sample: reference,
|
|
documentOverflow: await page.evaluate(
|
|
() => document.documentElement.scrollWidth > innerWidth,
|
|
),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
// Uploaded media is an explicitly named local fixture, added after empty-state visual captures.
|
|
const fixturePath = path.resolve(
|
|
"design/prototypes/reframe-20261014/assets/preview.webm",
|
|
);
|
|
const upload = await page.request.post(base + "/api/playground/uploads", {
|
|
multipart: {
|
|
file: {
|
|
name: "HEL730-playback-fixture.webm",
|
|
mimeType: "video/webm",
|
|
buffer: await fs.readFile(fixturePath),
|
|
},
|
|
},
|
|
});
|
|
check(upload.ok(), "isolated video fixture upload succeeds");
|
|
await page.goto(base + "/library", { waitUntil: "networkidle" });
|
|
const preview = page.getByRole("button", {
|
|
name: /预览 .*HEL730-playback-fixture/,
|
|
});
|
|
await preview.click();
|
|
const player = page.getByRole("dialog").locator("video");
|
|
await player.waitFor();
|
|
await player.evaluate(
|
|
(video) =>
|
|
new Promise((resolve) => {
|
|
if (video.readyState >= 1) resolve();
|
|
else video.addEventListener("loadedmetadata", resolve, { once: true });
|
|
}),
|
|
);
|
|
check(
|
|
await player.evaluate(
|
|
(video) => video.paused && video.controls && !video.autoplay,
|
|
),
|
|
"library video preview waits for manual play",
|
|
);
|
|
await player.evaluate((video) => video.play());
|
|
await page.waitForTimeout(300);
|
|
check(
|
|
await player.evaluate((video) => video.currentTime > 0 && !video.paused),
|
|
"library video plays on request",
|
|
);
|
|
await player.evaluate((video) => video.pause());
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-library-video-paused.png"),
|
|
});
|
|
await page.keyboard.press("Escape");
|
|
await page.getByRole("dialog").waitFor({ state: "hidden" });
|
|
await page.locator('.asset-meta input[type="checkbox"]').check();
|
|
await page.getByRole("button", { name: /删除已选/ }).click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.keyboard.press("Escape");
|
|
check(
|
|
await preview.isVisible(),
|
|
"library delete cancellation retains fixture",
|
|
);
|
|
await page.getByRole("button", { name: "存入项目", exact: true }).click();
|
|
await page.getByRole("dialog").waitFor();
|
|
await page.screenshot({
|
|
path: path.join(out, "interaction-library-attach-empty.png"),
|
|
});
|
|
await page.keyboard.press("Escape");
|
|
// Test-only fixture is added after all visual snapshots; it never represents an imported directory file.
|
|
const fixture = await page.request.post(base + "/api/workflows", {
|
|
data: {
|
|
name: "HEL730 待配置入口回归",
|
|
workflow_json: {
|
|
1: {
|
|
class_type: "PrimitiveStringMultiline",
|
|
inputs: { value: "fixture" },
|
|
},
|
|
7: {
|
|
class_type: "GlaxSamplerNode",
|
|
inputs: { prompt: ["1", 0], length: 121 },
|
|
},
|
|
15: { class_type: "QuarkMuffinDisplay", inputs: { payload: ["7", 0] } },
|
|
},
|
|
usage: "text2image",
|
|
usage_source: "user",
|
|
is_enabled: false,
|
|
},
|
|
});
|
|
check(fixture.ok(), "isolated pending fixture created");
|
|
const pending = await fixture.json();
|
|
check(
|
|
pending.needs_mapping && !pending.is_enabled,
|
|
"pending fixture cannot generate",
|
|
);
|
|
// B1 compatibility: readonly desk search, pending workflow deep link, no imaginary text-to-image input.
|
|
await page.goto(base + "/image", { waitUntil: "networkidle" });
|
|
await page.keyboard.press("/");
|
|
check(
|
|
await page.evaluate(() => document.activeElement?.tagName === "INPUT"),
|
|
"B1 / search remains available",
|
|
);
|
|
await page.keyboard.type("HEL730 keyboard");
|
|
await page.keyboard.press("Escape");
|
|
await page.screenshot({ path: path.join(out, "b1-keyboard-regression.png") });
|
|
await page
|
|
.getByRole("searchbox", { name: "搜索工作流", exact: true })
|
|
.fill("");
|
|
await page.getByRole("checkbox", { name: "仅可运行", exact: true }).uncheck();
|
|
await page
|
|
.locator('button.workflow-pick[title="HEL730 待配置入口回归"]')
|
|
.click();
|
|
await page.waitForURL("**/workflows?manage=1&wf=" + pending.id);
|
|
await page.locator(".wf-map-editor").waitFor();
|
|
check(
|
|
(await page.locator(".mg-detail h2").textContent()) ===
|
|
"HEL730 待配置入口回归",
|
|
"B1 pending link opens selected mapping row",
|
|
);
|
|
await page.screenshot({
|
|
path: path.join(out, "b1-pending-mapping-regression.png"),
|
|
});
|
|
const fallback = await context.newPage();
|
|
await fallback.addInitScript(() =>
|
|
Object.defineProperty(document, "startViewTransition", {
|
|
value: undefined,
|
|
configurable: true,
|
|
}),
|
|
);
|
|
await fallback.goto(base + "/settings", { waitUntil: "networkidle" });
|
|
const previous = await fallback.evaluate(
|
|
() => document.documentElement.dataset.theme,
|
|
);
|
|
await fallback
|
|
.getByRole("button", { name: previous === "day" ? /夜片场/ : /日光棚/ })
|
|
.click();
|
|
check(
|
|
await fallback.evaluate(() =>
|
|
document.documentElement.classList.contains("theme-anim"),
|
|
),
|
|
"unsupported View Transitions uses colour fallback",
|
|
);
|
|
await fallback.waitForTimeout(400);
|
|
check(
|
|
!(await fallback.evaluate(() =>
|
|
document.documentElement.classList.contains("theme-anim"),
|
|
)),
|
|
"fallback cleans up after 340ms",
|
|
);
|
|
await fallback.screenshot({
|
|
path: path.join(out, "interaction-theme-fallback.png"),
|
|
});
|
|
await context.close();
|
|
evidence.videos = {
|
|
actual: path.basename(await page.video().path()),
|
|
reference: path.basename(await ref.video().path()),
|
|
};
|
|
check(evidence.errors.length === 0, "no browser runtime errors");
|
|
} catch (error) {
|
|
await activePage?.screenshot({
|
|
path: path.join(out, "verification-failure.png"),
|
|
});
|
|
throw error;
|
|
} finally {
|
|
await fs.writeFile(
|
|
path.join(out, "browser-evidence.json"),
|
|
JSON.stringify(evidence, null, 2),
|
|
);
|
|
await browser.close();
|
|
}
|