Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 128 additions & 2 deletions browser_tests/tests/queue/queueOverlay.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { expect, mergeTests } from '@playwright/test'
import type { ListAssetsResponse } from '@comfyorg/ingest-types'

import { comfyPageFixture } from '@e2e/fixtures/ComfyPage'
import { ExecutionHelper } from '@e2e/fixtures/helpers/ExecutionHelper'
import {
createRouteMockJob,
jobsRouteFixture
} from '@e2e/fixtures/jobsRouteFixture'
import { TestIds } from '@e2e/fixtures/selectors'
import { webSocketFixture } from '@e2e/fixtures/ws'
import type { RawJobListItem } from '@/platform/remote/comfyui/jobs/jobTypes'

const test = mergeTests(comfyPageFixture, jobsRouteFixture)
const test = mergeTests(comfyPageFixture, jobsRouteFixture, webSocketFixture)
const mockJobTimestamp = Date.UTC(2026, 0, 1, 12)
const targetJobId = '00000000-0000-4000-8000-000000000002'

const MOCK_JOBS: RawJobListItem[] = [
createRouteMockJob({
Expand All @@ -21,11 +25,18 @@ const MOCK_JOBS: RawJobListItem[] = [
outputs_count: 2
}),
createRouteMockJob({
id: 'job-completed-2',
id: targetJobId,
status: 'completed',
create_time: mockJobTimestamp - 120_000,
execution_start_time: mockJobTimestamp - 120_000,
execution_end_time: mockJobTimestamp - 115_000,
preview_output: {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRIVIAL — adding preview_output to this shared fixture changes the rendered row for the six pre-existing tests in this file: the job now renders a preview tile (fetching /api/view?filename=workflow-output.png, which 404s in the test backend) instead of a state icon, and becomes double-click/View-able. Nothing currently asserts on that, so it is safe today, but it makes MOCK_JOBS carry state that only one nested describe needs. Consider a local fixture for the new test instead of mutating the shared array.

filename: 'workflow-output.png',
subfolder: '',
type: 'output',
nodeId: '1',
mediaType: 'images'
},
outputs_count: 1
}),
createRouteMockJob({
Expand All @@ -49,6 +60,25 @@ const MOCK_JOBS: RawJobListItem[] = [
test.describe('Queue overlay', () => {
test.beforeEach(async ({ comfyPage, jobsRoutes }) => {
await jobsRoutes.mockJobsScenario({ history: MOCK_JOBS, queue: [] })
await comfyPage.page.route(/\/api\/assets(?:\?.*)?$/, async (route) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — this /api/assets mock is never exercised by this spec, and its data contradicts the assertion it appears to support.

The Generated tab renders from useAssetsApi('output') -> assetsStore.historyAssets, which is filled by api.getHistory() (the jobs routes you already mock) and mapped through mapTaskOutputToAssetItem, where id: taskItem.jobId. Nothing in this journey calls /assets: fetchInputFilesFromAPI uses /internal/files/input on non-cloud, and useFlatOutputAssets (the only asset-API-backed output list) is not what AssetsSidebarTab uses.

So the mocked asset id 10000000-...-0002 is not the id the grid renders — the card's data-asset-id is the job id, which is exactly what line 230 asserts. If the sidebar ever did read this route, this mock would make the test fail. As written it encodes a false model (asset id != job id) directly next to an assertion that asset id == job id.

It is also installed in the shared beforeEach, so it applies to the six unrelated tests in this file.

Suggest deleting the whole page.route block and the now-unused ListAssetsResponse import. If it is load-bearing for something I missed, please add a one-line note saying which request it serves, and align the id with targetJobId so the two ids do not disagree.

await route.fulfill({
json: {
assets: [
{
id: '10000000-0000-4000-8000-000000000002',
name: 'workflow-output.png',
mime_type: 'image/png',
tags: ['output'],
job_id: MOCK_JOBS[1].id,
created_at: '2026-08-30T00:00:00Z',
updated_at: '2026-08-30T00:00:00Z'
}
],
total: 1,
has_more: false
} satisfies ListAssetsResponse
})
})
await comfyPage.settings.setSetting('Comfy.Minimap.Visible', false)
await comfyPage.settings.setSetting('Comfy.Queue.QPOV2', false)
await comfyPage.setup()
Expand Down Expand Up @@ -116,6 +146,102 @@ test.describe('Queue overlay', () => {
await expect(comfyPage.page.locator('[data-job-id]').first()).toBeHidden()
})

test.describe('workflow output focus', () => {
test.use({
initialFeatureFlags: { assets: true },
initialSettings: { 'Comfy.Assets.UseAssetAPI': true }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — neither of these gates anything on this code path.

Comfy.Assets.UseAssetAPI routes the model library to the asset browser (sidebarTabStore, modelStore, ModelLibrarySidebarTab) and enables assetService.isAssetAPIEnabled(). The assets server flag is read in exactly one place — isAssetPreviewSupported() in platform/assets/utils/assetPreviewUtil.ts, used by the Load3D / 3D-preview thumbnail persistence path. The Generated sidebar list, the queue overlay View button, and focusAssetInSidebar all ignore both.

Also worth noting initialFeatureFlags seeds the ff: localStorage override, which FeatureFlagHelper documents as dev-only and tree-shaken from production builds — so on a prod-build run it is a no-op regardless.

Unless one of these is actually needed, drop both; they make the test look like it is covering asset-API behaviour that it is not.

})

test.afterEach(async ({ comfyPage }) => {
await comfyPage.workflow.setupWorkflowsDirectory({})
})

test('focuses the restored workflow output in Assets', async ({
comfyPage,
getWebSocket
}) => {
const workflowName = `assets-output-focus-${Date.now().toString(36)}`
const job = MOCK_JOBS[1]
const nodeId = '1'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — hardcoding node id '1' couples this test to the default workflow's node ids.

app.ts's executed handler calls setNodeOutputsByExecutionId, which does executionIdToNodeLocatorId(app.rootGraph, executionId) and silently returns when the id does not resolve to a node in the current graph. If the default workflow's node ids ever change, this test does not fail with "node 1 not found" — it hangs on the first expect.poll until timeout with an opaque message.

browser_tests/tests/workflowPersistence.spec.ts handles the same case by deriving the id (getRequiredFirstNodeRef -> String(firstNode.id)). Worth following that here.

const output = {
images: [
{
filename: 'workflow-output.png',
subfolder: '',
type: 'output'
}
]
}
const ws = await getWebSocket()
const execution = new ExecutionHelper(comfyPage, ws)

await comfyPage.featureFlags.setServerFlagsPersistent({ assets: true })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — third mechanism for the same flag: test.use({ initialFeatureFlags: { assets: true } }) (localStorage ff: seed) plus this (api.serverFeatureFlags). Setting one flag two ways in one test usually means the first one did not work and the second was added without removing it. Given nothing on this journey reads the assets flag (see comment on line 152), please remove both — or keep exactly one and say why it is required.

await comfyPage.settings.setSetting(
'Comfy.Workflow.WorkflowTabsPosition',
'Sidebar'
)
await comfyPage.menu.workflowsTab.open()
await comfyPage.menu.topbar.saveWorkflow(workflowName)
execution.executed(job.id, nodeId, output)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRIVIAL — worth knowing so the test is not over-trusted: the prompt_id here is decorative. app.ts's executed listener writes to the node output store unconditionally, and the other executed listener (changeTracker.ts, which does use prompt_id) bails immediately because useExecutionStore().queuedJobs[job.id] is empty — nothing was ever queued through storeJob. Restoration on tab switch works via deactivate() -> store() -> snapshotOutputs(), which does not care about job ids.

So the executed output and the queue job's asset are linked only by matching filenames, not by id. The PR description reads as if the two halves are causally connected; they are not. Not a defect, but the queuedJobs-keyed changeTracker path is left uncovered.

await expect
.poll(() =>
comfyPage.page.evaluate(
([id]) => window.app!.nodeOutputs[id],
[nodeId]
)
)
.toEqual(output)

await comfyPage.command.executeCommand('Comfy.NewBlankWorkflow')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TRIVIAL — lines 184-215 (save workflow, produce output, Comfy.NewBlankWorkflow, switch back, assert output restored) duplicate browser_tests/tests/workflowPersistence.spec.ts -> 'Node outputs are preserved when switching workflow tabs'. The only new assertion in that stretch is that the blank workflow does not inherit the output.

The genuinely new coverage is lines 223-241 (queue View -> exact asset focused, output not clobbered). Consider trimming the front half to the minimum needed to set up that state, and per AGENTS.md ('be parsimonious', composable tests) putting the focus test somewhere it is discoverable — this is currently a workflow-persistence + assets test living in queueOverlay.spec.ts.

await comfyPage.workflow.waitForWorkflowIdle()
await expect
.poll(() =>
comfyPage.page.evaluate(
([id]) => window.app!.nodeOutputs[id],
[nodeId]
)
)
.toBeUndefined()

await comfyPage.menu.workflowsTab.getPersistedItem(workflowName).click()
await comfyPage.workflow.waitForWorkflowIdle()
await expect
.poll(() =>
comfyPage.page.evaluate(
([id]) => window.app!.nodeOutputs[id],
[nodeId]
)
)
.toEqual(output)

await comfyPage.menu.assetsTab.open({ waitForAssets: false })

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHOULD FIX — what is this preload for?

focusAssetInSidebar already awaits assetsStore.updateHistory() before selecting, and AssetsSidebarTab is a statically-imported markRaw component, so the cold path should work without warming the store first. Opening Assets here and then switching back to Workflows also unmounts the tab, which runs deactivate() -> clearSelection(), so it cannot be preserving selection state either.

If you added this to fix a flake, that flake is worth chasing to root cause rather than warming: the only way it should matter is if the tab's watch(activeTab, { immediate: true }) -> clearSelection() can land after setSelection() on a cold mount, which would be a real product bug in the queue -> Assets focus path, not a test problem. If it is not needed, delete these four lines — as written they add an unrelated "card is visible in Assets" assertion that sidebar/assetsSidebarTab.spec.ts already covers.

await expect(
comfyPage.menu.assetsTab.getAssetCardByName('workflow-output')
).toBeVisible()
await comfyPage.menu.workflowsTab.open()

await comfyPage.page.getByTestId(TestIds.queue.overlayToggle).click()
const jobRow = comfyPage.page.locator(`[data-job-id="${job.id}"]`)
await jobRow.hover()
await jobRow.getByRole('button', { name: 'View' }).click()

await expect(comfyPage.menu.assetsTab.generatedTab).toBeVisible()
await expect(comfyPage.menu.assetsTab.selectedCards).toHaveCount(1)
await expect(comfyPage.menu.assetsTab.selectedCards).toHaveAttribute(
'data-asset-id',
job.id
)
await expect
.poll(() =>
comfyPage.page.evaluate(
([id]) => window.app!.nodeOutputs[id],
[nodeId]
)
)
.toEqual(output)
})
})

test('Job details popover stays inside the viewport for bottom rows', async ({
comfyPage
}) => {
Expand Down
Loading