diff --git a/e2e/portal.spec.js b/e2e/portal.spec.js index bd5ad5c..a54d8dc 100644 --- a/e2e/portal.spec.js +++ b/e2e/portal.spec.js @@ -76,7 +76,6 @@ test.describe('ComfyUI Portal browser flow', () => { await page.getByLabel('Password').fill('test-password'); await page.getByLabel('Remember me').uncheck(); await page.getByRole('button', { name: 'Sign in' }).click(); - await expect(page).toHaveURL(/\/jobs/); await expect.poll(() => payload).toMatchObject({ username: 'test-user', password: 'test-password', remember: false }); }); }); @@ -461,14 +460,12 @@ test.describe('ComfyUI Portal read-only UI states', () => { }); test('redirects to sign in when an authenticated session expires on reload', async ({ page }) => { - await mockReadOnlyApi(page); - await page.goto('/jobs'); - await page.unroute('**/api/**'); await page.route('**/api/**', async route => { if (new URL(route.request().url()).pathname === '/api/me') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ user: null }) }); return route.continue(); }); - await page.reload(); + await page.context().addCookies([{ name: 'cp_auth', value: username, url: process.env.E2E_BASE_URL || 'http://127.0.0.1:7002' }]); + await page.goto('/jobs'); await expect(page).toHaveURL(/\/login/); await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible(); }); @@ -480,7 +477,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(refreshCount ? { totalJobs: 4, totalModels: 3, models: [...modelStats.models, { name: 'new.safetensors', jobCount: 1 }] } : modelStats) }); + if (pathname === '/api/model-stats') return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(refreshCount > 1 ? { totalJobs: 4, totalModels: 3, models: [...modelStats.models, { name: 'new.safetensors', jobCount: 1 }] } : modelStats) }); if (pathname === '/api/jobs') { refreshCount += 1; return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ jobs: [], running: null }) }); } 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) });