Add read-only portal UI coverage
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 4m55s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 14s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Failing after 3m31s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Failing after 5s

This commit is contained in:
2026-10-26 16:15:10 +00:00
parent 8de0f8d7f0
commit fc66e6ab7c
+115
View File
@@ -59,3 +59,118 @@ test.describe('ComfyUI Portal browser flow', () => {
expect(overflow, 'mobile layout should not create horizontal scrolling').toBe(false);
});
});
const adminUser = { id: 'user_admin', username: 'admin', displayName: 'Admin', role: 'admin' };
const regularUser = { id: 'user_regular', username: 'user', displayName: 'User', role: 'user' };
const connectedServer = {
reachable: true,
version: '0.3.0',
os: 'linux',
pythonVersion: '3.12.8',
devices: [{ name: 'GPU 0', type: 'cuda', vramTotal: 8 * 1073741824, vramFree: 6 * 1073741824 }],
queue: { running: 0, pending: 0, total: 0 },
};
const managerInfo = { managerVersion: '3.0.0', currentVersion: '0.3.0', versions: ['0.3.0', '0.2.9'] };
async function mockReadOnlyApi(page, { user = adminUser, jobs = [], running = null, server = connectedServer, manager = managerInfo } = {}) {
await page.route('**/api/**', async (route) => {
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/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 }) });
}
if (url.pathname === '/api/comfy/manager') {
if (manager === 'unavailable') return route.fulfill({ status: 502, contentType: 'application/json', body: JSON.stringify({ error: 'Manager unavailable' }) });
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(manager) });
}
if (url.pathname === '/api/assets/meta') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ width: 1280, height: 720, sizeBytes: 2097152 }) });
if (url.pathname === '/api/assets') return route.fulfill({ status: 200, contentType: 'application/octet-stream', body: 'test asset' });
return route.continue();
});
}
test.describe('ComfyUI Portal read-only UI states', () => {
test('root and unknown routes redirect an unauthenticated visitor to sign in', async ({ page }) => {
await mockReadOnlyApi(page, { user: null });
await page.goto('/');
await expect(page).toHaveURL(/\/login/);
await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible();
await page.goto('/does-not-exist');
await expect(page).toHaveURL(/\/login/);
});
test('refresh reloads the job list and returns to a non-loading state', async ({ page }) => {
let jobRequestCount = 0;
await mockReadOnlyApi(page, { jobs: [] });
await page.unroute('**/api/**');
await page.route('**/api/**', async (route) => {
const pathname = new URL(route.request().url()).pathname;
if (pathname === '/api/me') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ user: adminUser }) });
if (pathname === '/api/server-status') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ status: connectedServer }) });
if (pathname === '/api/comfy/manager') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(managerInfo) });
if (pathname === '/api/jobs') {
jobRequestCount += 1;
const jobs = jobRequestCount > 1 ? [{ promptId: 'job-refresh', title: 'Refreshed job', status: 'completed', queuedAt: 1000, durationMs: 2500, outputCount: 0, assets: [], models: [], progress: null }] : [];
return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ jobs, running: null }) });
}
return route.continue();
});
await page.goto('/jobs');
await expect(page.getByText('No remote jobs were returned.')).toBeVisible();
await page.getByRole('button', { name: 'Refresh' }).click();
await expect(page.getByText('Refreshed job')).toBeVisible();
await expect(page.getByText('No remote jobs were returned.')).toHaveCount(0);
});
test('renders running progress, queue metadata, models, and asset metadata', async ({ page }) => {
const running = { promptId: 'running-1', title: 'Generating scene', status: 'running', queuedAt: Date.now() - 65000, durationMs: null, outputCount: 0, assets: [], models: [{ nodeId: '1', type: 'CheckpointLoader', name: 'model.safetensors' }], progress: { value: 3, max: 10, percent: 30 } };
const jobs = [{ promptId: 'done-1', title: 'Finished scene', status: 'completed', queuedAt: 1000, durationMs: 65000, outputCount: 1, assets: [{ filename: 'scene.png', url: '/api/assets?filename=scene.png&subfolder=&type=output', type: 'image' }], models: [], progress: null }];
await mockReadOnlyApi(page, { jobs, running });
await page.goto('/jobs');
await expect(page.getByRole('heading', { name: 'Generating scene' })).toBeVisible();
await expect(page.getByText('30% complete')).toBeVisible();
await expect(page.getByText('model.safetensors')).toBeVisible();
await expect(page.getByRole('heading', { name: 'Finished scene' })).toBeVisible();
await expect(page.getByText('scene.png')).toBeVisible();
await expect(page.getByText('1280 × 720')).toBeVisible();
await expect(page.getByText('2.0 MB')).toBeVisible();
});
test('renders failed jobs and jobs without output assets', async ({ page }) => {
const jobs = [
{ promptId: 'failed-1', title: 'Failed scene', status: 'failed', queuedAt: 1000, durationMs: null, outputCount: 0, assets: [], models: [], progress: null },
{ promptId: 'queued-1', title: 'Queued scene', status: 'queued', queuedAt: null, durationMs: null, outputCount: 0, assets: [], models: [], progress: null },
];
await mockReadOnlyApi(page, { jobs });
await page.goto('/jobs');
await expect(page.getByRole('heading', { name: 'Failed scene' })).toBeVisible();
await expect(page.getByText('failed', { exact: true })).toBeVisible();
await expect(page.getByRole('heading', { name: 'Queued scene' })).toBeVisible();
await expect(page.getByText('queued', { exact: true })).toBeVisible();
await expect(page.getByText('No output assets')).toHaveCount(2);
});
test('shows a clear unavailable state when ComfyUI and Manager status cannot be read', async ({ page }) => {
await mockReadOnlyApi(page, { server: 'unavailable', manager: 'unavailable' });
await page.goto('/jobs');
await expect(page.getByText('Unavailable', { exact: true })).toBeVisible();
await expect(page.getByText('Unable to read server status')).toBeVisible();
await expect(page.getByText('No remote jobs were returned.')).toBeVisible();
});
test('shows Manager controls only to administrators', async ({ page }) => {
await mockReadOnlyApi(page, { user: regularUser });
await page.goto('/jobs');
await expect(page.getByText('Runtime controls')).toHaveCount(0);
await page.unroute('**/api/**');
await mockReadOnlyApi(page, { user: adminUser });
await page.reload();
await expect(page.getByText('Runtime controls')).toBeVisible();
await expect(page.getByRole('button', { name: 'Restart ComfyUI' })).toBeVisible();
await expect(page.getByRole('button', { name: 'Update all' })).toBeVisible();
});
});