Files
ComfyUI_frontend/browser_tests/fixtures/helpers/QueueHelper.ts
bymyself 8d1ab9bc98 test: add 106 Playwright E2E tests covering UI coverage gaps
Add comprehensive E2E test coverage across 18 spec files and 2 test helpers:

Infrastructure:
- FeatureFlagHelper: manage localStorage feature flags and mock /api/features
- QueueHelper: mock queue API routes and wait for completion

Wave 1 (28 tests): toast notifications, error overlay, selection toolbox
actions, linear mode, selection rectangle for vue nodes

Wave 2 (30 tests): V2 node search, bottom panel logs, focus mode, job
history actions, right side panel tabs

Wave 3 (24 tests): errors tab interactions, vue node header actions,
queue notification banners, settings sidebar button

Wave 4 (24 tests): minimap status, widget copy button, floating menus,
node library essentials tab
2026-03-07 17:50:20 -08:00

71 lines
1.7 KiB
TypeScript

import type { Page } from '@playwright/test'
export class QueueHelper {
constructor(private readonly page: Page) {}
/**
* Mock the /api/queue endpoint to return specific queue state.
*/
async mockQueueState(
running: number = 0,
pending: number = 0
): Promise<void> {
await this.page.route('**/api/queue', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify({
queue_running: Array.from({ length: running }, (_, i) => [
i,
`running-${i}`,
{},
{},
[]
]),
queue_pending: Array.from({ length: pending }, (_, i) => [
i,
`pending-${i}`,
{},
{},
[]
])
})
})
)
}
/**
* Mock the /api/history endpoint with completed/failed job entries.
*/
async mockHistory(
jobs: Array<{ promptId: string; status: 'success' | 'error' }>
): Promise<void> {
const history: Record<string, unknown> = {}
for (const job of jobs) {
history[job.promptId] = {
prompt: [0, job.promptId, {}, {}, []],
outputs: {},
status: {
status_str: job.status === 'success' ? 'success' : 'error',
completed: job.status === 'success'
}
}
}
await this.page.route('**/api/history**', (route) =>
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(history)
})
)
}
/**
* Clear all route mocks set by this helper.
*/
async clearMocks(): Promise<void> {
await this.page.unroute('**/api/queue')
await this.page.unroute('**/api/history**')
}
}