Add more read-only portal UI tests
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 4m46s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 16s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Successful in 1m37s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 4m46s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 16s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Successful in 1m37s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 4s
This commit is contained in:
+53
-1
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user