refactor: delete the compatibility config surface

This commit is contained in:
2026-08-20 01:11:35 +05:30
parent d19595c7ba
commit 5c8f3ede54
14 changed files with 46 additions and 261 deletions
-13
View File
@@ -7,7 +7,6 @@ import {
resolveProfile,
loadEnv,
renderStyles,
resolveCompatibility,
validateAppConfig,
explainAppConfig,
} from "../src/index.ts";
@@ -16,18 +15,6 @@ afterEach(() => {
delete process.env.WRNEXUS_PROFILE;
});
test("compatibility dates pin behavior and reject invalid or future policies", () => {
expect(
resolveCompatibility({ compatibilityDate: "2026-08-02", frameworkBehaviour: 1 }),
).toMatchObject({ needsUpgrade: false, future: false, effectiveBehaviour: 1 });
expect(validateAppConfig({ compatibilityDate: "2026-02-31" })).toContainEqual(
expect.objectContaining({ path: "compatibilityDate", severity: "error" }),
);
expect(validateAppConfig({ frameworkBehaviour: 2 })).toContainEqual(
expect.objectContaining({ severity: "error" }),
);
});
test("observability config requires bounded sampling and a valid OTLP endpoint", () => {
expect(validateAppConfig({ observability: { sampleRate: Number.NaN } })).toContainEqual(
expect.objectContaining({ path: "observability.sampleRate", severity: "error" }),
@@ -0,0 +1,28 @@
import { expect, test } from "bun:test";
import { validateAppConfig } from "../src/config.ts";
// A stale config must fail loudly. Silently ignoring a removed key leaves
// someone believing a flag still applies.
const REMOVED = [
{ key: "compatibilityDate", config: { compatibilityDate: "2026-08-02" } },
{ key: "frameworkBehaviour", config: { frameworkBehaviour: 1 } },
{ key: "functions", config: { functions: { legacyDefaultRuntime: "current" } } },
{ key: "compatibility", config: { compatibility: { legacyEmit: false } } },
];
for (const { key, config } of REMOVED) {
test(`a config still setting "${key}" is rejected with a message naming it`, () => {
const issues = validateAppConfig(config as never);
const match = issues.find((issue) => issue.path === key || issue.path.startsWith(`${key}.`));
expect(match).toBeDefined();
expect(match!.severity).toBe("error");
expect(match!.message.toLowerCase()).toContain("removed");
});
}
test("a config without those keys is accepted", () => {
const issues = validateAppConfig({} as never);
expect(issues.filter((issue) => issue.severity === "error")).toEqual([]);
});