Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(web): add auth options unit tests
Richie McIlroy0372ffe85084
diff --git a/apps/web/__tests__/unit/auth-options.test.ts b/apps/web/__tests__/unit/auth-options.test.tsnew file mode 100644index 000000000..3dbc4fe8c--- /dev/null+++ b/apps/web/__tests__/unit/auth-options.test.ts@@ -0,0 +1,42 @@+import { authOptions } from "@cap/database/auth/auth-options";+import { beforeEach, describe, expect, it, vi } from "vitest";++const env = vi.hoisted(() => ({+ APPLE_CLIENT_ID: "so.cap.auth",+ APPLE_CLIENT_SECRET: "apple-secret",+ CAP_ALLOWED_SIGNUP_DOMAINS: undefined,+ GOOGLE_CLIENT_ID: "google-client",+ GOOGLE_CLIENT_SECRET: "google-secret",+ NEXTAUTH_SECRET: "next-auth-secret",+ RESEND_API_KEY: undefined,+ WORKOS_API_KEY: "workos-secret",+ WORKOS_CLIENT_ID: "workos-client",+}));++vi.mock("@cap/env", () => ({+ serverEnv: () => env,+}));++describe("authOptions", () => {+ beforeEach(() => {+ env.APPLE_CLIENT_ID = "so.cap.auth";+ env.APPLE_CLIENT_SECRET = "apple-secret";+ });++ it("enables Apple when both OAuth credentials are configured", () => {+ const options = authOptions();+ const providers = options.providers.map((provider) => provider.id);++ expect(providers).toContain("apple");+ expect(options.cookies?.callbackUrl?.options.sameSite).toBe("none");+ expect(options.cookies?.pkceCodeVerifier?.options.sameSite).toBe("none");+ });++ it("does not expose a partially configured Apple provider", () => {+ env.APPLE_CLIENT_SECRET = "";++ const providers = authOptions().providers.map((provider) => provider.id);++ expect(providers).not.toContain("apple");+ });+});