test: tighten shared manifest metadata coverage

This commit is contained in:
Peter Steinberger 2026-03-13 21:57:16 +00:00
parent 25e900f64a
commit 592d93211f
3 changed files with 78 additions and 0 deletions

View File

@ -46,4 +46,16 @@ describe("shared/entry-metadata", () => {
homepage: "https://openclaw.ai/install",
});
});
it("does not fall back once frontmatter homepage aliases are present but blank", () => {
expect(
resolveEmojiAndHomepage({
frontmatter: {
homepage: " ",
website: "https://docs.openclaw.ai",
url: "https://openclaw.ai/install",
},
}),
).toEqual({});
});
});

View File

@ -129,4 +129,33 @@ describe("shared/entry-status", () => {
configChecks: [],
});
});
it("returns empty requirements when metadata and frontmatter are missing", () => {
const result = evaluateEntryMetadataRequirements({
always: false,
hasLocalBin: () => false,
localPlatform: "linux",
isEnvSatisfied: () => false,
isConfigSatisfied: () => false,
});
expect(result).toEqual({
required: {
bins: [],
anyBins: [],
env: [],
config: [],
os: [],
},
missing: {
bins: [],
anyBins: [],
env: [],
config: [],
os: [],
},
requirementsSatisfied: true,
configChecks: [],
});
});
});

View File

@ -27,6 +27,7 @@ describe("shared/frontmatter", () => {
expect(parseFrontmatterBool("true", false)).toBe(true);
expect(parseFrontmatterBool("false", true)).toBe(false);
expect(parseFrontmatterBool(undefined, true)).toBe(true);
expect(parseFrontmatterBool("maybe", false)).toBe(false);
});
test("resolveOpenClawManifestBlock reads current manifest keys and custom metadata fields", () => {
@ -53,6 +54,8 @@ describe("shared/frontmatter", () => {
expect(
resolveOpenClawManifestBlock({ frontmatter: { metadata: "not-json5" } }),
).toBeUndefined();
expect(resolveOpenClawManifestBlock({ frontmatter: { metadata: "123" } })).toBeUndefined();
expect(resolveOpenClawManifestBlock({ frontmatter: { metadata: "[]" } })).toBeUndefined();
expect(
resolveOpenClawManifestBlock({ frontmatter: { metadata: "{ nope: { a: 1 } }" } }),
).toBeUndefined();
@ -120,6 +123,40 @@ describe("shared/frontmatter", () => {
});
});
it("prefers explicit kind, ignores invalid common fields, and leaves missing ones untouched", () => {
const parsed = parseOpenClawManifestInstallBase(
{
kind: " npm ",
type: "brew",
id: 42,
label: null,
bins: [" ", ""],
},
["brew", "npm"],
);
expect(parsed).toEqual({
raw: {
kind: " npm ",
type: "brew",
id: 42,
label: null,
bins: [" ", ""],
},
kind: "npm",
});
expect(
applyOpenClawManifestInstallCommonFields(
{ id: "keep", label: "Keep", bins: ["bun"] },
parsed!,
),
).toEqual({
id: "keep",
label: "Keep",
bins: ["bun"],
});
});
it("maps install entries through the parser and filters rejected specs", () => {
expect(
resolveOpenClawManifestInstall(