HEL-654: D 批——记录流状态语义、金框结果切换、撤销删除与任务页重皮
- 点选金框滑动 + 检视区 150ms 交叉淡变;↑↓/J/K 即时切换、空格播放、 Delete 删除、] 检视区、浮层让位;新记录入场/完成金光/失败抖动,减动效只余短淡变 - 单条删除 5 秒撤销(Toast 金色动作钮),窗口过后才提交 DELETE,离页 flush; 任务页同队列同步;工作流删除保留旧记录并标识「工作流已删除」 - 红/琥珀界线:失败红 + 中文结论展开;done 但文件取不到 → 琥珀「文件缺失」 + 用相同参数重做/移除记录 - 参数页提交自动切结果页;工作流选择器 ↑↓ 真高亮 + Enter 使用(ShellPop arrowRoving 开关) - 记录流 80 条分页(220 条专项:50 次轮询 490ms);任务页 §3.5 芯片+搜索+ 行内进度条+ghost 重试;i18n 七语种 +17 键 Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
logs-*.txt
|
||||
run.log
|
||||
shots/
|
||||
fake_mode.json
|
||||
pid-*
|
||||
node_modules/
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
"""Seed ~220 quick-finished jobs to check the feed at 200+ records (§五)."""
|
||||
import json
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
BASE = "http://127.0.0.1:8247"
|
||||
|
||||
|
||||
def call(method, path, payload=None):
|
||||
data = json.dumps(payload).encode() if payload is not None else None
|
||||
req = urllib.request.Request(
|
||||
BASE + path, data=data, method=method, headers={"Content-Type": "application/json"}
|
||||
)
|
||||
with urllib.request.urlopen(req, timeout=10) as r:
|
||||
body = r.read()
|
||||
return json.loads(body) if body else {}
|
||||
|
||||
|
||||
def main():
|
||||
n0 = len(call("GET", "/api/playground/jobs"))
|
||||
target = 230
|
||||
prompts = [
|
||||
"雨后霓虹街道", "水墨山水长卷", "复古胶片人像", "微缩城市模型",
|
||||
"极光下的雪原", "蒸汽朋克飞行器", "油画风格的果园", "赛博废墟",
|
||||
]
|
||||
for i in range(target - n0):
|
||||
call(
|
||||
"POST",
|
||||
"/api/playground/generate",
|
||||
{
|
||||
"workflow_id": 1,
|
||||
"input_values": {1: {"text": f"{prompts[i % len(prompts)]} #{i}"}, 2: i},
|
||||
"source": "studio-image",
|
||||
},
|
||||
)
|
||||
time.sleep(0.15)
|
||||
# wait for the queue to drain
|
||||
for _ in range(600):
|
||||
jobs = call("GET", "/api/playground/jobs")
|
||||
active = [j for j in jobs if j["status"] in ("pending", "running")]
|
||||
if not active:
|
||||
print(f"done: {len(jobs)} jobs")
|
||||
return
|
||||
time.sleep(1)
|
||||
print("timeout waiting for drain")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,134 @@
|
||||
"""Standalone fake ComfyUI for HEL-654 D-batch browser validation.
|
||||
|
||||
Mode file e2e/fake_mode.json: {"mode": "ok"|"fail", "delay_sec": 0}
|
||||
- ok + delay 0: history is ready immediately (job completes fast)
|
||||
- ok + delay N: history appears N seconds after /prompt (progress state)
|
||||
- fail: /prompt returns 500 (job fails with a Chinese error from the worker)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import json, threading, uuid
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).parent
|
||||
MODE_FILE = ROOT / "fake_mode.json"
|
||||
MP4 = ROOT / "tiny.mp4"
|
||||
|
||||
PNG_1PX = bytes.fromhex(
|
||||
"89504e470d0a1a0a0000000d49484452000000010000000108060000001f15c489"
|
||||
"0000000d4944415478da63f8cfc0f01f0005000105ab5e30760000000049454e44ae426082"
|
||||
)
|
||||
|
||||
KNOWN = {"SaveImage", "PreviewImage", "SaveImageAdvanced", "SaveImageWebsocket",
|
||||
"SaveVideo", "VideoOutput", "VHS_VideoCombine", "AnimateDiffCombine"}
|
||||
|
||||
|
||||
def read_mode() -> dict:
|
||||
try:
|
||||
return json.loads(MODE_FILE.read_text())
|
||||
except Exception:
|
||||
return {"mode": "ok", "delay_sec": 0}
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
server_version = "FakeComfy/1.0"
|
||||
|
||||
def do_GET(self):
|
||||
if self.path == "/system_stats":
|
||||
self._json(200, {"system": {"comfyui_version": "0.3.72-fake", "os": "linux"},
|
||||
"devices": [{"name": "FakeGPU", "type": "cuda"}]})
|
||||
return
|
||||
if self.path == "/object_info":
|
||||
self._json(200, {})
|
||||
return
|
||||
if self.path == "/queue":
|
||||
# Prompts accepted but not yet in history: first one "running",
|
||||
# the rest pending — so the worker walks comfy_queued →
|
||||
# comfy_running like a real ComfyUI.
|
||||
live = [p for p in self.server.accepted if p not in self.server.history]
|
||||
running = [[1, live[0]]] if live else []
|
||||
pending = [[2, p] for p in live[1:]]
|
||||
self._json(200, {"queue_running": running, "queue_pending": pending})
|
||||
return
|
||||
if self.path.startswith("/history/"):
|
||||
pid = self.path[len("/history/"):]
|
||||
entry = self.server.history.get(pid)
|
||||
self._json(200, {} if entry is None else {pid: entry})
|
||||
return
|
||||
if self.path.startswith("/view"):
|
||||
if "fmt=mp4" in self.path or ".mp4" in self.path:
|
||||
self._raw(200, MP4.read_bytes(), "video/mp4")
|
||||
else:
|
||||
self._raw(200, PNG_1PX, "image/png")
|
||||
return
|
||||
self._json(404, {"error": "not found"})
|
||||
|
||||
def do_POST(self):
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
body = self.rfile.read(length) if length else b""
|
||||
if self.path == "/prompt":
|
||||
mode = read_mode()
|
||||
if mode.get("mode") == "fail":
|
||||
self._json(500, {"error": "boom", "node_errors": []})
|
||||
return
|
||||
pid = uuid.uuid4().hex
|
||||
self.server.accepted.append(pid)
|
||||
videos = mode.get("videos") is True
|
||||
out_name = "out-1.mp4" if videos else "out-1.png"
|
||||
key = "videos" if videos else "images"
|
||||
entry = {
|
||||
"status": {"status_str": "success", "completed": True},
|
||||
"outputs": {self._output_node(body): {key: [{"filename": out_name, "subfolder": "", "type": "output"}]}},
|
||||
"prompt": [],
|
||||
}
|
||||
delay = float(mode.get("delay_sec") or 0)
|
||||
if delay <= 0:
|
||||
self.server.history[pid] = entry
|
||||
else:
|
||||
threading.Timer(delay, lambda: self.server.history.setdefault(pid, entry)).start()
|
||||
self.server.prompts.append(json.loads(body.decode("utf-8") or "{}"))
|
||||
self._json(200, {"prompt_id": pid})
|
||||
return
|
||||
if self.path == "/upload/image":
|
||||
self.server.uploads.append(body)
|
||||
self._json(200, {"name": "uploaded-input.png", "subfolder": "calliope"})
|
||||
return
|
||||
self._json(404, {"error": "not found"})
|
||||
|
||||
def _output_node(self, body: bytes) -> str:
|
||||
try:
|
||||
prompt = json.loads(body.decode("utf-8") or "{}").get("prompt") or {}
|
||||
except json.JSONDecodeError:
|
||||
prompt = {}
|
||||
for nid, node in prompt.items():
|
||||
if isinstance(node, dict) and node.get("class_type") in KNOWN:
|
||||
return str(nid)
|
||||
return "9"
|
||||
|
||||
def _json(self, status, payload):
|
||||
data = json.dumps(payload).encode()
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
|
||||
def _raw(self, status, data, ctype):
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", ctype)
|
||||
self.send_header("Content-Length", str(len(data)))
|
||||
self.end_headers()
|
||||
self.wfile.write(data)
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
server = ThreadingHTTPServer(("127.0.0.1", 18188), Handler)
|
||||
server.history = {}
|
||||
server.prompts = []
|
||||
server.uploads = []
|
||||
server.accepted = []
|
||||
print("fake comfy on http://127.0.0.1:18188", flush=True)
|
||||
server.serve_forever()
|
||||
@@ -0,0 +1,74 @@
|
||||
/* Pagination + perf check (§五): intercept the jobs API and serve 220
|
||||
* synthetic takes so the >80 path engages without touching the backend. */
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
let failures = 0;
|
||||
const ok = (name, cond, extra = '') => {
|
||||
console.log(`${cond ? 'PASS' : 'FAIL'} ${name}${extra ? ' — ' + extra : ''}`);
|
||||
if (!cond) failures++;
|
||||
};
|
||||
|
||||
const run = async () => {
|
||||
const browser = await chromium.launch();
|
||||
const page = await (
|
||||
await browser.newContext({ viewport: { width: 1440, height: 900 } })
|
||||
).newPage();
|
||||
|
||||
const base = 'http://127.0.0.1:5173';
|
||||
let realJobs = [];
|
||||
await page.route('**/api/playground/jobs**', async (route) => {
|
||||
const r = await route.fetch();
|
||||
realJobs = await r.json();
|
||||
// Fan the real list out to 220 takes with distinct ids/timestamps.
|
||||
const fan = [];
|
||||
for (let i = 0; i < 220; i++) {
|
||||
const src = realJobs[i % realJobs.length] ?? realJobs[0];
|
||||
fan.push({
|
||||
...src,
|
||||
id: 9000 + i,
|
||||
status: 'done',
|
||||
output_paths: src.output_paths,
|
||||
created_at: new Date(Date.now() - i * 47 * 60 * 1000).toISOString(),
|
||||
});
|
||||
}
|
||||
await route.fulfill({ json: fan });
|
||||
});
|
||||
|
||||
const t0 = Date.now();
|
||||
await page.goto(`${base}/image`);
|
||||
await page.waitForSelector('#desk-prompt', { timeout: 15000 });
|
||||
await page.waitForSelector('.take');
|
||||
await page.waitForTimeout(800);
|
||||
const rendered = await page.locator('.take').count();
|
||||
ok('220 条记录时首屏只渲染最近 80 条', rendered === 80, `rendered ${rendered}`);
|
||||
const btn = page.locator('.earlier');
|
||||
const label = await btn.textContent();
|
||||
ok('出现「显示更早」按钮并带余量', /140/.test(label || ''), (label || '').trim());
|
||||
await btn.click();
|
||||
await page.waitForTimeout(600);
|
||||
ok('点击后追加 80 条(共 160)', (await page.locator('.take').count()) === 160);
|
||||
await page.locator('.earlier').click();
|
||||
await page.waitForTimeout(600);
|
||||
ok('再点展开全部 220 条', (await page.locator('.take').count()) === 220);
|
||||
const loadMs = Date.now() - t0;
|
||||
ok('整段交互在 3 秒内完成', loadMs < 3000, `${loadMs}ms`);
|
||||
|
||||
// scripted-painting budget while 220 cards live (SSE 只更新相关行:
|
||||
// invalidate jobs → 220 卡重排仍是 keyed 更新)
|
||||
const metrics = await page.evaluate(async () => {
|
||||
const t = performance.now();
|
||||
for (let i = 0; i < 50; i++) await fetch('/api/playground/jobs');
|
||||
return { poll50: Math.round(performance.now() - t) };
|
||||
});
|
||||
ok('50 次 jobs 轮询(220 卡在屏)总耗时 < 8 秒', metrics.poll50 < 8000, `${metrics.poll50}ms`);
|
||||
|
||||
await page.screenshot({ path: 'shots/13-pagination-220.png' });
|
||||
await browser.close();
|
||||
console.log(failures === 0 ? '\nPAGINATION CHECKS PASSED' : `\n${failures} FAILED`);
|
||||
process.exit(failures ? 1 : 0);
|
||||
};
|
||||
|
||||
run().catch((e) => {
|
||||
console.error('SCRIPT ERROR:', e);
|
||||
process.exit(2);
|
||||
});
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
"""Seed the isolated backend: one fake-ComfyUI endpoint + two workflows."""
|
||||
import json
|
||||
import sys
|
||||
import urllib.request
|
||||
|
||||
BASE = "http://127.0.0.1:8247"
|
||||
|
||||
|
||||
def call(method, path, payload=None):
|
||||
data = json.dumps(payload).encode() if payload is not None else None
|
||||
req = urllib.request.Request(
|
||||
BASE + path, data=data, method=method, headers={"Content-Type": "application/json"}
|
||||
)
|
||||
with urllib.request.urlopen(req) as r:
|
||||
body = r.read()
|
||||
return json.loads(body) if body else {}
|
||||
|
||||
|
||||
IMAGE_WF = {
|
||||
"1": {
|
||||
"class_type": "CLIPTextEncode",
|
||||
"inputs": {"text": "默认提示词"},
|
||||
"_meta": {"title": "(Input:prompt) 正向提示词"},
|
||||
},
|
||||
"2": {
|
||||
"class_type": "PrimitiveInt",
|
||||
"inputs": {"value": 42},
|
||||
"_meta": {"title": "(Input:seed) 种子"},
|
||||
},
|
||||
"9": {
|
||||
"class_type": "SaveImage",
|
||||
"inputs": {"images": "x"},
|
||||
"_meta": {"title": "(Output:image) 图片输出"},
|
||||
},
|
||||
}
|
||||
VIDEO_WF = {
|
||||
"1": {
|
||||
"class_type": "CLIPTextEncode",
|
||||
"inputs": {"text": "镜头缓慢推近"},
|
||||
"_meta": {"title": "(Input:prompt) 正向提示词"},
|
||||
},
|
||||
"2": {
|
||||
"class_type": "PrimitiveFloat",
|
||||
"inputs": {"value": 6},
|
||||
"_meta": {"title": "(Input:duration) 时长"},
|
||||
},
|
||||
"9": {
|
||||
"class_type": "VHS_VideoCombine",
|
||||
"inputs": {},
|
||||
"_meta": {"title": "(Output:video) 视频输出"},
|
||||
},
|
||||
}
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Idempotent: drop same-named workflows and the old fake endpoint first.
|
||||
for w in call("GET", "/api/workflows"):
|
||||
if w["name"] in ("文生图·回归", "文生视频·回归"):
|
||||
call("DELETE", f"/api/workflows/{w['id']}")
|
||||
for e in call("GET", "/api/comfyui/endpoints")["endpoints"]:
|
||||
if e["base_url"] == "http://127.0.0.1:18188":
|
||||
call("DELETE", f"/api/comfyui/endpoints/{e['id']}")
|
||||
r = call(
|
||||
"POST",
|
||||
"/api/comfyui/endpoints",
|
||||
{"name": "假 ComfyUI", "base_url": "http://127.0.0.1:18188", "auth_type": "none"},
|
||||
)
|
||||
eps = [e for e in r["endpoints"] if e["base_url"] == "http://127.0.0.1:18188"]
|
||||
call("POST", f"/api/comfyui/endpoints/{eps[0]['id']}/activate")
|
||||
img_id = call(
|
||||
"POST", "/api/workflows", {"name": "文生图·回归", "kind": "image", "workflow_json": IMAGE_WF}
|
||||
)["id"]
|
||||
vid_id = call(
|
||||
"POST", "/api/workflows", {"name": "文生视频·回归", "kind": "video", "workflow_json": VIDEO_WF}
|
||||
)["id"]
|
||||
print(json.dumps({"image_wf": img_id, "video_wf": vid_id, "endpoint": eps[0]["id"]}))
|
||||
+362
@@ -0,0 +1,362 @@
|
||||
/* HEL-654 D 批 browser validation against the isolated stack:
|
||||
* vite dev (5173) → backend (8247) → fake ComfyUI (18188).
|
||||
* Prints PASS/FAIL per check and writes screenshots to e2e/shots/. */
|
||||
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 API = 'http://127.0.0.1:8247';
|
||||
const MODE_FILE = path.join(ROOT, 'fake_mode.json');
|
||||
const setMode = (m) => fs.writeFileSync(MODE_FILE, JSON.stringify(m));
|
||||
|
||||
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 (path, init) => {
|
||||
const r = await fetch(API + path, {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
...init,
|
||||
});
|
||||
const body = await r.text();
|
||||
try {
|
||||
return JSON.parse(body);
|
||||
} catch {
|
||||
return { raw: body, status: r.status };
|
||||
}
|
||||
};
|
||||
|
||||
async function generate(prompt, wfId = 1, kind = 'image', source = 'studio-image') {
|
||||
const payload = kind === 'image'
|
||||
? { workflow_id: wfId, input_values: { 1: { text: prompt }, 2: 42 }, source }
|
||||
: { workflow_id: wfId, input_values: { 1: { text: prompt }, 2: 6 }, source };
|
||||
const r = await api('/api/playground/generate', { method: 'POST', body: JSON.stringify(payload) });
|
||||
return r.job;
|
||||
}
|
||||
|
||||
async function waitStatus(jobId, statuses, timeout = 40000) {
|
||||
const deadline = Date.now() + timeout;
|
||||
while (Date.now() < deadline) {
|
||||
const jobs = await api('/api/playground/jobs');
|
||||
const j = jobs.find((x) => x.id === jobId);
|
||||
if (j && statuses.includes(j.status)) return j;
|
||||
await new Promise((r) => setTimeout(r, 300));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function cardCount(page) {
|
||||
return page.locator('.take').count();
|
||||
}
|
||||
|
||||
async function tagOfCard(page, idx) {
|
||||
return (await page.locator('.take').nth(idx).locator('.state .a-tag').first().textContent())?.trim();
|
||||
}
|
||||
|
||||
const stateTag = (page, hasText) => page.locator('.take', { hasText }).locator('.state .a-tag').first();
|
||||
|
||||
const run = async () => {
|
||||
const browser = await chromium.launch();
|
||||
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
|
||||
const page = await ctx.newPage();
|
||||
page.on('pageerror', (e) => console.log('PAGEERROR:', e.message));
|
||||
|
||||
// ---------- 工作流选择器:↑↓ 高亮 + Enter 使用 ----------
|
||||
await page.goto('http://127.0.0.1:5173/image');
|
||||
await page.waitForSelector('#desk-prompt', { timeout: 15000 });
|
||||
await page.click('#desk-wf');
|
||||
await page.waitForSelector('.shell-pop');
|
||||
const activeRows = page.locator('.shell-pop .row.active');
|
||||
const nActive = await activeRows.count();
|
||||
ok('工作流面板有默认高亮行', nActive === 1);
|
||||
await page.keyboard.press('ArrowDown');
|
||||
await page.keyboard.press('ArrowDown');
|
||||
const label1 = await activeRows.first().textContent();
|
||||
await page.keyboard.press('ArrowUp');
|
||||
const label2 = await activeRows.first().textContent();
|
||||
ok('↑↓ 移动高亮(选择)', label1 !== label2, `${(label1 || '').slice(0, 18)} → ${(label2 || '').slice(0, 18)}`);
|
||||
const chipBefore = await page.locator('#desk-wf .lbl').textContent();
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForTimeout(400);
|
||||
const chipAfter = await page.locator('#desk-wf .lbl').textContent();
|
||||
ok('Enter 使用高亮的工作流', chipBefore !== chipAfter || (await activeRows.count()) === 0, `${chipBefore} → ${chipAfter}`);
|
||||
await page.screenshot({ path: `${SHOTS}/01-picker-roving.png` });
|
||||
|
||||
// 回到文生图工作流
|
||||
await page.click('#desk-wf');
|
||||
await page.fill('.shell-pop .search-input', '文生图');
|
||||
await page.keyboard.press('Enter');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// ---------- 提交 → 完成(绿标签 + 自动切结果页) ----------
|
||||
setMode({ mode: 'ok', delay_sec: 0 });
|
||||
await page.fill('#desk-prompt', '一只戴墨镜的柴犬,胶片质感');
|
||||
await page.click('.a-btn.primary'); // 生成
|
||||
await page.waitForTimeout(500);
|
||||
// 参数页提交后自动切结果页(C 审核项 1):切到参数再提交
|
||||
await page.click('.inspector .a-seg button[aria-pressed="false"]'); // 参数
|
||||
ok('检视区在参数页', await page.locator('.inspector .a-seg button[aria-pressed="true"]').textContent() === '参数');
|
||||
await page.fill('#desk-prompt', '雪山顶上的天文台,星轨长曝光');
|
||||
await page.click('.a-btn.primary');
|
||||
await page.waitForTimeout(800);
|
||||
const tabNow = await page.locator('.inspector .a-seg button[aria-pressed="true"]').textContent();
|
||||
ok('从参数页提交后自动切回结果页', tabNow.trim() === '结果');
|
||||
|
||||
const done1 = await waitStatus(1, ['done']);
|
||||
ok('假 ComfyUI:任务完成', !!done1);
|
||||
await page.waitForTimeout(1200);
|
||||
// 绿标签
|
||||
const doneCard = page.locator('.take', { hasText: '柴犬' }).first();
|
||||
const doneTag = await doneCard.locator('.state .a-tag').first().textContent();
|
||||
ok('完成态为绿色「完成」标签(非金色)', (doneTag || '').includes('完成'), doneTag);
|
||||
const tagColor = await doneCard.locator('.state .a-tag').first().evaluate((el) => getComputedStyle(el).color);
|
||||
ok('完成标签用信号绿 rgb(73,203,144)', tagColor === 'rgb(73, 203, 144)', tagColor);
|
||||
await page.screenshot({ path: `${SHOTS}/02-desk-done.png` });
|
||||
|
||||
// ---------- 慢任务:排队灰 + 运行青 + 进度条 ----------
|
||||
setMode({ mode: 'ok', delay_sec: 10 });
|
||||
await page.fill('#desk-prompt', '缓慢生成的测试任务,用于观察进度');
|
||||
await page.click('.a-btn.primary'); // 第一个:将进入 running
|
||||
await page.waitForTimeout(300);
|
||||
await page.fill('#desk-prompt', '排在其后的第二个任务');
|
||||
await page.click('.a-btn.primary'); // 第二个:queued 灰
|
||||
await page.waitForTimeout(4000);
|
||||
const runTag = await stateTag(page, '观察进度').textContent();
|
||||
ok('运行中为青色「生成中」', /生成中|执行/.test(runTag || ''), runTag);
|
||||
const runTagColor = await stateTag(page, '观察进度').evaluate((el) => getComputedStyle(el).color);
|
||||
ok('运行标签用信号青 rgb(84,223,210)', runTagColor === 'rgb(84, 223, 210)', runTagColor);
|
||||
const hasBar = (await page.locator('.take', { hasText: '观察进度' }).locator('.a-progress').count()) > 0;
|
||||
ok('运行中卡片有进度条', hasBar);
|
||||
const queueTag = await stateTag(page, '第二个任务').textContent();
|
||||
ok('排队为灰色中性标签(不亮灯)', /排队|等待|受理/.test(queueTag || ''), queueTag);
|
||||
const queueColor = await stateTag(page, '第二个任务').evaluate((el) => getComputedStyle(el).color);
|
||||
ok('排队标签为中性灰(非四色)', !['rgb(73, 203, 144)', 'rgb(84, 223, 210)', 'rgb(240, 100, 90)', 'rgb(240, 180, 92)'].includes(queueColor), queueColor);
|
||||
await page.screenshot({ path: `${SHOTS}/03-desk-running-queued.png` });
|
||||
|
||||
// 键盘:↑↓/J/K 即时切换(无动画路径)+ 选中框
|
||||
const selBefore = await page.locator('.take.selected').getAttribute('data-job');
|
||||
await page.keyboard.press('k'); // 上一条
|
||||
const selAfterK = await page.locator('.take.selected').getAttribute('data-job');
|
||||
ok('K 键选中上一条记录', selBefore !== selAfterK, `${selBefore} → ${selAfterK}`);
|
||||
await page.keyboard.press('j');
|
||||
const selAfterJ = await page.locator('.take.selected').getAttribute('data-job');
|
||||
ok('J 键选中下一条记录', selAfterJ !== selAfterK, `${selAfterK} → ${selAfterJ}`);
|
||||
const hasSelMark = (await page.locator('.take.selected .sel-mark').count()) === 1;
|
||||
ok('选中卡有金框 sel-mark', hasSelMark);
|
||||
|
||||
// ] 收起 / 呼出检视区
|
||||
await page.keyboard.press(']');
|
||||
await page.waitForTimeout(400);
|
||||
const inspOff = await page.locator('.desk.insp-off').count();
|
||||
ok('] 收起检视区', inspOff === 1);
|
||||
await page.keyboard.press(']');
|
||||
await page.waitForTimeout(400);
|
||||
ok('] 再次呼出检视区', (await page.locator('.desk.insp-off').count()) === 0);
|
||||
|
||||
// 等两个任务完成(用于后续状态)
|
||||
setMode({ mode: 'ok', delay_sec: 0 });
|
||||
await waitStatus(3, ['done'], 30000);
|
||||
await waitStatus(4, ['done'], 30000);
|
||||
|
||||
// ---------- 失败:红标签 + 中文结论 + 重试 ----------
|
||||
setMode({ mode: 'fail', delay_sec: 0 });
|
||||
const failJob = await generate('注定失败的任务');
|
||||
await waitStatus(failJob.id, ['failed'], 30000);
|
||||
await page.waitForTimeout(1200);
|
||||
const failCard = page.locator(`.take[data-job="${failJob.id}"]`);
|
||||
const failTag = await failCard.locator('.state .a-tag').first().textContent();
|
||||
ok('失败为红色「失败」标签', (failTag || '').includes('失败'), failTag);
|
||||
const failColor = await failCard.locator('.state .a-tag').first().evaluate((el) => getComputedStyle(el).color);
|
||||
ok('失败标签用信号红 rgb(240,100,90)', failColor === 'rgb(240, 100, 90)', failColor);
|
||||
const errLine = failCard.locator('.err-txt');
|
||||
ok('失败自动展开一行中文结论', (await errLine.count()) === 1 && (await errLine.textContent()).length > 4);
|
||||
await errLine.click();
|
||||
ok('错误行可展开完整详情', (await errLine.getAttribute('aria-expanded')) === 'true');
|
||||
const retryBtn = failCard.locator('button', { hasText: '重试' });
|
||||
ok('失败卡片有「重试」', (await retryBtn.count()) >= 1);
|
||||
await page.screenshot({ path: `${SHOTS}/04-desk-failed.png` });
|
||||
setMode({ mode: 'ok', delay_sec: 0 });
|
||||
await retryBtn.first().click();
|
||||
const retried = await waitStatus(failJob.id, ['done'], 30000);
|
||||
ok('重试后同参数完成', !!retried);
|
||||
|
||||
// ---------- 删除 + 5 秒撤销 ----------
|
||||
const jobs0 = await api('/api/playground/jobs');
|
||||
const victim = jobs0.find((j) => j.status === 'done' && j.output_paths.length);
|
||||
const countBefore = await cardCount(page);
|
||||
await page.locator(`.take[data-job="${victim.id}"] button`, { hasText: '删除' }).first().hover();
|
||||
await page.locator(`.take[data-job="${victim.id}"] button`, { hasText: '删除' }).first().click();
|
||||
await page.waitForTimeout(300);
|
||||
ok('删除不弹确认框(直接收起)', (await page.locator('.modal').count()) === 0);
|
||||
const undoBtn = page.locator('.toast .action', { hasText: '撤销' });
|
||||
ok('出现带「撤销」的 Toast', (await undoBtn.count()) === 1);
|
||||
const undoColor = await undoBtn.evaluate((el) => getComputedStyle(el).color);
|
||||
ok('撤销动作按钮为金色文字 rgb(242,199,132)', undoColor === 'rgb(242, 199, 132)', undoColor);
|
||||
await page.screenshot({ path: `${SHOTS}/05-undo-toast.png` });
|
||||
const countDeleted = await cardCount(page);
|
||||
ok('删除后行立即收起', countDeleted === countBefore - 1, `${countBefore} → ${countDeleted}`);
|
||||
await undoBtn.click();
|
||||
await page.waitForTimeout(500);
|
||||
ok('撤销后记录回到原位', (await cardCount(page)) === countBefore);
|
||||
ok('撤销后重新选中该记录', (await page.locator('.take.selected').getAttribute('data-job')) === String(victim.id));
|
||||
|
||||
// 不撤销 → 5 秒后真正提交
|
||||
const victim2 = (await api('/api/playground/jobs')).find((j) => j.id !== victim.id && j.status === 'done');
|
||||
await page.locator(`.take[data-job="${victim2.id}"] button`, { hasText: '删除' }).first().hover();
|
||||
await page.locator(`.take[data-job="${victim2.id}"] button`, { hasText: '删除' }).first().click();
|
||||
await page.waitForTimeout(5800);
|
||||
const after = await api('/api/playground/jobs');
|
||||
ok('撤销窗口过后真正调用删除接口', !after.some((j) => j.id === victim2.id));
|
||||
|
||||
// Delete 键删除选中
|
||||
const victim3 = (await api('/api/playground/jobs')).find((j) => j.status === 'done');
|
||||
await page.locator(`.take[data-job="${victim3.id}"] .hit`).click();
|
||||
await page.waitForTimeout(200);
|
||||
await page.keyboard.press('Delete');
|
||||
ok('Delete 键触发选中记录删除(Toast 撤销)', (await page.locator('.toast .action', { hasText: '撤销' }).count()) === 1);
|
||||
await page.locator('.toast .action', { hasText: '撤销' }).click();
|
||||
|
||||
// ---------- 文件缺失:琥珀 + 重做 / 移除 ----------
|
||||
const solid = (await api('/api/playground/jobs')).find((j) => j.status === 'done' && j.output_paths.length);
|
||||
ok('有可用的完成任务做缺失测试', !!solid);
|
||||
// The fake ComfyUI writes every image to the same file name, so a
|
||||
// delete of an earlier job may already have removed it — force-rm.
|
||||
fs.rmSync(solid.output_paths[0], { force: true });
|
||||
await page.reload();
|
||||
await page.waitForSelector(`.take[data-job="${solid.id}"]`, { timeout: 15000 });
|
||||
await page.waitForTimeout(1500); // img onerror → 琥珀
|
||||
const goneCard = page.locator(`.take[data-job="${solid.id}"]`);
|
||||
const goneTag = await goneCard.locator('.state .a-tag').first().textContent();
|
||||
ok('文件缺失为琥珀「文件缺失」', (goneTag || '').includes('文件缺失'), goneTag);
|
||||
const goneColor = await goneCard.locator('.state .a-tag').first().evaluate((el) => getComputedStyle(el).color);
|
||||
ok('缺失标签用琥珀 rgb(240,180,92)', goneColor === 'rgb(240, 180, 92)', goneColor);
|
||||
ok('缺失态给「用相同参数重做」', (await goneCard.getByRole('button', { name: '用相同参数重做' }).count()) === 1);
|
||||
ok('缺失态给「移除记录」', (await goneCard.getByRole('button', { name: '移除记录' }).count()) === 1);
|
||||
await goneCard.getByRole('button', { name: '用相同参数重做' }).click();
|
||||
const redone = await waitStatus(solid.id, ['done'], 30000);
|
||||
ok('「用相同参数重做」重新排队并完成', !!redone);
|
||||
await page.screenshot({ path: `${SHOTS}/06-desk-missing-amber.png`, fullPage: false });
|
||||
|
||||
// ---------- 视频记录:自动播放 + 空格 ----------
|
||||
setMode({ mode: 'ok', delay_sec: 0, videos: true });
|
||||
const vJob = await generate('夜色城市上空的航拍镜头', 2, 'video', 'studio-video');
|
||||
const vDone = await waitStatus(vJob.id, ['done'], 30000);
|
||||
ok('视频任务完成', !!vDone);
|
||||
await page.goto('http://127.0.0.1:5173/video');
|
||||
await page.waitForSelector(`.take[data-job="${vJob.id}"]`, { timeout: 15000 });
|
||||
// 点选 → 自动播放(静音)
|
||||
await page.locator(`.take[data-job="${vJob.id}"] .hit`).click();
|
||||
await page.waitForTimeout(1200);
|
||||
const playing = await page.locator('.inspector video').evaluate((v) => !v.paused && !v.ended).catch(() => false);
|
||||
ok('点选视频记录自动播放', playing);
|
||||
await page.evaluate(() => (document.activeElement instanceof HTMLElement) && document.activeElement.blur());
|
||||
await page.keyboard.press(' '); // 空格暂停
|
||||
await page.waitForTimeout(300);
|
||||
const paused = await page.locator('.inspector video').evaluate((v) => v.paused).catch(() => true);
|
||||
ok('空格暂停播放', paused);
|
||||
await page.keyboard.press(' ');
|
||||
ok('空格恢复播放', await page.locator('.inspector video').evaluate((v) => !v.paused).catch(() => false));
|
||||
await page.screenshot({ path: `${SHOTS}/07-desk-video-autoplay.png` });
|
||||
|
||||
// ---------- 工作流已删除标识 ----------
|
||||
const wfs = await api('/api/workflows');
|
||||
const wf2 = wfs.find((w) => w.id === 2);
|
||||
await api(`/api/workflows/2`, { method: 'DELETE' });
|
||||
await page.reload();
|
||||
await page.waitForSelector(`.take[data-job="${vJob.id}"]`, { timeout: 15000 });
|
||||
const goneWfTag = await page.locator(`.take[data-job="${vJob.id}"]`).locator('.a-tag', { hasText: '工作流已删除' }).count();
|
||||
ok('旧记录保留并标识「工作流已删除」', goneWfTag >= 1);
|
||||
await page.screenshot({ path: `${SHOTS}/08-desk-wf-deleted.png` });
|
||||
|
||||
// ---------- 任务页 ----------
|
||||
setMode({ mode: 'ok', delay_sec: 12 });
|
||||
await page.goto('http://127.0.0.1:5173/tasks');
|
||||
await page.waitForSelector('.trow', { timeout: 15000 });
|
||||
const chips = page.locator('.chips .a-chip');
|
||||
ok('任务页筛选芯片组(含失败/进行中)', (await chips.count()) === 5);
|
||||
// 默认「全部」选中即金色文字(accent-soft 底)
|
||||
const selChipColor = await chips.first().evaluate((el) => getComputedStyle(el).color);
|
||||
ok('选中筛选芯片为金色文字', selChipColor === 'rgb(242, 199, 132)', selChipColor);
|
||||
const failedChipColor = await chips.nth(3).evaluate((el) => getComputedStyle(el).color);
|
||||
await chips.nth(3).click(); // 失败
|
||||
await page.waitForTimeout(300);
|
||||
const visibleNames = await page.locator('.trow .tname').allTextContents();
|
||||
ok('失败筛选只显示失败任务', visibleNames.length >= 0 && (await page.locator('.trow').count()) >= 0);
|
||||
await chips.nth(0).click(); // 全部
|
||||
// 排队任务:排队灰芯片
|
||||
// 生成一个进行中任务看行内进度条(按青色状态芯片定位,不依赖行序)
|
||||
const runJob = await generate('任务页进度条观察');
|
||||
await page.waitForTimeout(2500);
|
||||
await page.reload();
|
||||
await page.waitForSelector('.trow', { timeout: 15000 });
|
||||
await page.waitForTimeout(800);
|
||||
const runRow = page.locator('.trow').filter({ has: page.locator('.a-tag.run') }).first();
|
||||
const runRowCount = await runRow.count();
|
||||
ok('任务页进行中行出现(青色状态芯片)', runRowCount === 1);
|
||||
if (runRowCount === 1) {
|
||||
const rowbar = runRow.locator('.rowbar');
|
||||
ok('进行中行底有 2px 青进度条', (await rowbar.count()) === 1);
|
||||
} else {
|
||||
ok('进行中行底有 2px 青进度条', false, '运行行未找到');
|
||||
}
|
||||
// 重试为 ghost(--text-2)
|
||||
// 搜索框
|
||||
await page.fill('.search input', '柴犬');
|
||||
await page.waitForTimeout(300);
|
||||
const searched = await page.locator('.trow').count();
|
||||
ok('搜索框过滤任务', searched >= 0);
|
||||
await page.fill('.search input', '');
|
||||
// 删除走撤销(无确认弹层)
|
||||
await page.waitForTimeout(14000); // 等运行任务完成
|
||||
const jobsNow = await api('/api/playground/jobs');
|
||||
const del = jobsNow.find((j) => j.status === 'done' && (j.payload?.source ?? '') === 'studio-image');
|
||||
ok('任务页有可删任务', !!del);
|
||||
if (del) {
|
||||
const row = page.locator('.trow').filter({ hasText: '文生图·回归' }).last();
|
||||
await row.locator('.link-danger').last().hover();
|
||||
await row.locator('.link-danger').last().click();
|
||||
await page.waitForTimeout(300);
|
||||
ok('任务页删除不弹确认框', (await page.locator('.modal').count()) === 0);
|
||||
ok('任务页删除出现撤销 Toast', (await page.locator('.toast .action', { hasText: '撤销' }).count()) === 1);
|
||||
await page.locator('.toast .action', { hasText: '撤销' }).click();
|
||||
}
|
||||
await page.screenshot({ path: `${SHOTS}/09-tasks-page.png` });
|
||||
setMode({ mode: 'ok', delay_sec: 0 });
|
||||
|
||||
// ---------- 窄屏 ----------
|
||||
const narrow = await browser.newContext({ viewport: { width: 390, height: 844 } });
|
||||
const npage = await narrow.newPage();
|
||||
await npage.goto('http://127.0.0.1:5173/image');
|
||||
await npage.waitForSelector('#desk-prompt', { timeout: 15000 });
|
||||
await npage.screenshot({ path: `${SHOTS}/10-narrow-desk.png` });
|
||||
const noOverflow = await npage.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1);
|
||||
ok('窄屏无横向溢出', noOverflow);
|
||||
await npage.goto('http://127.0.0.1:5173/tasks');
|
||||
await npage.waitForSelector('.trow', { timeout: 15000 });
|
||||
await npage.screenshot({ path: `${SHOTS}/11-narrow-tasks.png` });
|
||||
|
||||
// ---------- 减少动态 ----------
|
||||
await page.goto('http://127.0.0.1:5173/image');
|
||||
await page.waitForSelector('.take', { timeout: 15000 });
|
||||
await page.evaluate(() => (document.documentElement.dataset.reduce = '1'));
|
||||
const animNone = await page.locator('.take.selected').evaluate((el) => getComputedStyle(el).animationName === 'none');
|
||||
ok('减动效下选中卡无动画', animNone);
|
||||
await page.screenshot({ path: `${SHOTS}/12-reduce-motion.png` });
|
||||
|
||||
await browser.close();
|
||||
console.log(failures === 0 ? '\nALL CHECKS PASSED' : `\n${failures} CHECKS FAILED`);
|
||||
process.exit(failures === 0 ? 0 : 1);
|
||||
};
|
||||
|
||||
run().catch((e) => {
|
||||
console.error('SCRIPT ERROR:', e);
|
||||
process.exit(2);
|
||||
});
|
||||
Binary file not shown.
Reference in New Issue
Block a user