import { env } from "cloudflare:workers"; import { afterEach, describe, expect, it } from "vitest"; import { createPublicClientConfigScript, renderSpaShell, resetShellHintsCacheForTests } from "@/worker/lib/spa-shell"; afterEach(() => { resetShellHintsCacheForTests(); }); describe("createPublicClientConfigScript", () => { it("escapes unsafe html sequences inside the injected JSON", () => { const script = createPublicClientConfigScript( { SENTRY_DSN: "https://public@example.ingest.sentry.io/1?x=", } as Pick, "nonce-test", ); expect(script).toContain("window.__BLAND_PUBLIC_CONFIG__="); expect(script).toContain('window.__BLAND_CSP_NONCE__="nonce-test";'); expect(script).toContain("\\u003c/script>\\u003cscript>alert(1)\\u003c/script>"); expect(script).not.toContain("