Files
EpicNext-Cms/src/lib/verify-runtime-metadata.test.ts
T
Simo c389c3893d
CI / check (push) Successful in 52s
CI / deploy (push) Successful in 2m10s
CI / publish-container (push) Failing after 1m18s
feat(cms): improve catalog, editorial recovery and operations
2026-09-09 19:36:15 +02:00

37 lines
1.2 KiB
TypeScript

import { afterEach, expect, it, vi } from "vitest";
import { verifyRuntimeMetadata } from "../../scripts/verify-runtime-metadata.mjs";
afterEach(() => vi.unstubAllGlobals());
it("verifies runtime names and domains without requesting DB-dependent login HTML", async () => {
const fetcher = vi.fn(async (url: string) => {
if (url.endsWith("/login"))
return new Response("Database unavailable", { status: 500 });
return url.endsWith("webmanifest")
? Response.json({ name: "Fixture alpha" })
: new Response("https://alpha.test/sitemap.xml");
});
vi.stubGlobal("fetch", fetcher);
await expect(
verifyRuntimeMetadata("https://alpha.test", "alpha"),
).resolves.toBeUndefined();
expect(fetcher.mock.calls.map((c) => c[0])).not.toContain(
"https://alpha.test/login",
);
});
it.each(["manifest", "domain", "http"])("rejects wrong %s", async (mode) => {
vi.stubGlobal(
"fetch",
vi.fn(async (url: string) =>
url.endsWith("webmanifest")
? Response.json(
{ name: mode === "manifest" ? "Build fixture" : "Fixture alpha" },
{ status: mode === "http" ? 500 : 200 },
)
: new Response("https://wrong.test"),
),
);
await expect(
verifyRuntimeMetadata("https://alpha.test", "alpha"),
).rejects.toThrow();
});