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:
@@ -1,14 +1,14 @@
|
|||||||
import { test as base } from "@playwright/test";
|
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
|
* When authDisabled=true, the app uses the dev login selector instead of
|
||||||
* /login if no dev-user is in localStorage. This fixture:
|
* Better Auth signIn.social(). This fixture:
|
||||||
* 1. Mocks /api/dev/config to return authDisabled: false
|
* 1. Mocks /api/dev/config to return authDisabled: true
|
||||||
* 2. Seeds localStorage with a dev user as a fallback
|
* 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 = {
|
const MOCK_DEV_USERS = {
|
||||||
staff: [
|
staff: [
|
||||||
@@ -23,9 +23,9 @@ const MOCK_DEV_USERS = {
|
|||||||
|
|
||||||
export const test = base.extend({
|
export const test = base.extend({
|
||||||
page: async ({ page }, use) => {
|
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) =>
|
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
|
// Mock the dev users endpoint for login selector tests
|
||||||
await page.route("**/api/dev/users", (route) =>
|
await page.route("**/api/dev/users", (route) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user