116 lines
4.2 KiB
JavaScript
116 lines
4.2 KiB
JavaScript
// HEL-742 independent verification: pure text-to-image / text-to-video
|
|
// workflows expose no pad-slot UI at all (no 管理素材 entry, no .a-slot),
|
|
// no stale slot UI after mode/workflow switches; positive control on the
|
|
// mask workflow (2 slots). Run inside the isolated stack.
|
|
const { chromium } = require(
|
|
process.env.PLAYWRIGHT_MODULE_PATH || "playwright",
|
|
);
|
|
const fs = require("node:fs");
|
|
const out = "e2e/shots/hel742";
|
|
fs.mkdirSync(out, { recursive: true });
|
|
const checks = [];
|
|
const errors = [];
|
|
const ok = (name, value) => {
|
|
if (!value) throw new Error("FAIL " + name);
|
|
checks.push(name);
|
|
console.log("PASS", name);
|
|
};
|
|
const api = async (p, body) =>
|
|
body
|
|
? (
|
|
await fetch("http://127.0.0.1:8247" + p, {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify(body),
|
|
})
|
|
).json()
|
|
: (await fetch("http://127.0.0.1:8247" + p)).json();
|
|
const pause = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
|
(async () => {
|
|
const b = await chromium.launch({
|
|
executablePath: process.env.CHROMIUM_EXECUTABLE_PATH,
|
|
args: ["--no-sandbox", "--disable-dev-shm-usage"],
|
|
});
|
|
try {
|
|
const c = await b.newContext({ viewport: { width: 1440, height: 900 } });
|
|
const p = await c.newPage();
|
|
p.on("pageerror", (e) => errors.push(e.message));
|
|
p.setDefaultTimeout(15000);
|
|
const wfs = await api("/api/workflows");
|
|
const t2i = wfs.find((w) => w.name === "文生图·回归");
|
|
const t2v = wfs.find((w) => w.name === "文生视频·回归");
|
|
let mask = wfs.find((w) => w.name === "遮罩图生图测试");
|
|
ok("隔离夹具含文生图/文生视频工作流", t2i && t2v);
|
|
if (!mask) {
|
|
const base = await api("/api/workflows/" + t2i.id);
|
|
const maskBody = {
|
|
...base.workflow_json,
|
|
5: {
|
|
class_type: "LoadImage",
|
|
inputs: { image: "" },
|
|
_meta: { title: "(Input:image) 输入图" },
|
|
},
|
|
6: {
|
|
class_type: "LoadImageMask",
|
|
inputs: { image: "", channel: "red" },
|
|
_meta: { title: "(Input:mask) 遮罩" },
|
|
},
|
|
};
|
|
mask = await api("/api/workflows", {
|
|
name: "遮罩图生图测试",
|
|
kind: "image",
|
|
workflow_json: maskBody,
|
|
});
|
|
}
|
|
|
|
const noSlotUi = async () =>
|
|
(await p.locator(".a-slot").count()) === 0 &&
|
|
(await p
|
|
.getByRole("button", { name: "管理素材", exact: true })
|
|
.count()) === 0;
|
|
|
|
await p.goto("http://127.0.0.1:5173/create?wf=" + t2i.id);
|
|
await p.locator("#desk-prompt").waitFor();
|
|
await pause(400);
|
|
await p.screenshot({ path: out + "/t2i-no-slot.png" });
|
|
ok("文生图无图片输入:无垫图槽、无素材入口", await noSlotUi());
|
|
|
|
await p.getByRole("tab", { name: "视频", exact: true }).click();
|
|
await p.locator(".rail-tools input[type=search]").fill("文生视频");
|
|
await p.locator(".workflow-pick").first().click();
|
|
await pause(600);
|
|
await p.screenshot({ path: out + "/t2v-no-slot.png" });
|
|
ok("文生视频无图片输入:无首尾帧槽、无素材入口", await noSlotUi());
|
|
|
|
await p.getByRole("tab", { name: "图片", exact: true }).click();
|
|
await p.locator(".rail-tools input[type=search]").fill("文生图");
|
|
await p.locator(".workflow-pick").first().click();
|
|
await pause(600);
|
|
ok("切回图片后无残留垫图槽", await noSlotUi());
|
|
|
|
await p.locator(".rail-tools input[type=search]").fill("遮罩");
|
|
await p.locator(".workflow-pick").first().click();
|
|
await pause(600);
|
|
await p.getByRole("button", { name: "管理素材", exact: true }).click();
|
|
await pause(400);
|
|
ok(
|
|
"遮罩工作流仍有两个图片槽(对照)",
|
|
(await p.locator(".a-slot").count()) === 2,
|
|
);
|
|
await p.getByRole("button", { name: "完成", exact: true }).click();
|
|
|
|
await p.locator(".rail-tools input[type=search]").fill("文生图");
|
|
await p.locator(".workflow-pick").first().click();
|
|
await pause(600);
|
|
ok("从遮罩切回文生图后槽位入口消失", await noSlotUi());
|
|
ok("无浏览器异常", errors.length === 0);
|
|
fs.writeFileSync(
|
|
out + "/results.json",
|
|
JSON.stringify({ checks, errors }, null, 2),
|
|
);
|
|
} finally {
|
|
await b.close();
|
|
}
|
|
})();
|