From 592d93211f0d5dac9df413c55c3ca4c44338ba40 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 21:57:16 +0000 Subject: [PATCH] test: tighten shared manifest metadata coverage --- src/shared/entry-metadata.test.ts | 12 ++++++++++ src/shared/entry-status.test.ts | 29 ++++++++++++++++++++++++ src/shared/frontmatter.test.ts | 37 +++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) diff --git a/src/shared/entry-metadata.test.ts b/src/shared/entry-metadata.test.ts index cf94453a62e..ea52cd033e4 100644 --- a/src/shared/entry-metadata.test.ts +++ b/src/shared/entry-metadata.test.ts @@ -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({}); + }); }); diff --git a/src/shared/entry-status.test.ts b/src/shared/entry-status.test.ts index 88913913011..68cce75c982 100644 --- a/src/shared/entry-status.test.ts +++ b/src/shared/entry-status.test.ts @@ -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: [], + }); + }); }); diff --git a/src/shared/frontmatter.test.ts b/src/shared/frontmatter.test.ts index 94cd4acabef..69d48e05b57 100644 --- a/src/shared/frontmatter.test.ts +++ b/src/shared/frontmatter.test.ts @@ -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(