惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Google DeepMind News
Google DeepMind News
博客园 - 【当耐特】
量子位
博客园 - 司徒正美
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Jina AI
Jina AI
J
Java Code Geeks
腾讯CDC
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
I
InfoQ
D
Docker
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
宝玉的分享
宝玉的分享
G
Google Developers Blog
GbyAI
GbyAI
Y
Y Combinator Blog
有赞技术团队
有赞技术团队
H
Help Net Security

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(plugin-sdk): add unit tests for linkOpenClawPeerDepe...
anishesg · 2026-04-24 · via Recent Commits to openclaw:main

@@ -9,6 +9,7 @@ import { expectInstallUsesIgnoreScripts } from "../test-utils/npm-spec-install-t

99

import { initializeGlobalHookRunner, resetGlobalHookRunner } from "./hook-runner-global.js";

1010

import { createMockPluginRegistry } from "./hooks.test-helpers.js";

1111

import * as installSecurityScan from "./install-security-scan.js";

12+

import { resolveOpenClawPackageRootSync } from "../infra/openclaw-root.js";

1213

import {

1314

installPluginFromArchive,

1415

installPluginFromDir,

@@ -21,6 +22,10 @@ vi.mock("../process/exec.js", () => ({

2122

runCommandWithTimeout: vi.fn(),

2223

}));

232425+

vi.mock("../infra/openclaw-root.js", () => ({

26+

resolveOpenClawPackageRootSync: vi.fn(),

27+

}));

28+2429

const resolveCompatibilityHostVersionMock = vi.fn();

25302631

vi.mock("./install.runtime.js", async () => {

@@ -2350,3 +2355,96 @@ describe("installPluginFromDir", () => {

23502355

});

23512356

});

23522357

});

2358+2359+

describe("linkOpenClawPeerDependencies (via installPluginFromDir)", () => {

2360+

const resolveRootMock = vi.mocked(resolveOpenClawPackageRootSync);

2361+2362+

function writePluginWithPeerDeps(

2363+

pluginDir: string,

2364+

peerDependencies: Record<string, string>,

2365+

): void {

2366+

fs.mkdirSync(pluginDir, { recursive: true });

2367+

fs.writeFileSync(

2368+

path.join(pluginDir, "package.json"),

2369+

JSON.stringify({

2370+

name: "peer-dep-plugin",

2371+

version: "1.0.0",

2372+

openclaw: { extensions: ["index.js"] },

2373+

peerDependencies,

2374+

}),

2375+

"utf-8",

2376+

);

2377+

fs.writeFileSync(path.join(pluginDir, "index.js"), "export {};\n", "utf-8");

2378+

}

2379+2380+

it("creates a node_modules/openclaw symlink when peerDependencies declares openclaw", async () => {

2381+

const { pluginDir, extensionsDir } = setupPluginInstallDirs();

2382+

const fakeHostRoot = suiteTempRootTracker.makeTempDir();

2383+

resolveRootMock.mockReturnValue(fakeHostRoot);

2384+2385+

writePluginWithPeerDeps(pluginDir, { openclaw: "*" });

2386+2387+

const { result } = await installFromDirWithWarnings({ pluginDir, extensionsDir });

2388+2389+

expect(result.ok).toBe(true);

2390+

if (!result.ok) return;

2391+2392+

const symlinkPath = path.join(result.targetDir, "node_modules", "openclaw");

2393+

const stat = fs.lstatSync(symlinkPath);

2394+

expect(stat.isSymbolicLink()).toBe(true);

2395+

expect(fs.realpathSync(symlinkPath)).toBe(fs.realpathSync(fakeHostRoot));

2396+

});

2397+2398+

it("does not create a symlink when peerDependencies is empty", async () => {

2399+

const { pluginDir, extensionsDir } = setupPluginInstallDirs();

2400+

resolveRootMock.mockReturnValue(suiteTempRootTracker.makeTempDir());

2401+2402+

writePluginWithPeerDeps(pluginDir, {});

2403+2404+

const { result } = await installFromDirWithWarnings({ pluginDir, extensionsDir });

2405+2406+

expect(result.ok).toBe(true);

2407+

if (!result.ok) return;

2408+2409+

const nodeModulesDir = path.join(result.targetDir, "node_modules");

2410+

const symlinkPath = path.join(nodeModulesDir, "openclaw");

2411+

expect(fs.existsSync(symlinkPath)).toBe(false);

2412+

});

2413+2414+

it("is idempotent — re-installing replaces an existing symlink without error", async () => {

2415+

const { pluginDir, extensionsDir } = setupPluginInstallDirs();

2416+

const fakeHostRoot = suiteTempRootTracker.makeTempDir();

2417+

resolveRootMock.mockReturnValue(fakeHostRoot);

2418+2419+

writePluginWithPeerDeps(pluginDir, { openclaw: "*" });

2420+2421+

// First install

2422+

const { result: first } = await installFromDirWithWarnings({ pluginDir, extensionsDir });

2423+

expect(first.ok).toBe(true);

2424+2425+

// Second install (update mode) — should replace symlink, not throw

2426+

const { result: second, warnings } = await installFromDirWithWarnings({

2427+

pluginDir,

2428+

extensionsDir,

2429+

mode: "update",

2430+

});

2431+

expect(second.ok).toBe(true);

2432+

expect(warnings).toHaveLength(0);

2433+2434+

if (!second.ok) return;

2435+

const symlinkPath = path.join(second.targetDir, "node_modules", "openclaw");

2436+

expect(fs.lstatSync(symlinkPath).isSymbolicLink()).toBe(true);

2437+

});

2438+2439+

it("warns and skips when resolveOpenClawPackageRootSync returns null", async () => {

2440+

const { pluginDir, extensionsDir } = setupPluginInstallDirs();

2441+

resolveRootMock.mockReturnValue(null);

2442+2443+

writePluginWithPeerDeps(pluginDir, { openclaw: "*" });

2444+2445+

const { result, warnings } = await installFromDirWithWarnings({ pluginDir, extensionsDir });

2446+2447+

expect(result.ok).toBe(true);

2448+

expect(warnings.some((w) => w.includes("Could not locate openclaw package root"))).toBe(true);

2449+

});

2450+

});