mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-23 19:08:22 -06:00
98e3f729bc
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
108 lines
2.9 KiB
TypeScript
108 lines
2.9 KiB
TypeScript
// Verifies plugin minimum host version compatibility checks.
|
|
import { describe, expect, it } from "vitest";
|
|
import { checkMinHostVersion, parseMinHostVersionRequirement } from "./min-host-version.js";
|
|
|
|
const MIN_HOST_REQUIREMENT = {
|
|
raw: ">=2026.3.22",
|
|
minimumLabel: "2026.3.22",
|
|
};
|
|
const BETA_MIN_HOST_REQUIREMENT = {
|
|
raw: ">=2026.5.1-beta.1",
|
|
minimumLabel: "2026.5.1-beta.1",
|
|
};
|
|
|
|
function expectValidHostCheck(currentVersion: string, minHostVersion?: string) {
|
|
expectHostCheckResult({
|
|
currentVersion,
|
|
minHostVersion,
|
|
expected: {
|
|
ok: true,
|
|
requirement: minHostVersion ? MIN_HOST_REQUIREMENT : null,
|
|
},
|
|
});
|
|
}
|
|
|
|
function expectHostCheckResult(params: {
|
|
currentVersion: string;
|
|
minHostVersion?: string | number;
|
|
expected: unknown;
|
|
}) {
|
|
expect(
|
|
checkMinHostVersion({
|
|
currentVersion: params.currentVersion,
|
|
minHostVersion: params.minHostVersion,
|
|
}),
|
|
).toEqual(params.expected);
|
|
}
|
|
|
|
describe("min-host-version", () => {
|
|
it("accepts empty metadata", () => {
|
|
expect(parseMinHostVersionRequirement(undefined)).toBeNull();
|
|
expectValidHostCheck("2026.3.22");
|
|
});
|
|
|
|
it("parses semver floors", () => {
|
|
expect(parseMinHostVersionRequirement(">=2026.3.22")).toEqual(MIN_HOST_REQUIREMENT);
|
|
expect(parseMinHostVersionRequirement(">=2026.5.1-beta.1")).toEqual(BETA_MIN_HOST_REQUIREMENT);
|
|
expect(parseMinHostVersionRequirement(">=2026.5.1+20260501")).toEqual({
|
|
raw: ">=2026.5.1+20260501",
|
|
minimumLabel: "2026.5.1+20260501",
|
|
});
|
|
});
|
|
|
|
it("can parse legacy bare semver floors for runtime upgrade compatibility", () => {
|
|
expect(parseMinHostVersionRequirement("2026.3.22", { allowLegacyBareSemver: true })).toEqual({
|
|
raw: "2026.3.22",
|
|
minimumLabel: "2026.3.22",
|
|
});
|
|
expect(
|
|
checkMinHostVersion({
|
|
currentVersion: "2026.3.22",
|
|
minHostVersion: "2026.3.22",
|
|
allowLegacyBareSemver: true,
|
|
}),
|
|
).toEqual({
|
|
ok: true,
|
|
requirement: {
|
|
raw: "2026.3.22",
|
|
minimumLabel: "2026.3.22",
|
|
},
|
|
});
|
|
});
|
|
|
|
it.each([
|
|
{
|
|
name: "reports unknown host versions distinctly",
|
|
currentVersion: "unknown",
|
|
expected: {
|
|
ok: false,
|
|
kind: "unknown_host_version",
|
|
requirement: MIN_HOST_REQUIREMENT,
|
|
},
|
|
},
|
|
{
|
|
name: "reports incompatible hosts",
|
|
currentVersion: "2026.3.21",
|
|
expected: {
|
|
ok: false,
|
|
kind: "incompatible",
|
|
currentVersion: "2026.3.21",
|
|
requirement: MIN_HOST_REQUIREMENT,
|
|
},
|
|
},
|
|
] as const)("$name", ({ currentVersion, expected }) => {
|
|
expectHostCheckResult({
|
|
currentVersion,
|
|
minHostVersion: ">=2026.3.22",
|
|
expected,
|
|
});
|
|
});
|
|
|
|
it.each(["2026.3.22", "2026.4.0"] as const)(
|
|
"accepts equal or newer hosts: %s",
|
|
(currentVersion) => {
|
|
expectValidHostCheck(currentVersion, ">=2026.3.22");
|
|
},
|
|
);
|
|
});
|