import { afterEach, describe, expect, it, vi } from "vitest"; import { NextRequest } from "next/server"; // The Manager must not load the business Auth.js module even if a stale // client requests `/api/auth/session`. vi.mock("@/auth", () => { throw new Error("Business Auth.js must not load in Manager mode."); }); import { GET } from "@/app/api/auth/[...nextauth]/route"; describe("Manager business-auth boundary", () => { const originalManagerMode = process.env.MANAGER_MODE; afterEach(() => { if (originalManagerMode === undefined) delete process.env.MANAGER_MODE; else process.env.MANAGER_MODE = originalManagerMode; }); it("returns 404 without importing business Auth.js", async () => { process.env.MANAGER_MODE = "true"; const response = await GET(new NextRequest("https://manager.example.com/api/auth/session")); expect(response.status).toBe(404); }); });