Persist job history and show model usage stats
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 5m14s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 16s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Successful in 1m58s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Successful in 5s

This commit is contained in:
2026-10-26 17:19:11 +00:00
parent ba34d33308
commit 2f7f2cc375
8 changed files with 252 additions and 6 deletions
+15 -1
View File
@@ -71,8 +71,9 @@ const connectedServer = {
queue: { running: 0, pending: 0, total: 0 },
};
const managerInfo = { managerVersion: '3.0.0', currentVersion: '0.3.0', versions: ['0.3.0', '0.2.9'] };
const modelStats = { totalJobs: 3, totalModels: 2, models: [{ name: 'model-a.safetensors', jobCount: 2 }, { name: 'style.safetensors', jobCount: 1 }] };
async function mockReadOnlyApi(page, { user = adminUser, jobs = [], running = null, server = connectedServer, manager = managerInfo } = {}) {
async function mockReadOnlyApi(page, { user = adminUser, jobs = [], running = null, server = connectedServer, manager = managerInfo, stats = modelStats } = {}) {
test.skip(!requiresCredentials, 'deployed read-only UI tests require the configured E2E account');
if (user) {
await page.context().addCookies([{ name: 'cp_auth', value: username, url: process.env.E2E_BASE_URL || 'http://127.0.0.1:7002' }]);
@@ -85,6 +86,7 @@ async function mockReadOnlyApi(page, { user = adminUser, jobs = [], running = nu
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/model-stats') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(stats) });
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 }) });
@@ -116,6 +118,7 @@ test.describe('ComfyUI Portal read-only UI states', () => {
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/model-stats') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(modelStats) });
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') {
@@ -192,6 +195,17 @@ test.describe('ComfyUI Portal read-only UI states', () => {
await expect(page.getByText('6.0 GB free of 8.0 GB')).toBeVisible();
});
test('renders persistent most-used model statistics without counting duplicate jobs twice', async ({ page }) => {
await mockReadOnlyApi(page);
await page.goto('/jobs');
await expect(page.getByRole('heading', { name: 'Most used models' })).toBeVisible();
await expect(page.getByText('3 tracked jobs · 2 models')).toBeVisible();
await expect(page.locator('.stats-list li')).toHaveCount(2);
await expect(page.locator('.stats-list li').first()).toContainText('model-a.safetensors');
await expect(page.locator('.stats-list li').first()).toContainText('2 jobs');
await expect(page.locator('.stats-list li').nth(1)).toContainText('style.safetensors');
});
test('renders video assets with metadata and safe output links', async ({ page }) => {
const jobs = [{
promptId: 'video-1', title: 'Finished video', status: 'completed', queuedAt: 1000,