From e0fd01e37746825d5996bc4f6f1833ba1bb50174 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Mon, 5 Jan 2026 17:22:52 +0100 Subject: [PATCH] feat: add lightweight E2E session warmup page (#26451) * feat: add lightweight E2E session warmup endpoint - Add /api/__e2e__/session-warmup endpoint that triggers NextAuth session loading - Update apiLogin fixture to use the new endpoint instead of navigating to /settings/my-account/profile - The endpoint is gated by NEXT_PUBLIC_IS_E2E=1 (already set in playwright.config.ts) - This reduces overhead in E2E tests by avoiding loading a full UI page just to warm up the session Co-Authored-By: eunjae@cal.com * refactor: move session warmup endpoint to App Router - Move /api/__e2e__/session-warmup from pages/api to app/api - Use App Router patterns (NextResponse, buildLegacyRequest) - Maintains same functionality for E2E session warming Co-Authored-By: eunjae@cal.com * rename path * refactor: switch from API route to minimal SSR page (Option 2) - Replace /api/e2e/session-warmup API route with /e2e/session-warmup page - Use App Router page pattern with getServerSession for session warmup - Update apiLogin fixture to navigate to the page instead of API request Co-Authored-By: eunjae@cal.com * revert users fixture but with a new url * render nothing on success * clean up * trying something * Revert "trying something" This reverts commit 2ae2f7dcb42612e54eb072a9f09857272020889a. --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Keith Williams --- apps/web/app/e2e/session-warmup/page.tsx | 25 ++++++++++++++++++++++++ apps/web/playwright/fixtures/users.ts | 4 +--- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 apps/web/app/e2e/session-warmup/page.tsx diff --git a/apps/web/app/e2e/session-warmup/page.tsx b/apps/web/app/e2e/session-warmup/page.tsx new file mode 100644 index 0000000000..f7a2c65ed2 --- /dev/null +++ b/apps/web/app/e2e/session-warmup/page.tsx @@ -0,0 +1,25 @@ +import process from "node:process"; + +import { notFound } from "next/navigation"; + +/** + * E2E-only page for warming up the NextAuth session. + * This triggers the jwt and session callbacks that populate the session + * with profile, org, and other important data. + * + * Only available when NEXT_PUBLIC_IS_E2E=1 is set (automatically set by playwright.config.ts) + * or in development mode. + */ +const Page = (): JSX.Element => { + // Gate this page to E2E test mode or dev only + if ( + process.env.NEXT_PUBLIC_IS_E2E !== "1" && + process.env.NODE_ENV !== "development" + ) { + notFound(); + } + + return
; +}; + +export default Page; diff --git a/apps/web/playwright/fixtures/users.ts b/apps/web/playwright/fixtures/users.ts index 4a53966ec6..012a2ff44a 100644 --- a/apps/web/playwright/fixtures/users.ts +++ b/apps/web/playwright/fixtures/users.ts @@ -1172,10 +1172,8 @@ export async function apiLogin( * Critical: Navigate to a protected page to trigger NextAuth session loading * This forces NextAuth to run the jwt and session callbacks that populate * the session with profile, org, and other important data - * We picked /settings/my-account/profile due to it being one of - * our lighest protected pages and doesnt do anything other than load the user profile */ - await page.goto(navigateToUrl || "/settings/my-account/profile"); + await page.goto(navigateToUrl || "/e2e/session-warmup"); // Wait for the session API call to complete to ensure session is fully established // Only wait if we're on a protected page that would trigger the session API call