Prime liveAuthPage with integrations navigation after login

Fix for the 2 remaining OIDC redirect failures: after login, the
page lands on Dashboard. When a test calls page.goto('/setup/...'),
Angular sometimes redirects back to Dashboard because the auth guard
hasn't settled.

Fix: After loginAndGetToken, navigate to /setup/integrations and
wait for [role="tab"] to render. This:
1. Settles the OIDC auth guard (validates token, caches auth state)
2. Lazy-loads the integration module chunk
3. Primes Angular's router with the /setup/ route tree

Subsequent page.goto() calls from tests will work reliably because
Angular already has auth state and the lazy chunk is cached.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
master
2026-04-03 07:41:35 +03:00
parent 95f9ac379f
commit 6771d7fae8

View File

@@ -128,11 +128,20 @@ export const test = base.extend<TestFixtures, WorkerFixtures>({
await ctx.dispose();
}, { scope: 'worker' }],
// Test-scoped: each UI test gets a fresh authenticated page
// Test-scoped: each UI test gets a fresh authenticated page.
// After login, navigate to integrations to prime the auth guard
// and lazy-load the integration module. This prevents the OIDC
// callback race where page.goto() redirects back to Dashboard.
liveAuthPage: async ({ browser }, use) => {
const context = await browser.newContext({ ignoreHTTPSErrors: true });
const page = await context.newPage();
await loginAndGetToken(page);
// Prime: navigate to integrations shell and wait for tabs to render.
// This ensures auth guard is settled and lazy chunks are loaded.
await page.goto(`${BASE_URL}/setup/integrations`, { waitUntil: 'load', timeout: 30_000 }).catch(() => {});
await page.waitForSelector('[role="tab"]', { timeout: 20_000 }).catch(() => {});
await use(page);
await context.close();
},