HEL-665: rebuild ComfyUI creative journey with visible controls and isolated drafts

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-14 00:04:19 +08:00
co-authored by multica-agent
parent ac1c0f98a6
commit 07f6475b1a
11 changed files with 1195 additions and 826 deletions
+152 -33
View File
@@ -58,6 +58,18 @@ const mode = (videos = false, photo = 'coast') =>
);
try {
mode();
// Remove only this script's marked local fixtures after an interrupted previous run.
const staleProjects = (await api('/api/projects')).filter(
(p) => p.title === '折光·可删除测试项目',
);
const staleProjectIds = new Set(staleProjects.map((p) => p.id));
for (const j of await api('/api/playground/jobs'))
if (staleProjectIds.has(j.payload?.workbench?.project_id))
await api('/api/playground/jobs/' + j.id, null, 'DELETE');
for (const p of staleProjects) await api('/api/projects/' + p.id, null, 'DELETE');
for (const w of await api('/api/workflows?view=meta'))
if (['H3 首尾帧·折光回归', 'H3 首尾帧·首次加载回归'].includes(w.name))
await api('/api/workflows/' + w.id, null, 'DELETE');
const rows = await api('/api/workflows?view=meta');
ok('more than 100 imported catalogue entries', rows.length > 100);
const image = rows.find((w) => w.name === '文生图·回归');
@@ -170,37 +182,53 @@ try {
(await page.inputValue('#desk-prompt')) === 'traveler on coast' &&
(await page.locator('.context-bar a.back').count()) === 1,
);
await page.fill('#desk-prompt', '项目草稿·旅人');
await page.locator('.sidebar .nav-item[href="/image"]').click();
await page.waitForURL(WEB + '/image');
await page.locator('.context-bar').waitFor({ state: 'detached' });
await page.locator('#desk-prompt').waitFor();
await page.fill('#desk-prompt', '独立创作草稿');
await page.goto(desk);
await page.locator('#desk-prompt').waitFor();
ok(
'project and standalone drafts stay separate across navigation',
(await page.inputValue('#desk-prompt')) === '项目草稿·旅人',
);
await page.fill('#desk-prompt', 'traveler on coast');
const preview = await page.locator('.inspector.main .stage').boundingBox(),
form = await page.locator('.studio-form').boundingBox();
ok(
'large preview and compact input panel',
preview.width > 600 && preview.x < form.x && form.width < 330,
'input and results are adjacent workspace regions',
preview.x > form.x && form.width >= 290 && form.width <= 370,
);
await page.locator('.model-selector').click();
await page.locator('[role="dialog"] .catalogue').waitFor();
await page.locator('[aria-label="搜索工作流"]').fill('文生图·回归');
await until(async () => (await page.locator('[role="dialog"] .workflow-card').count()) === 1);
ok('workflow search in modal', true);
await page.getByRole('button', { name: '云端与智能体', exact: true }).click();
await page.locator('[aria-label="搜索工作流"]').focus();
await page.keyboard.press('Enter');
await page.locator('.tool-picker .catalogue').waitFor();
await page.fill('[aria-label="搜索工作流"]', '文生图·回归');
await until(async () => (await page.locator('.tool-picker .workflow-card').count()) === 1);
ok('tool search stays in workspace', (await page.locator('[role="dialog"]').count()) === 0);
await page.getByRole('button', { name: '查看 文生图·回归', exact: true }).click();
await page.locator('.tool-detail h3').waitFor();
ok(
'cloud search Enter does not choose a hidden local workflow',
(await page.locator('[role="dialog"]').count()) === 1,
'tool requirements before confirmation',
await page
.locator('.tool-detail')
.innerText()
.then((s) => s.includes('画面描述')),
);
await page.keyboard.press('Escape');
ok(
'Escape restores selector focus',
(await page.locator('[role="dialog"]').count()) === 0 &&
'Escape preserves input and restores tool button',
(await page.inputValue('#desk-prompt')) === 'traveler on coast' &&
(await page.locator('.model-selector').evaluate((e) => e === document.activeElement)),
);
await page.getByRole('button', { name: '全部参数' }).click();
await page.getByRole('dialog').waitFor();
ok(
'parameters do not replace the artboard',
await page.locator('.inspector.main .stage').isVisible(),
'common parameters visible inline',
await page
.locator('.composer-scroll .input-section')
.last()
.innerText()
.then((s) => s.includes('生成设置')),
);
await page.keyboard.press('Escape');
let submitted = page.waitForRequest(
(r) => r.url().endsWith('/api/playground/generate') && r.method() === 'POST',
);
@@ -225,12 +253,13 @@ try {
);
ok('output flows to source project asset', true);
await page.reload();
await page
.locator(`.take[data-job="${job.id}"] .actions .a-tag`, {
hasText: '已回流',
})
.waitFor();
ok('attachment survives reload', true);
await page.locator('.save-project').waitFor();
ok(
'attachment survives reload',
!!(await api(`/api/workbench/projects/${project.id}`)).stages.find(
(s) => s.stage_key === 'assets',
).content.assets[0].job,
);
mode(false, 'arch');
await page.fill('#desk-prompt', 'second variation');
await page.locator('.studio-form .gen').click();
@@ -243,7 +272,7 @@ try {
),
);
jobs.push(second.id);
await page.locator(`.take[data-job="${second.id}"] button.hit`).click();
await page.locator(`.result-item[aria-label^="查看第 ${second.id} 次"]`).click();
await page.getByRole('button', { name: '对比画面 ◫' }).click();
await page.getByRole('slider', { name: '拖动对比画面' }).fill('70');
@@ -277,7 +306,8 @@ try {
.evaluateAll((els) => els.map((e) => e.getAttribute('src')));
await page.locator('.model-selector').click();
await page.fill('[aria-label="搜索工作流"]', h3Copy.name);
await page.getByRole('button', { name: '使用 ' + h3Copy.name, exact: true }).click();
await page.getByRole('button', { name: '查看 ' + h3Copy.name, exact: true }).click();
await page.getByRole('button', { name: '使用这个工具 →', exact: true }).click();
await page.locator('#desk-prompt').waitFor();
ok(
'first uncached workflow keeps prompt',
@@ -291,9 +321,34 @@ try {
.evaluateAll((els) => els.map((e) => e.getAttribute('src'))),
) === JSON.stringify(inputSources),
);
await page.route(/\/api\/workflows\?view=meta$/, async (route) => {
const response = await route.fetch();
await new Promise((r) => setTimeout(r, 1000));
await route.fulfill({ response });
});
const delayedMeta = page.waitForResponse(/\/api\/workflows\?view=meta$/);
await page.reload();
await delayedMeta;
await page.locator('#desk-prompt').waitFor();
await page.waitForTimeout(150);
await page.unrouteAll({ behavior: 'wait' });
ok(
'reload restores the chosen workflow and prompt',
(await page.inputValue('#desk-prompt')) === '切换后保留提示词与首尾帧' &&
(await page.locator('.model-selector').innerText()).includes(h3Copy.name),
);
ok(
'reload restores first and last frame inputs',
JSON.stringify(
await page
.locator('.studio-form img')
.evaluateAll((els) => els.map((e) => e.getAttribute('src'))),
) === JSON.stringify(inputSources),
);
await page.locator('.model-selector').click();
await page.fill('[aria-label="搜索工作流"]', h3.name);
await page.getByRole('button', { name: '使用 ' + h3.name, exact: true }).click();
await page.getByRole('button', { name: '查看 ' + h3.name, exact: true }).click();
await page.getByRole('button', { name: '使用这个工具 →', exact: true }).click();
await page.locator('#desk-prompt').waitFor();
submitted = page.waitForRequest(
(r) => r.url().endsWith('/api/playground/generate') && r.method() === 'POST',
@@ -354,13 +409,77 @@ try {
await page.locator('.svelte-flow').waitFor();
ok('canvas opens actual persisted graph', new URL(page.url()).pathname.startsWith('/canvas/'));
await page.screenshot({ path: SHOTS + '/canvas.png' });
for (const width of [1280, 1440, 1920]) {
await page.setViewportSize({ width, height: 960 });
await page.goto(WEB + '/image?wf=' + image.id);
await page.locator('.studio-form').waitFor();
const b = await page.locator('.studio-form').boundingBox();
ok(`desktop ${width}px no horizontal input overflow`, b.x + b.width <= width + 1);
await page.goto(WEB + `/video?wf=${h3.id}`);
await page.locator('.inspector.main video').waitFor();
await page.waitForTimeout(300);
ok(
'entering page does not autoplay',
await page.locator('.inspector.main video').evaluate((v) => v.paused),
);
await page.getByRole('button', { name: '播放视频', exact: true }).click();
await page.getByRole('button', { name: '暂停视频', exact: true }).waitFor();
ok(
'explicit playback changes state',
await page.locator('.inspector.main video').evaluate((v) => !v.paused),
);
await page.getByRole('button', { name: '暂停视频', exact: true }).click();
await page.evaluate(() => document.activeElement?.blur());
await page.keyboard.press('Space');
ok(
'space outside player does not change playback',
await page.locator('.inspector.main video').evaluate((v) => v.paused),
);
for (const [width, height] of [
[1366, 768],
[1280, 720],
[1100, 600],
[960, 540],
[1920, 1080],
]) {
await page.setViewportSize({ width, height });
await page.goto(WEB + `/video?wf=${h3.id}`);
await page.locator('.inspector.main video').waitFor();
const visible = await page.evaluate(() => {
const v = document.querySelector('.inspector.main video').getBoundingClientRect(),
stage = document.querySelector('.inspector.main .stage').getBoundingClientRect(),
gen = document.querySelector('.studio-form .gen').getBoundingClientRect(),
play = document.querySelector('.playback-bar').getBoundingClientRect();
return (
v.bottom <= stage.bottom + 1 &&
v.right <= stage.right + 1 &&
gen.bottom <= innerHeight &&
gen.top >= 0 &&
play.bottom <= innerHeight &&
document.documentElement.scrollWidth <= innerWidth
);
});
ok(`entire video, playback and generate visible at ${width}x${height}`, visible);
await page.screenshot({ path: SHOTS + `/workspace-${width}x${height}.png` });
await page.locator('.model-selector').click();
await page.locator('.tool-picker').waitFor();
const confirm = await page
.getByRole('button', { name: '使用这个工具 →', exact: true })
.boundingBox();
ok(`tool confirmation visible at ${width}x${height}`, confirm.y + confirm.height <= height);
await page.keyboard.press('Escape');
}
const zoomContext = await browser.newContext({
viewport: { width: 960, height: 540 },
deviceScaleFactor: 1.5,
});
const zoomPage = await zoomContext.newPage();
await zoomPage.goto(WEB + `/video?wf=${h3.id}`);
await zoomPage.locator('.inspector.main video').waitFor();
ok(
'150 percent equivalent desktop viewport keeps primary controls visible',
await zoomPage.evaluate(() => {
const gen = document.querySelector('.studio-form .gen').getBoundingClientRect(),
play = document.querySelector('.playback-bar').getBoundingClientRect();
return devicePixelRatio === 1.5 && gen.bottom <= innerHeight && play.bottom <= innerHeight;
}),
);
await zoomPage.screenshot({ path: SHOTS + '/zoom-equivalent-150.png' });
await zoomContext.close();
await page.emulateMedia({ reducedMotion: 'reduce' });
ok(
'reduced motion disables transitions',