From da4ac533333704ad01eed9674d23ba45ad38f835 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 2 May 2026 17:19:58 +0100 Subject: [PATCH] test(plugins): trust synthetic public artifact roots --- src/plugins/public-surface-loader.test.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/public-surface-loader.test.ts b/src/plugins/public-surface-loader.test.ts index 5f3d811455e..ecebd1aeac0 100644 --- a/src/plugins/public-surface-loader.test.ts +++ b/src/plugins/public-surface-loader.test.ts @@ -6,6 +6,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; const tempDirs: string[] = []; const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR; +const originalTrustBundledPluginsDir = process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR; function createTempDir(): string { const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-public-surface-loader-")); @@ -27,6 +28,11 @@ afterEach(() => { } else { process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir; } + if (originalTrustBundledPluginsDir === undefined) { + delete process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR; + } else { + process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = originalTrustBundledPluginsDir; + } }); describe("bundled plugin public surface loader", () => { @@ -128,7 +134,9 @@ describe("bundled plugin public surface loader", () => { >(import.meta.url, "./public-surface-loader.js?scope=bundled-native-public-artifacts"); const tempRoot = createTempDir(); const bundledPluginsDir = path.join(tempRoot, "dist"); + fs.mkdirSync(bundledPluginsDir, { recursive: true }); process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir; + process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = "1"; const firstPath = path.join(bundledPluginsDir, "demo-a", "api.js"); const secondPath = path.join(bundledPluginsDir, "demo-b", "api.js"); @@ -162,12 +170,14 @@ describe("bundled plugin public surface loader", () => { })); vi.resetModules(); + const tempRoot = createTempDir(); + const bundledPluginsDir = path.join(tempRoot, "dist"); + fs.mkdirSync(bundledPluginsDir, { recursive: true }); + process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir; + process.env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR = "1"; const publicSurfaceLoader = await importFreshModule< typeof import("./public-surface-loader.js") >(import.meta.url, "./public-surface-loader.js?scope=missing-location-retry"); - const tempRoot = createTempDir(); - const bundledPluginsDir = path.join(tempRoot, "dist"); - process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = bundledPluginsDir; expect( publicSurfaceLoader.resolveBundledPluginPublicArtifactPath({