-
Notifications
You must be signed in to change notification settings - Fork 448
Add queue overlay tests and stories #7342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christian-byrne
merged 1 commit into
queue-overlay-additions
from
queue-overlay-tests-completion
Dec 14, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import type { Page } from '@playwright/test' | ||
| import { expect } from '@playwright/test' | ||
|
|
||
| export class QueueList { | ||
| constructor(public readonly page: Page) {} | ||
|
|
||
| get toggleButton() { | ||
| return this.page.getByTestId('queue-toggle-button') | ||
| } | ||
|
|
||
| get inlineProgress() { | ||
| return this.page.getByTestId('queue-inline-progress') | ||
| } | ||
|
|
||
| get overlay() { | ||
| return this.page.getByTestId('queue-overlay') | ||
| } | ||
|
|
||
| get closeButton() { | ||
| return this.page.getByTestId('queue-overlay-close-button') | ||
| } | ||
|
|
||
| get jobItems() { | ||
| return this.page.getByTestId('queue-job-item') | ||
| } | ||
|
|
||
| get clearHistoryButton() { | ||
| return this.page.getByRole('button', { name: /Clear History/i }) | ||
| } | ||
|
|
||
| async open() { | ||
| if (!(await this.overlay.isVisible())) { | ||
| await this.toggleButton.click() | ||
| await expect(this.overlay).toBeVisible() | ||
| } | ||
| } | ||
|
|
||
| async close() { | ||
| if (await this.overlay.isVisible()) { | ||
| await this.closeButton.click() | ||
| await expect(this.overlay).not.toBeVisible() | ||
| } | ||
| } | ||
|
|
||
| async getJobCount(state?: string) { | ||
| if (state) { | ||
| return await this.page | ||
| .locator(`[data-testid="queue-job-item"][data-job-state="${state}"]`) | ||
| .count() | ||
| } | ||
| return await this.jobItems.count() | ||
| } | ||
|
|
||
| getJobAction(actionKey: string) { | ||
| return this.page.getByTestId(`job-action-${actionKey}`) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| import { expect, mergeTests } from '@playwright/test' | ||
|
|
||
| import type { ComfyPage } from '../../fixtures/ComfyPage' | ||
| import { comfyPageFixture } from '../../fixtures/ComfyPage' | ||
| import { webSocketFixture } from '../../fixtures/ws' | ||
| import type { WsMessage } from '../../fixtures/ws' | ||
|
|
||
| const test = mergeTests(comfyPageFixture, webSocketFixture) | ||
|
|
||
| type QueueState = { | ||
| running: QueueJob[] | ||
| pending: QueueJob[] | ||
| } | ||
|
|
||
| type QueueJob = [ | ||
| string, | ||
| string, | ||
| Record<string, unknown>, | ||
| Record<string, unknown>, | ||
| string[] | ||
| ] | ||
|
|
||
| type QueueController = { | ||
| state: QueueState | ||
| sync: ( | ||
| ws: { trigger(data: WsMessage, url?: string): Promise<void> }, | ||
| nextState: Partial<QueueState> | ||
| ) => Promise<void> | ||
| } | ||
|
|
||
| test.describe('Queue UI', () => { | ||
| let queue: QueueController | ||
|
|
||
| test.beforeEach(async ({ comfyPage }) => { | ||
| await comfyPage.page.route('**/api/prompt', async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ | ||
| prompt_id: 'mock-prompt-id', | ||
| number: 1, | ||
| node_errors: {} | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| // Mock history to avoid pulling real data | ||
| await comfyPage.page.route('**/api/history**', async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ History: [] }) | ||
| }) | ||
| }) | ||
|
|
||
| queue = await createQueueController(comfyPage) | ||
| }) | ||
|
|
||
| test('toggles overlay and updates count from status events', async ({ | ||
| comfyPage, | ||
| ws | ||
| }) => { | ||
| await queue.sync(ws, { running: [], pending: [] }) | ||
|
|
||
| await expect(comfyPage.queueList.toggleButton).toContainText('0') | ||
| await expect(comfyPage.queueList.toggleButton).toContainText(/queued/i) | ||
| await expect(comfyPage.queueList.overlay).toBeHidden() | ||
|
|
||
| await queue.sync(ws, { | ||
| pending: [queueJob('1', 'mock-pending', 'client-a')] | ||
| }) | ||
|
|
||
| await expect(comfyPage.queueList.toggleButton).toContainText('1') | ||
| await expect(comfyPage.queueList.toggleButton).toContainText(/queued/i) | ||
|
|
||
| await comfyPage.queueList.open() | ||
| await expect(comfyPage.queueList.overlay).toBeVisible() | ||
| await expect(comfyPage.queueList.jobItems).toHaveCount(1) | ||
|
|
||
| await comfyPage.queueList.close() | ||
| await expect(comfyPage.queueList.overlay).toBeHidden() | ||
| }) | ||
|
|
||
| test('displays running and pending jobs via status updates', async ({ | ||
| comfyPage, | ||
| ws | ||
| }) => { | ||
| await queue.sync(ws, { | ||
| running: [queueJob('2', 'mock-running', 'client-b')], | ||
| pending: [queueJob('3', 'mock-pending', 'client-c')] | ||
| }) | ||
|
|
||
| await comfyPage.queueList.open() | ||
| await expect(comfyPage.queueList.jobItems).toHaveCount(2) | ||
|
|
||
| const firstJob = comfyPage.queueList.jobItems.first() | ||
| await firstJob.hover() | ||
|
|
||
| const cancelAction = firstJob | ||
| .getByTestId('job-action-cancel-running') | ||
| .or(firstJob.getByTestId('job-action-cancel-hover')) | ||
|
|
||
| await expect(cancelAction).toBeVisible() | ||
| }) | ||
| }) | ||
|
|
||
| const queueJob = ( | ||
| queueIndex: string, | ||
| promptId: string, | ||
| clientId: string | ||
| ): QueueJob => [ | ||
| queueIndex, | ||
| promptId, | ||
| { client_id: clientId }, | ||
| { class_type: 'Note' }, | ||
| ['output'] | ||
| ] | ||
|
|
||
| const createQueueController = async ( | ||
| comfyPage: ComfyPage | ||
| ): Promise<QueueController> => { | ||
| const state: QueueState = { running: [], pending: [] } | ||
|
|
||
| // Single queue handler reads the latest in-memory state | ||
| await comfyPage.page.route('**/api/queue', async (route) => { | ||
| await route.fulfill({ | ||
| status: 200, | ||
| contentType: 'application/json', | ||
| body: JSON.stringify({ | ||
| queue_running: state.running, | ||
| queue_pending: state.pending | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| const sync = async ( | ||
| ws: { trigger(data: WsMessage, url?: string): Promise<void> }, | ||
| nextState: Partial<QueueState> | ||
| ) => { | ||
| if (nextState.running) state.running = nextState.running | ||
| if (nextState.pending) state.pending = nextState.pending | ||
|
|
||
| const total = state.running.length + state.pending.length | ||
| const queueResponse = comfyPage.page.waitForResponse('**/api/queue') | ||
|
|
||
| await ws.trigger({ | ||
| type: 'status', | ||
| data: { | ||
| status: { exec_info: { queue_remaining: total } } | ||
| } | ||
| }) | ||
|
|
||
| await queueResponse | ||
| } | ||
|
|
||
| return { state, sync } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider tightening typing for
stateandactionKeyto match queue/job domaingetJobCount(state?: string)andgetJobAction(actionKey: string)currently accept plain strings, while the underlying UI likely has a closed set of job states and actions.If there is already a shared string-literal union or enum for job states / action keys elsewhere in the codebase (e.g., used by
useJobListor job type definitions), it would be preferable to reuse that type here instead of barestring. That keeps tests in sync with the domain model and prevents typos in selectors from compiling.If no such shared type exists yet, this is fine for now, but consider introducing one when you touch this area again.
🤖 Prompt for AI Agents