52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
loadReleaseManifest,
|
|
ReleaseManifestError,
|
|
} from "../../src/bootstrap/load-release-manifest.js";
|
|
|
|
const runtime = {
|
|
build: { buildId: "build-a" },
|
|
config: {
|
|
RELEASE_MANIFEST_URL: "/release-manifest.json",
|
|
BUILD_ID: "build-a",
|
|
RELEASE_ID: "release-a",
|
|
CONFIG_SCHEMA_VERSION: "1",
|
|
API_CONTRACT_VERSION: "1",
|
|
},
|
|
};
|
|
const manifest = {
|
|
schemaVersion: 1,
|
|
appVersion: "0.1.0",
|
|
buildId: "build-a",
|
|
commitSha: "abc123",
|
|
configSchemaVersion: "1",
|
|
apiContractVersion: "1",
|
|
assetManifestHash: "hash-a",
|
|
releaseId: "release-a",
|
|
builtAt: "2026-07-25T00:00:00Z",
|
|
};
|
|
|
|
describe("release manifest boot boundary", () => {
|
|
it("loads a coherent release tuple", async () => {
|
|
await expect(
|
|
loadReleaseManifest(
|
|
/** @type {Parameters<typeof loadReleaseManifest>[0]} */ (runtime),
|
|
{ fetcher: async () => new Response(JSON.stringify(manifest)) },
|
|
),
|
|
).resolves.toMatchObject({ releaseId: "release-a" });
|
|
});
|
|
|
|
it("fails before mount when release and runtime differ", async () => {
|
|
await expect(
|
|
loadReleaseManifest(
|
|
/** @type {Parameters<typeof loadReleaseManifest>[0]} */ (runtime),
|
|
{
|
|
fetcher: async () =>
|
|
new Response(JSON.stringify({ ...manifest, buildId: "build-b" })),
|
|
},
|
|
),
|
|
).rejects.toBeInstanceOf(ReleaseManifestError);
|
|
});
|
|
});
|