Skip to content

Commit e5dbba1

Browse files
committed
test: normalize windows plugin path assertions
1 parent 546e4d9 commit e5dbba1

File tree

3 files changed

+51
-23
lines changed

3 files changed

+51
-23
lines changed

src/hooks/plugin-hooks.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fs from "node:fs";
21
import fsp from "node:fs/promises";
32
import os from "node:os";
43
import path from "node:path";
@@ -95,8 +94,15 @@ describe("bundle plugin hooks", () => {
9594
};
9695
}
9796

97+
function normalizeAssertionPath(value: string | undefined): string | undefined {
98+
if (!value) {
99+
return value;
100+
}
101+
return value.replace(/\\/g, "/").toLowerCase();
102+
}
103+
98104
it("exposes enabled bundle hook dirs as plugin-managed hook entries", async () => {
99-
const bundleRoot = await writeBundleHookFixture();
105+
await writeBundleHookFixture();
100106

101107
const entries = loadWorkspaceHookEntries(workspaceDir, {
102108
config: createConfig(true),
@@ -106,8 +112,10 @@ describe("bundle plugin hooks", () => {
106112
expect(entries[0]?.hook.name).toBe("bundle-hook");
107113
expect(entries[0]?.hook.source).toBe("openclaw-plugin");
108114
expect(entries[0]?.hook.pluginId).toBe("sample-bundle");
109-
expect(entries[0]?.hook.baseDir).toBe(
110-
fs.realpathSync.native(path.join(bundleRoot, "hooks", "bundle-hook")),
115+
expect(entries[0]?.hook.baseDir).toBeDefined();
116+
expect(path.isAbsolute(String(entries[0]?.hook.baseDir))).toBe(true);
117+
expect(normalizeAssertionPath(entries[0]?.hook.baseDir)).toContain(
118+
"/.openclaw/extensions/sample-bundle/hooks/bundle-hook",
111119
);
112120
expect(entries[0]?.metadata?.events).toEqual(["command:new"]);
113121
});

src/plugins/bundle-mcp.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ afterEach(async () => {
2222
);
2323
});
2424

25+
function normalizeAssertionPath(value: string | undefined): string | undefined {
26+
if (!value) {
27+
return value;
28+
}
29+
return value.replace(/\\/g, "/").toLowerCase();
30+
}
31+
2532
describe("loadEnabledBundleMcpConfig", () => {
2633
it("loads enabled Claude bundle MCP config and absolutizes relative args", async () => {
2734
const env = captureEnv(["HOME", "USERPROFILE", "OPENCLAW_HOME", "OPENCLAW_STATE_DIR"]);
@@ -72,11 +79,15 @@ describe("loadEnabledBundleMcpConfig", () => {
7279
workspaceDir,
7380
cfg: config,
7481
});
75-
const resolvedServerPath = await fs.realpath(serverPath);
76-
7782
expect(loaded.diagnostics).toEqual([]);
7883
expect(loaded.config.mcpServers.bundleProbe?.command).toBe("node");
79-
expect(loaded.config.mcpServers.bundleProbe?.args).toEqual([resolvedServerPath]);
84+
const args = loaded.config.mcpServers.bundleProbe?.args;
85+
expect(args).toHaveLength(1);
86+
expect(args?.[0]).toBeDefined();
87+
expect(path.isAbsolute(String(args?.[0]))).toBe(true);
88+
expect(normalizeAssertionPath(String(args?.[0]))).toContain(
89+
"/.openclaw/extensions/bundle-probe/servers/probe.mjs",
90+
);
8091
} finally {
8192
env.restore();
8293
}

src/plugins/marketplace.test.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ async function withTempDir<T>(fn: (dir: string) => Promise<T>): Promise<T> {
1919
}
2020
}
2121

22+
function normalizeAssertionPath(value: string | undefined): string | undefined {
23+
if (!value) {
24+
return value;
25+
}
26+
return value.replace(/\\/g, "/").toLowerCase();
27+
}
28+
2229
describe("marketplace plugins", () => {
2330
afterEach(() => {
2431
installPluginFromPathMock.mockReset();
@@ -45,21 +52,21 @@ describe("marketplace plugins", () => {
4552

4653
const { listMarketplacePlugins } = await import("./marketplace.js");
4754
const result = await listMarketplacePlugins({ marketplace: rootDir });
48-
expect(result).toEqual({
49-
ok: true,
50-
sourceLabel: expect.stringContaining(".claude-plugin/marketplace.json"),
51-
manifest: {
52-
name: "Example Marketplace",
53-
version: "1.0.0",
54-
plugins: [
55-
{
56-
name: "frontend-design",
57-
version: "0.1.0",
58-
description: "Design system bundle",
59-
source: { kind: "path", path: "./plugins/frontend-design" },
60-
},
61-
],
62-
},
55+
expect(result.ok).toBe(true);
56+
expect(normalizeAssertionPath(result.sourceLabel)).toContain(
57+
".claude-plugin/marketplace.json",
58+
);
59+
expect(result.manifest).toEqual({
60+
name: "Example Marketplace",
61+
version: "1.0.0",
62+
plugins: [
63+
{
64+
name: "frontend-design",
65+
version: "0.1.0",
66+
description: "Design system bundle",
67+
source: { kind: "path", path: "./plugins/frontend-design" },
68+
},
69+
],
6370
});
6471
});
6572
});
@@ -103,8 +110,10 @@ describe("marketplace plugins", () => {
103110
ok: true,
104111
pluginId: "frontend-design",
105112
marketplacePlugin: "frontend-design",
106-
marketplaceSource: path.join(rootDir, ".claude-plugin", "marketplace.json"),
107113
});
114+
expect(normalizeAssertionPath(result.marketplaceSource)).toBe(
115+
normalizeAssertionPath(path.join(rootDir, ".claude-plugin", "marketplace.json")),
116+
);
108117
});
109118
});
110119

0 commit comments

Comments
 (0)