Files
ComfyUiPortalNext/e2e/portal.spec.js
T
chris.dumas 96be6412a8
Test, build, and deploy ComfyUI Jobs / test-build (push) Successful in 4m41s
Test, build, and deploy ComfyUI Jobs / deploy (push) Successful in 14s
Test, build, and deploy ComfyUI Jobs / browser-test (push) Failing after 7m5s
Test, build, and deploy ComfyUI Jobs / qa-gate (push) Failing after 4s
Add portal browser testing and QA issue automation
2026-10-26 14:16:26 +00:00

62 lines
2.7 KiB
JavaScript

const { test, expect } = require('@playwright/test');
const username = process.env.E2E_USERNAME;
const password = process.env.E2E_PASSWORD;
const requiresCredentials = username && password;
test.describe('ComfyUI Portal browser flow', () => {
test.beforeEach(async ({ page }) => {
test.skip(!requiresCredentials, 'E2E_USERNAME and E2E_PASSWORD are required for deployed portal tests');
await page.goto('/login');
});
async function signIn(page, user = username, pass = password) {
await page.getByLabel('Username').fill(user);
await page.getByLabel('Password').fill(pass);
await page.getByRole('button', { name: 'Sign in' }).click();
}
test('valid credentials open the protected job monitor', async ({ page }) => {
await signIn(page);
await expect(page).toHaveURL(/\/jobs/);
await expect(page.getByRole('heading', { name: 'Job monitor' })).toBeVisible();
await expect(page.getByText('ComfyUI status')).toBeVisible();
});
test('invalid credentials remain on sign in with a clear error', async ({ page }) => {
await signIn(page, username, String(password) + '-invalid');
await expect(page).toHaveURL(/\/login/);
await expect(page.getByText('Invalid username or password.')).toBeVisible();
});
test('protected jobs route redirects an unauthenticated visitor', async ({ page }) => {
await page.context().clearCookies();
await page.goto('/jobs');
await expect(page).toHaveURL(/\/login/);
await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible();
});
test('the job monitor exposes stable loading or empty/error states', async ({ page }) => {
await signIn(page);
await expect(page.getByRole('heading', { name: 'Job monitor' })).toBeVisible();
await expect(page.locator('.server-card')).toBeVisible();
await expect(page.locator('.loading, .empty, .notice, .grid .job, .server-error').first()).toBeVisible({ timeout: 15000 });
});
test('an authenticated user can sign out', async ({ page }) => {
await signIn(page);
await expect(page.getByRole('button', { name: 'Sign out' })).toBeVisible();
await page.getByRole('button', { name: 'Sign out' }).click();
await expect(page).toHaveURL(/\/login/);
await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible();
});
test('the portal remains usable at mobile width without horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 390, height: 844 });
await signIn(page);
await expect(page.getByRole('heading', { name: 'Job monitor' })).toBeVisible();
const overflow = await page.evaluate(() => document.documentElement.scrollWidth > window.innerWidth + 1);
expect(overflow, 'mobile layout should not create horizontal scrolling').toBe(false);
});
});