2026-05-15 11:17:15 -07:00
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
|
import { isOnboardingExempt } from "../../root";
|
|
|
|
|
|
|
|
|
|
describe("isOnboardingExempt", () => {
|
|
|
|
|
it("exempts /onboarding exactly", () => {
|
|
|
|
|
expect(isOnboardingExempt("/onboarding")).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("exempts /onboarding sub-paths", () => {
|
|
|
|
|
expect(isOnboardingExempt("/onboarding/step2")).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("exempts /api/ prefix paths", () => {
|
|
|
|
|
expect(isOnboardingExempt("/api/auth/callback")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/api/draft/start")).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not exempt paths that merely start with /api without trailing slash", () => {
|
|
|
|
|
// /api/ has a trailing slash so startsWith("/api/") is used — /apiary would not match
|
|
|
|
|
expect(isOnboardingExempt("/apiary")).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("exempts auth pages exactly", () => {
|
|
|
|
|
expect(isOnboardingExempt("/login")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/register")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/check-email")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/forgot-password")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/reset-password")).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it("does not exempt a path that merely starts with an exempt path without slash", () => {
|
|
|
|
|
expect(isOnboardingExempt("/registered-user")).toBe(false);
|
|
|
|
|
expect(isOnboardingExempt("/loginpage")).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-15 12:07:51 -07:00
|
|
|
it("exempts /admin and all sub-paths", () => {
|
|
|
|
|
expect(isOnboardingExempt("/admin")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/admin/users")).toBe(true);
|
|
|
|
|
expect(isOnboardingExempt("/admin/sports-seasons/123")).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
2026-05-15 11:17:15 -07:00
|
|
|
it("does not exempt normal app routes", () => {
|
|
|
|
|
expect(isOnboardingExempt("/")).toBe(false);
|
|
|
|
|
expect(isOnboardingExempt("/leagues/abc")).toBe(false);
|
|
|
|
|
expect(isOnboardingExempt("/settings")).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
});
|