From fcfa2617a86180ffaeee5f7c32bbb7d871e19ed2 Mon Sep 17 00:00:00 2001 From: Shakker Date: Tue, 12 May 2026 10:10:00 +0100 Subject: [PATCH] test: check plugin payload failures --- .../plugin-payload-validation.test.ts | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/src/cli/update-cli/plugin-payload-validation.test.ts b/src/cli/update-cli/plugin-payload-validation.test.ts index 621f64c65d8..537cd8e067c 100644 --- a/src/cli/update-cli/plugin-payload-validation.test.ts +++ b/src/cli/update-cli/plugin-payload-validation.test.ts @@ -49,12 +49,12 @@ describe("runPluginPayloadSmokeCheck", () => { records: { brave: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toEqual([ + expect(result.failures).toStrictEqual([ { pluginId: "brave", installPath: dir, reason: "missing-package-dir", - detail: expect.stringContaining(dir), + detail: `Install dir is missing: ${dir}`, }, ]); }); @@ -66,12 +66,12 @@ describe("runPluginPayloadSmokeCheck", () => { records: { brave: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toEqual([ + expect(result.failures).toStrictEqual([ { pluginId: "brave", installPath: dir, reason: "missing-package-json", - detail: expect.stringContaining("package.json"), + detail: `package.json is missing under ${dir}`, }, ]); }); @@ -83,12 +83,14 @@ describe("runPluginPayloadSmokeCheck", () => { records: { brave: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toHaveLength(1); - expect(result.failures[0]).toMatchObject({ - pluginId: "brave", - reason: "missing-main-entry", - }); - expect(result.failures[0]?.detail).toContain("dist/index.js"); + expect(result.failures).toStrictEqual([ + { + pluginId: "brave", + installPath: dir, + reason: "missing-main-entry", + detail: `Plugin main entry "dist/index.js" not found at ${path.join(dir, "dist/index.js")}`, + }, + ]); }); it("accepts a manifest with no main field (OpenClaw plugins commonly use `exports` or `openclaw.extensions`)", async () => { @@ -153,12 +155,15 @@ describe("runPluginPayloadSmokeCheck", () => { records: { brave: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toHaveLength(1); - expect(result.failures[0]).toMatchObject({ - pluginId: "brave", - reason: "missing-extension-entry", - }); - expect(result.failures[0]?.detail).toContain("./dist/index.js"); + expect(result.failures).toStrictEqual([ + { + pluginId: "brave", + installPath: dir, + reason: "missing-extension-entry", + detail: + "Plugin extension entry validation failed: extension entry not found: ./dist/index.js", + }, + ]); }); it("reports a failure when `main` resolves to a directory rather than a file", async () => { @@ -174,8 +179,14 @@ describe("runPluginPayloadSmokeCheck", () => { records: { x: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toHaveLength(1); - expect(result.failures[0]).toMatchObject({ pluginId: "x", reason: "missing-main-entry" }); + expect(result.failures).toStrictEqual([ + { + pluginId: "x", + installPath: dir, + reason: "missing-main-entry", + detail: `Plugin main entry "lib" not found at ${path.join(dir, "lib")}`, + }, + ]); }); it("reports a failure when `main` is a symlink whose target is missing", async () => { @@ -195,11 +206,14 @@ describe("runPluginPayloadSmokeCheck", () => { records: { x: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toHaveLength(1); - expect(result.failures[0]).toMatchObject({ - pluginId: "x", - reason: "missing-main-entry", - }); + expect(result.failures).toStrictEqual([ + { + pluginId: "x", + installPath: dir, + reason: "missing-main-entry", + detail: `Plugin main entry "dist/entry.js" not found at ${path.join(dir, "dist", "entry.js")}`, + }, + ]); }); it("reports a failure when package.json cannot be parsed", async () => { @@ -210,11 +224,15 @@ describe("runPluginPayloadSmokeCheck", () => { records: { broken: { source: "npm", installPath: dir } }, env: {}, }); - expect(result.failures).toHaveLength(1); - expect(result.failures[0]).toMatchObject({ - pluginId: "broken", - reason: "invalid-package-json", - }); + expect(result.failures).toStrictEqual([ + { + pluginId: "broken", + installPath: dir, + reason: "invalid-package-json", + detail: + "Could not parse package.json: Unexpected token 'o', \"not-json\" is not valid JSON", + }, + ]); }); it("reports a failure when an install record is missing installPath", async () => {