fix: improve E2E auth resilience and diagnostics (#33)
- Wait for Authentik popup to fully load (domcontentloaded + networkidle) before interacting with form elements - Add explicit waitFor on username/password fields with 15s timeout - Enable screenshot capture on test failure for better diagnostics - Increase auth setup timeout to 60s to accommodate slow IdP responses The auth setup was failing because the popup form elements weren't ready when Playwright tried to fill them — this adds proper load state waits between each interaction step. Co-authored-by: gandalf-the-greybeard[bot] <gandalf-the-greybeard[bot]@users.noreply.github.com>
This commit was merged in pull request #33.
This commit is contained in:
committed by
GitHub
parent
7603dfeb29
commit
2012a34938
+13
-4
@@ -12,12 +12,21 @@ async function authenticateWithOIDC(page: Page, username: string, password: stri
|
|||||||
await page.getByRole('button', { name: /sign in/i }).click();
|
await page.getByRole('button', { name: /sign in/i }).click();
|
||||||
const popup = await popupPromise;
|
const popup = await popupPromise;
|
||||||
|
|
||||||
// Authentik step 1: fill username
|
// Wait for the Authentik popup to fully load before interacting
|
||||||
await popup.getByRole('textbox', { name: /email or username/i }).fill(username);
|
await popup.waitForLoadState('domcontentloaded');
|
||||||
|
await popup.waitForLoadState('networkidle');
|
||||||
|
|
||||||
|
// Authentik step 1: fill username — wait for the form to render
|
||||||
|
const usernameField = popup.getByRole('textbox', { name: /email or username/i });
|
||||||
|
await usernameField.waitFor({ state: 'visible', timeout: 15_000 });
|
||||||
|
await usernameField.fill(username);
|
||||||
await popup.getByRole('button', { name: /log in/i }).click();
|
await popup.getByRole('button', { name: /log in/i }).click();
|
||||||
|
|
||||||
// Authentik step 2: fill password
|
// Authentik step 2: fill password — wait for the next step to load
|
||||||
await popup.getByRole('textbox', { name: /password/i }).fill(password);
|
await popup.waitForLoadState('networkidle');
|
||||||
|
const passwordField = popup.getByRole('textbox', { name: /password/i });
|
||||||
|
await passwordField.waitFor({ state: 'visible', timeout: 15_000 });
|
||||||
|
await passwordField.fill(password);
|
||||||
await popup.getByRole('button', { name: /continue|log in/i }).click();
|
await popup.getByRole('button', { name: /continue|log in/i }).click();
|
||||||
|
|
||||||
// Wait for the popup to close (Authentik redirects back, Headlamp processes callback)
|
// Wait for the popup to close (Authentik redirects back, Headlamp processes callback)
|
||||||
|
|||||||
@@ -11,9 +11,10 @@ export default defineConfig({
|
|||||||
use: {
|
use: {
|
||||||
baseURL: process.env.HEADLAMP_URL || 'https://headlamp.animaniacs.farh.net',
|
baseURL: process.env.HEADLAMP_URL || 'https://headlamp.animaniacs.farh.net',
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
|
screenshot: 'only-on-failure',
|
||||||
},
|
},
|
||||||
projects: [
|
projects: [
|
||||||
{ name: 'setup', testMatch: /auth\.setup\.ts/ },
|
{ name: 'setup', testMatch: /auth\.setup\.ts/, timeout: 60_000 },
|
||||||
{
|
{
|
||||||
name: 'chromium',
|
name: 'chromium',
|
||||||
use: {
|
use: {
|
||||||
|
|||||||
Reference in New Issue
Block a user