File
Blob: tests/worker/api/config.test.ts
| 1 | import { beforeEach, describe, expect, it } from "vitest"; |
| 2 | import { apiRequest, resetWorkerState } from "./helpers"; |
| 3 | |
| 4 | describe("worker api /api/public/config", () => { |
| 5 | beforeEach(async () => { |
| 6 | await resetWorkerState(); |
| 7 | }); |
| 8 | |
| 9 | it("returns the turnstile site key when configured", async () => { |
| 10 | const response = await apiRequest("/api/public/config"); |
| 11 | |
| 12 | expect(response.status).toBe(200); |
| 13 | await expect(response.json()).resolves.toEqual({ |
| 14 | turnstileSiteKey: "1x00000000000000000000AA", |
| 15 | }); |
| 16 | }); |
| 17 | |
| 18 | it("returns 503 when the turnstile site key is missing", async () => { |
| 19 | const response = await apiRequest("/api/public/config", { |
| 20 | envOverrides: { |
| 21 | TURNSTILE_SITE_KEY: "", |
| 22 | }, |
| 23 | }); |
| 24 | |
| 25 | expect(response.status).toBe(503); |
| 26 | await expect(response.json()).resolves.toEqual({ |
| 27 | error: "Human verification is temporarily unavailable.", |
| 28 | }); |
| 29 | }); |
| 30 | }); |