Skip to content
25 changes: 25 additions & 0 deletions apps/web/app/e2e/session-warmup/page.tsx
Original file line number Diff line number Diff line change
@@ -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 <div></div>;
};

export default Page;
4 changes: 1 addition & 3 deletions apps/web/playwright/fixtures/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading