import { afterEach, describe, expect, it, vi } from "vitest"; import { isMacAppcastPath, MAC_APPCAST_PATH } from "../../shared/macUpdates.ts"; import type { Env } from "../env.ts"; import worker from "../index.ts"; /** * The Mac app's update feed — answered by the SERVING MAC off its release * records, forwarded here. * * The failure this guards is silent by construction: a feed answered as HTML * (a relay error page, the site's SPA shell) makes Sparkle say "could not check * for updates" while the site looks healthy. So only an XML 200 from the * serving Mac is passed on, and everything else is plain text naming the path. */ function envServing(body: string | null, type = "application/xml; charset=utf-8"): Env { vi.stubGlobal("fetch", async () => body === null ? new Response("
an error page", { status: 200, headers: { "Content-Type": "text/html; charset=utf-8" }, }) : new Response(body, { status: 200, headers: { "Content-Type": type } }), ); return { PUBLIC_ORIGIN: "https://cottondb.com", MAC_FEED_ORIGIN: "https://example.relay.cottondb.com" } as unknown as Env; } afterEach(() => vi.unstubAllGlobals()); const feed = '