mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:40:43 +00:00
test(plugins): trust synthetic public artifact roots
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user