From cf407a2c13d334e57f23622acf23b9d6e3b7e4d2 Mon Sep 17 00:00:00 2001 From: "chris.dumas" Date: Mon, 26 Oct 2026 16:38:03 +0000 Subject: [PATCH] Add more read-only portal UI tests --- e2e/portal.spec.js | 54 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/e2e/portal.spec.js b/e2e/portal.spec.js index 9d0331b..47d4ebc 100644 --- a/e2e/portal.spec.js +++ b/e2e/portal.spec.js @@ -81,7 +81,10 @@ async function mockReadOnlyApi(page, { user = adminUser, jobs = [], running = nu const request = route.request(); const url = new URL(request.url()); if (url.pathname === '/api/me') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ user }) }); - if (url.pathname === '/api/jobs') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ jobs, running }) }); + if (url.pathname === '/api/jobs') { + if (jobs === 'unavailable') return route.fulfill({ status: 503, contentType: 'application/json', body: JSON.stringify({ error: 'Jobs unavailable' }) }); + return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ jobs, running }) }); + } if (url.pathname === '/api/server-status') { if (server === 'unavailable') return route.fulfill({ status: 502, contentType: 'application/json', body: JSON.stringify({ error: 'ComfyUI is unavailable right now.' }) }); return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ status: server }) }); @@ -177,4 +180,53 @@ test.describe('ComfyUI Portal read-only UI states', () => { await expect(page.getByRole('button', { name: 'Restart ComfyUI' })).toBeVisible(); await expect(page.getByRole('button', { name: 'Update all' })).toBeVisible(); }); + + test('renders connected server details, queue counts, and device capacity', async ({ page }) => { + await mockReadOnlyApi(page); + await page.goto('/jobs'); + await expect(page.getByText('Connected', { exact: true })).toBeVisible(); + await expect(page.getByText('0', { exact: true }).first()).toBeVisible(); + await expect(page.getByText('linux', { exact: true })).toBeVisible(); + await expect(page.getByText('3.12.8', { exact: true })).toBeVisible(); + await expect(page.getByText('GPU 0', { exact: true })).toBeVisible(); + await expect(page.getByText('6.0 GB free of 8.0 GB')).toBeVisible(); + }); + + test('renders video assets with metadata and safe output links', async ({ page }) => { + const jobs = [{ + promptId: 'video-1', title: 'Finished video', status: 'completed', queuedAt: 1000, + durationMs: 12000, outputCount: 1, + assets: [{ filename: 'clip.mp4', url: '/api/assets?filename=clip.mp4&subfolder=&type=output', type: 'video' }], + models: [], progress: null, + }]; + await mockReadOnlyApi(page, { jobs }); + await page.goto('/jobs'); + await expect(page.locator('video')).toHaveAttribute('src', /filename=clip\.mp4/); + await expect(page.getByText('clip.mp4')).toBeVisible(); + await expect(page.getByText('2.0 MB')).toBeVisible(); + await expect(page.locator('figure a')).toHaveAttribute('target', '_blank'); + await expect(page.locator('figure a')).toHaveAttribute('rel', 'noopener'); + }); + + test('shows a clear jobs error while retaining server status', async ({ page }) => { + await mockReadOnlyApi(page, { jobs: 'unavailable' }); + await page.goto('/jobs'); + await expect(page.getByText('Unable to load jobs.')).toBeVisible(); + await expect(page.getByText('Connected', { exact: true })).toBeVisible(); + await expect(page.getByText('No remote jobs were returned.')).toHaveCount(0); + }); + + test('does not invoke a runtime control when an administrator cancels confirmation', async ({ page }) => { + const requests = []; + await mockReadOnlyApi(page); + await page.route('**/api/comfy/restart', async (route) => { + requests.push(route.request().method()); + await route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ message: 'accepted' }) }); + }); + await page.goto('/jobs'); + page.once('dialog', dialog => dialog.dismiss()); + await page.getByRole('button', { name: 'Restart ComfyUI' }).click(); + await expect.poll(() => requests).toEqual([]); + await expect(page.getByRole('button', { name: 'Restart ComfyUI' })).toBeEnabled(); + }); });