55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
compareReleaseToRuntime,
|
|
RELEASE_TOKEN_REGISTRY,
|
|
} from "../../src/contracts/release-tokens.js";
|
|
|
|
describe("release coherence", () => {
|
|
it("owns all eight release tokens and keeps builtAt diagnostic-only", () => {
|
|
expect(Object.keys(RELEASE_TOKEN_REGISTRY)).toHaveLength(8);
|
|
expect(RELEASE_TOKEN_REGISTRY.builtAt.compatibilityRole).toContain(
|
|
"never cache identity",
|
|
);
|
|
});
|
|
|
|
it("compares the runtime config to the release structurally", () => {
|
|
const release = {
|
|
buildId: "build-a",
|
|
configSchemaVersion: "1.0",
|
|
apiContractVersion: "1.0",
|
|
assetManifestHash: "assets-a",
|
|
releaseId: "release-a",
|
|
};
|
|
expect(
|
|
compareReleaseToRuntime(release, {
|
|
BUILD_ID: "build-a",
|
|
CONFIG_SCHEMA_VERSION: "1.2",
|
|
API_CONTRACT_VERSION: "1.1",
|
|
RELEASE_ID: "release-a",
|
|
}),
|
|
).toMatchObject({ compatible: true, mismatches: [] });
|
|
});
|
|
|
|
it("rejects HTML-only rollback against a newer runtime config", () => {
|
|
const oldRelease = {
|
|
buildId: "build-old",
|
|
configSchemaVersion: "1.0",
|
|
apiContractVersion: "1.0",
|
|
assetManifestHash: "assets-old",
|
|
releaseId: "release-old",
|
|
};
|
|
expect(
|
|
compareReleaseToRuntime(oldRelease, {
|
|
BUILD_ID: "build-new",
|
|
CONFIG_SCHEMA_VERSION: "2.0",
|
|
API_CONTRACT_VERSION: "2.0",
|
|
RELEASE_ID: "release-new",
|
|
}),
|
|
).toMatchObject({
|
|
compatible: false,
|
|
mismatches: ["buildId", "configSchemaVersion", "apiContractVersion"],
|
|
});
|
|
});
|
|
});
|