feat(HEL-730): reshape management pages and preserve workflow tools
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,487 @@
|
||||
/** 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("");
|
||||
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",
|
||||
);
|
||||
// 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();
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
"""Reproduce HEL-730 on an isolated database and HTTP fake, never on a user server.
|
||||
Run from repo root: PYTHONPATH=calliope-backend/src:calliope-backend python3 scripts/verify-hel730.py
|
||||
Optional: PLAYWRIGHT_MODULE=/absolute/path/to/playwright/index.mjs.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import socket
|
||||
import subprocess
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import httpx
|
||||
import uvicorn
|
||||
from PIL import Image
|
||||
|
||||
from calliope.config import settings
|
||||
import calliope.config as config_module
|
||||
from calliope.db import migrate_db
|
||||
from calliope.main import create_app
|
||||
from tests.test_studio_generation import fake_comfy, PNG_1PX
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT.parent / 'hel730-evidence'
|
||||
OUT.mkdir(exist_ok=True)
|
||||
DATA = OUT / ('isolated-data-'+uuid.uuid4().hex[:8])
|
||||
DATA.mkdir(exist_ok=True)
|
||||
settings.data_dir = DATA
|
||||
settings.assets_dir = DATA / 'assets'
|
||||
settings.dry_run = False
|
||||
settings.queue_poll_interval_sec = .5
|
||||
settings.queue_poll_timeout_sec = 10
|
||||
settings.llm_profiles = []
|
||||
settings.llm_active_id = None
|
||||
settings.comfyui_endpoints = []
|
||||
settings.comfyui_active_id = None
|
||||
config_module.CONFIG_FILE = DATA / 'isolated-config.json'
|
||||
# Configuration and queue data are local to this evidence run.
|
||||
asyncio.run(migrate_db(settings.db_path))
|
||||
fake_generator = fake_comfy.__wrapped__()
|
||||
fake = next(fake_generator)
|
||||
sock = socket.socket()
|
||||
sock.bind(('127.0.0.1', 0))
|
||||
port = sock.getsockname()[1]
|
||||
server = uvicorn.Server(uvicorn.Config(create_app(ROOT/'calliope-web'/'build'), log_level='warning'))
|
||||
thread = threading.Thread(target=lambda: server.run(sockets=[sock]), daemon=True)
|
||||
thread.start()
|
||||
try:
|
||||
with httpx.Client(base_url=f'http://127.0.0.1:{port}', timeout=30) as client:
|
||||
for _ in range(200):
|
||||
if server.started: break
|
||||
time.sleep(.05)
|
||||
assert server.started
|
||||
def request(method, url, **kwargs):
|
||||
r = client.request(method, url, **kwargs)
|
||||
assert r.is_success, (url, r.status_code, r.text)
|
||||
return r.json()
|
||||
endpoint = request('POST','/api/comfyui/endpoints',json={'name':'HEL-730 本机隔离假服务','base_url':f'http://127.0.0.1:{fake.server_address[1]}','auth_type':'none'})['endpoints'][0]
|
||||
scan = request('POST','/api/workflows/import-scan',json={'root':str(ROOT/'example_ComfyUI_workflows'),'dry_run':True})
|
||||
(OUT/'scan.json').write_text(json.dumps(scan,ensure_ascii=False,indent=2))
|
||||
assert request('GET','/api/workflows?view=meta') == []
|
||||
candidates = [f for f in scan['files'] if f.get('importable') and f.get('suggested',{}).get('usage') == 'text2image' and 'image' in f.get('suggested',{}).get('media_out',[])]
|
||||
assert candidates, 'No convertible UI-format workflow in the real directory'
|
||||
# Prefer text-only inputs so the fake run does not need synthetic user reference media.
|
||||
candidates.sort(key=lambda f: (bool(f.get('suggested',{}).get('media_in')),f.get('source_path','')))
|
||||
chosen = candidates[0]
|
||||
path = ROOT/'example_ComfyUI_workflows'/chosen['source_path']
|
||||
graph = json.loads(path.read_text())
|
||||
convert = request('POST','/api/workflows/convert',json={'files':[{'source_path':chosen['source_path'],'workflow_json':graph}],'include_workflows':True})
|
||||
(OUT/'convert.json').write_text(json.dumps(convert,ensure_ascii=False,indent=2))
|
||||
imported = request('POST','/api/workflows/import-batch',json={'files':[{'source_path':chosen['source_path'],'workflow_json':graph}]})
|
||||
(OUT/'import.json').write_text(json.dumps(imported,ensure_ascii=False,indent=2))
|
||||
rows = request('GET','/api/workflows')
|
||||
assert len(rows) == 1
|
||||
wf = rows[0]
|
||||
wid = wf['id']
|
||||
outputs = wf.get('output_map') or [{'nodeId':o['nodeId'],'kind':o.get('kind') or 'image'} for o in wf['output_schema'] if o.get('kind') in ('image','video')]
|
||||
assert outputs, wf
|
||||
wf = request('PATCH',f'/api/workflows/{wid}',json={'usage':wf.get('usage') or 'text2image','usage_source':'user','output_map':outputs,'output_map_source':'user','endpoint_id':endpoint['id'],'is_enabled':True})
|
||||
fake.forced_output_node = outputs[0]['nodeId']
|
||||
fake.outputs_key = 'videos' if outputs[0]['kind']=='video' else 'images'
|
||||
fake.out_name = 'hel730-isolated.png'
|
||||
fake.object_info = {n['class_type']:{'input':{'required':{},'optional':{}},'output':[]} for n in wf['workflow_json'].values() if isinstance(n,dict) and n.get('class_type')}
|
||||
check = request('POST',f'/api/workflows/{wid}/check',json={'endpoint_id':endpoint['id'],'refresh':True})
|
||||
values = {i['nodeId']:i.get('defaultValue','HEL-730 fake-service verification') for i in wf['input_schema'] if i['kind'] in ('text','textarea','number','select')}
|
||||
result = request('POST',f'/api/workflows/{wid}/test',json={'input_values':values})
|
||||
jobid = result['job']['id']
|
||||
deadline = time.monotonic()+30
|
||||
while True:
|
||||
job = request('GET',f'/api/jobs/{jobid}')
|
||||
if job['status'] not in ('pending','running'): break
|
||||
assert time.monotonic()<deadline, job
|
||||
time.sleep(.1)
|
||||
assert job['status']=='done', job
|
||||
assert job['origin']=='workflow_test'
|
||||
assert job['output_paths']
|
||||
output = Path(job['output_paths'][0])
|
||||
assert output.read_bytes()==PNG_1PX
|
||||
assert '_workflow_test' in str(output)
|
||||
history = request('GET','/api/playground/jobs')
|
||||
assert all(j['id']!=jobid for j in history)
|
||||
meta = request('GET','/api/workflows?view=meta')
|
||||
assert meta[0]['is_enabled'] and meta[0]['usage'] and not meta[0]['needs_mapping']
|
||||
summary = {'source_path':chosen['source_path'],'source_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),'ui_format_files':scan['total'],'directory_json_files':len(list((ROOT/'example_ComfyUI_workflows').rglob('*.json'))),'imported':len(meta),'workflow_id':wid,'mapping':outputs,'check':check,'test_job_id':jobid,'test_status':job['status'],'output_sha256':hashlib.sha256(output.read_bytes()).hexdigest(),'output_isolated':True,'excluded_from_creation_history':True,'fake_prompt_requests':len(fake.prompts),'service_url':f'http://127.0.0.1:{port}'}
|
||||
(OUT/'closed-loop.json').write_text(json.dumps(summary,ensure_ascii=False,indent=2))
|
||||
# This server only offers a fake 1px response. The UI screenshot must not pretend it is artwork.
|
||||
env = {**os.environ,'HEL730_URL':f'http://127.0.0.1:{port}','HEL730_OUT':str(OUT),'HEL730_WORKFLOW':str(wid)}
|
||||
subprocess.run(['node',str(ROOT/'scripts'/'verify-hel730.mjs')],env=env,check=True)
|
||||
print(json.dumps(summary,ensure_ascii=False,indent=2))
|
||||
finally:
|
||||
server.should_exit = True
|
||||
thread.join(timeout=10)
|
||||
sock.close()
|
||||
fake_generator.close()
|
||||
Reference in New Issue
Block a user