Files
prowler/ui/tests/auth/auth-session-errors.spec.ts
Davidm4r baf1194824 feat(ui): invitation flow smart routing (#10589)
Co-authored-by: Pablo Fernandez Guerra (PFE) <148432447+pfe-nazaries@users.noreply.github.com>
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 10:11:52 +02:00

88 lines
2.7 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { SignInPage } from "../sign-in-base/sign-in-base-page";
test.describe("Session Error Messages", () => {
// Increase timeout for tests that involve session operations under load
test.setTimeout(60000);
test(
"should show RefreshAccessTokenError message",
{ tag: ["@e2e", "@auth", "@session", "@AUTH-SESSION-E2E-001"] },
async ({ page }) => {
const signInPage = new SignInPage(page);
await signInPage.gotoWithError("RefreshAccessTokenError");
const { isVisible, text } = await signInPage.waitForToast();
if (isVisible && text) {
expect(text).toContain("Session Expired");
expect(text).toContain("Please sign in again");
}
await signInPage.verifyFormElements();
},
);
test(
"should show MissingRefreshToken error message",
{ tag: ["@e2e", "@auth", "@session", "@AUTH-SESSION-E2E-002"] },
async ({ page }) => {
const signInPage = new SignInPage(page);
await signInPage.gotoWithError("MissingRefreshToken");
const { isVisible, text } = await signInPage.waitForToast();
if (isVisible && text) {
expect(text).toContain("Session Error");
}
await expect(signInPage.emailInput).toBeVisible();
},
);
test(
"should show generic error for unknown error types",
{ tag: ["@e2e", "@auth", "@session", "@AUTH-SESSION-E2E-003"] },
async ({ page }) => {
const signInPage = new SignInPage(page);
await signInPage.gotoWithError("UnknownError");
const { isVisible, text } = await signInPage.waitForToast();
if (isVisible && text) {
expect(text).toContain("Authentication Error");
expect(text).toContain("Please sign in again");
}
},
);
test(
"should include callbackUrl in redirect",
{ tag: ["@e2e", "@auth", "@session", "@AUTH-SESSION-E2E-004"] },
async ({ page, context }) => {
const signInPage = new SignInPage(page);
await context.clearCookies();
// Navigate directly to a protected route and assert callbackUrl preservation.
await page.goto("/providers", { waitUntil: "commit" });
await signInPage.verifyRedirectWithCallback("/providers");
},
);
test(
"should preserve query parameters in callbackUrl",
{ tag: ["@e2e", "@auth", "@session", "@AUTH-SESSION-E2E-005"] },
async ({ page, context }) => {
const signInPage = new SignInPage(page);
await context.clearCookies();
// Navigate to a protected route with query params and assert they are preserved.
await page.goto("/providers?ref=test", {
waitUntil: "commit",
});
await signInPage.verifyRedirectWithCallback("/providers?ref=test");
},
);
});