diff --git a/4-Infrastructure/k3s-flake/tests/homarr-verify.spec.ts b/4-Infrastructure/k3s-flake/tests/homarr-verify.spec.ts index db93b605..ab1ad8a6 100644 --- a/4-Infrastructure/k3s-flake/tests/homarr-verify.spec.ts +++ b/4-Infrastructure/k3s-flake/tests/homarr-verify.spec.ts @@ -49,24 +49,26 @@ test('Verify Homarr configured apps via SSO', async ({ page }) => { } } - // Land on Homarr. If we see a "Login" link, click it to authenticate to Homarr itself - const loginLink = page.locator('a[href="/auth/login"], a:has-text("Login")').first(); - if (await loginLink.isVisible({ timeout: 5000 }).catch(() => false)) { - console.log('Homarr login link visible. Clicking it to authenticate NextAuth...'); - await loginLink.click(); - await page.waitForTimeout(6000); - - // If Authentik consent/authorization screen appears after clicking login - if (page.url().includes('consent') || page.url().includes('authorize') || page.url().includes('application/o/authorize')) { - console.log('Consent/Authorization screen detected after Homarr login. Clicking continue...'); - const continueBtn = page.locator('button:has-text("Continue"), input[type="submit"], button[type="submit"]').first(); - if (await continueBtn.isVisible()) { - await continueBtn.click(); - await page.waitForTimeout(6000); - } + // Force NextAuth OIDC authentication by navigating to the login URL + console.log('Navigating directly to /auth/login to trigger OIDC session sync...'); + await page.goto('https://researchstack.info/auth/login'); + await page.waitForTimeout(6000); + + // If Authentik consent/authorization screen appears after navigating to login + if (page.url().includes('consent') || page.url().includes('authorize') || page.url().includes('application/o/authorize')) { + console.log('Consent/Authorization screen detected. Clicking continue...'); + const continueBtn = page.locator('button:has-text("Continue"), input[type="submit"], button[type="submit"]').first(); + if (await continueBtn.isVisible({ timeout: 5000 }).catch(() => false)) { + await continueBtn.click(); + await page.waitForTimeout(6000); } } + // Navigate back to the home board + console.log('Navigating back to home board...'); + await page.goto('https://researchstack.info/'); + await page.waitForTimeout(6000); + const title = await page.title(); console.log('Final Page Title:', title); console.log('Final URL:', page.url());