fix(e2e): set authDisabled=true in fixtures to bypass Better Auth

The App.tsx production auth path calls signIn.social() when
authDisabled=false, causing E2E tests to render blank. The fixtures
must mock authDisabled=true so the dev login selector is used instead.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Paperclip
2026-03-27 22:18:34 +00:00
parent a550fc4438
commit 982d6e87b7
+8 -8
View File
@@ -1,14 +1,14 @@
import { test as base } from "@playwright/test";
/**
* Custom test fixture that bypasses the dev login redirect for E2E tests.
* Custom test fixture that bypasses auth for E2E tests.
*
* When AUTH_DISABLED=true, the app fetches /api/dev/config and redirects to
* /login if no dev-user is in localStorage. This fixture:
* 1. Mocks /api/dev/config to return authDisabled: false
* 2. Seeds localStorage with a dev user as a fallback
* When authDisabled=true, the app uses the dev login selector instead of
* Better Auth signIn.social(). This fixture:
* 1. Mocks /api/dev/config to return authDisabled: true
* 2. Seeds localStorage with a dev user so the selector auto-selects a session
*
* This ensures E2E tests render pages directly without the login redirect.
* This ensures E2E tests render pages directly without the auth redirect.
*/
const MOCK_DEV_USERS = {
staff: [
@@ -23,9 +23,9 @@ const MOCK_DEV_USERS = {
export const test = base.extend({
page: async ({ page }, use) => {
// Mock the dev config endpoint so the app skips the auth-disabled redirect
// Mock the dev config endpoint so the app uses dev login selector (bypasses Better Auth)
await page.route("**/api/dev/config", (route) =>
route.fulfill({ json: { authDisabled: false } })
route.fulfill({ json: { authDisabled: true } })
);
// Mock the dev users endpoint for login selector tests
await page.route("**/api/dev/users", (route) =>