From 2622b05c0b7756bc4615e82e68bfc97b199fa177 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 18:58:53 +0000 Subject: [PATCH] test: tighten plugin install path warning coverage --- .../plugin-install-path-warnings.test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/infra/plugin-install-path-warnings.test.ts b/src/infra/plugin-install-path-warnings.test.ts index 6c24e5762..eef3348fb 100644 --- a/src/infra/plugin-install-path-warnings.test.ts +++ b/src/infra/plugin-install-path-warnings.test.ts @@ -8,6 +8,25 @@ import { } from "./plugin-install-path-warnings.js"; describe("plugin install path warnings", () => { + it("ignores non-path installs and blank path candidates", async () => { + expect( + await detectPluginInstallPathIssue({ + pluginId: "matrix", + install: null, + }), + ).toBeNull(); + expect( + await detectPluginInstallPathIssue({ + pluginId: "matrix", + install: { + source: "npm", + sourcePath: " ", + installPath: " ", + }, + }), + ).toBeNull(); + }); + it("detects stale custom plugin install paths", async () => { const issue = await detectPluginInstallPathIssue({ pluginId: "matrix", @@ -37,6 +56,28 @@ describe("plugin install path warnings", () => { ]); }); + it("uses the second candidate path when the first one is stale", async () => { + await withTempHome(async (home) => { + const pluginPath = path.join(home, "matrix-plugin"); + await fs.mkdir(pluginPath, { recursive: true }); + + const issue = await detectPluginInstallPathIssue({ + pluginId: "matrix", + install: { + source: "path", + sourcePath: "/tmp/openclaw-matrix-missing", + installPath: pluginPath, + }, + }); + + expect(issue).toEqual({ + kind: "custom-path", + pluginId: "matrix", + path: pluginPath, + }); + }); + }); + it("detects active custom plugin install paths", async () => { await withTempHome(async (home) => { const pluginPath = path.join(home, "matrix-plugin"); @@ -58,4 +99,25 @@ describe("plugin install path warnings", () => { }); }); }); + + it("applies custom command formatting in warning messages", () => { + expect( + formatPluginInstallPathIssue({ + issue: { + kind: "custom-path", + pluginId: "matrix", + path: "/tmp/matrix-plugin", + }, + pluginLabel: "Matrix", + defaultInstallCommand: "openclaw plugins install @openclaw/matrix", + repoInstallCommand: "openclaw plugins install ./extensions/matrix", + formatCommand: (command) => `<${command}>`, + }), + ).toEqual([ + "Matrix is installed from a custom path: /tmp/matrix-plugin", + "Main updates will not automatically replace that plugin with the repo's default Matrix package.", + 'Reinstall with "" when you want to return to the standard Matrix plugin.', + 'If you are intentionally running from a repo checkout, reinstall that checkout explicitly with "" after updates.', + ]); + }); });