32 lines
998 B
TypeScript
32 lines
998 B
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("~/utils/db/logs.db.server", () => ({ createLogLogout: vi.fn() }));
|
|
vi.mock("~/utils/session.server", () => ({
|
|
getUserInfo: vi.fn(async () => ({ userId: null })),
|
|
logout: vi.fn(async () => new Response(null, { status: 302 })),
|
|
validateCSRFToken: vi.fn(),
|
|
}));
|
|
|
|
import { loader } from "./logout";
|
|
|
|
describe("logout route", () => {
|
|
it("redirects GET requests to the canonical app host root", async () => {
|
|
try {
|
|
vi.stubEnv("APP_BASE_DOMAIN", "example.test");
|
|
vi.stubEnv("WEB_APP_HOST", "app.example.test");
|
|
vi.stubEnv("ADMIN_APP_HOST", "admin.example.test");
|
|
vi.stubEnv("APP_PROTOCOL", "https");
|
|
|
|
await loader();
|
|
} catch (error) {
|
|
expect(error).toBeInstanceOf(Response);
|
|
expect((error as Response).headers.get("Location")).toBe("https://app.example.test/");
|
|
return;
|
|
} finally {
|
|
vi.unstubAllEnvs();
|
|
}
|
|
|
|
throw new Error("Expected redirect response");
|
|
});
|
|
});
|