@@ -2,6 +2,7 @@ import crypto from "node:crypto";
|
2 | 2 | import fs from "node:fs"; |
3 | 3 | import path from "node:path"; |
4 | 4 | import { afterEach, describe, expect, it, vi } from "vitest"; |
| 5 | +import type { OpenClawConfig } from "../config/types.openclaw.js"; |
5 | 6 | import { |
6 | 7 | clearCurrentPluginMetadataSnapshot, |
7 | 8 | setCurrentPluginMetadataSnapshot, |
@@ -428,6 +429,32 @@ describe("loadPluginRegistrySnapshotWithMetadata", () => {
|
428 | 429 | expect(result.diagnostics).toStrictEqual([]); |
429 | 430 | }); |
430 | 431 | |
| 432 | +it("refreshes a memoized derived snapshot when workspace plugins are installed", () => { |
| 433 | +const tempRoot = makeTempDir(); |
| 434 | +const workspaceDir = path.join(tempRoot, "workspace"); |
| 435 | +const env = { ...createHermeticEnv(tempRoot), OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }; |
| 436 | + |
| 437 | +const first = loadPluginRegistrySnapshotWithMetadata({ config: {}, env, workspaceDir }); |
| 438 | +expect(first.snapshot.plugins.map((plugin) => plugin.pluginId)).not.toContain("demo"); |
| 439 | + |
| 440 | +writePackagePlugin(path.join(workspaceDir, ".openclaw", "extensions", "demo")); |
| 441 | + |
| 442 | +const second = loadPluginRegistrySnapshotWithMetadata({ config: {}, env, workspaceDir }); |
| 443 | +expect(second.snapshot.plugins.map((plugin) => plugin.pluginId)).toContain("demo"); |
| 444 | +}); |
| 445 | + |
| 446 | +it("ignores malformed load paths while fingerprinting memoized snapshots", () => { |
| 447 | +const tempRoot = makeTempDir(); |
| 448 | +const env = { ...createHermeticEnv(tempRoot), OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }; |
| 449 | +const config = { |
| 450 | +plugins: { |
| 451 | +load: { paths: "not-an-array" }, |
| 452 | +}, |
| 453 | +} as unknown as OpenClawConfig; |
| 454 | + |
| 455 | +expect(() => loadPluginRegistrySnapshotWithMetadata({ config, env })).not.toThrow(); |
| 456 | +}); |
| 457 | + |
431 | 458 | it("keeps persisted package plugins when file hashes match", () => { |
432 | 459 | const tempRoot = makeTempDir(); |
433 | 460 | const rootDir = path.join(tempRoot, "workspace"); |
|