mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
test(plugins): reuse tracked temp helpers in fixture tests
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||
import { inspectBundleLspRuntimeSupport } from "./bundle-lsp.js";
|
||||
import { loadBundleManifest } from "./bundle-manifest.js";
|
||||
import { inspectBundleMcpRuntimeSupport } from "./bundle-mcp.js";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
/**
|
||||
* Integration test: builds a Claude Code bundle plugin fixture on disk
|
||||
@@ -13,6 +13,7 @@ import { inspectBundleMcpRuntimeSupport } from "./bundle-mcp.js";
|
||||
*/
|
||||
describe("Claude bundle plugin inspect integration", () => {
|
||||
let rootDir: string;
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
function writeFixtureText(relativePath: string, value: string) {
|
||||
fs.mkdirSync(path.dirname(path.join(rootDir, relativePath)), { recursive: true });
|
||||
@@ -151,12 +152,12 @@ describe("Claude bundle plugin inspect integration", () => {
|
||||
}
|
||||
|
||||
beforeAll(() => {
|
||||
rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-claude-bundle-"));
|
||||
rootDir = makeTrackedTempDir("openclaw-claude-bundle", tempDirs);
|
||||
setupClaudeInspectFixture();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
fs.rmSync(rootDir, { recursive: true, force: true });
|
||||
cleanupTrackedTempDirs(tempDirs);
|
||||
});
|
||||
|
||||
it("loads the full Claude bundle manifest with all capabilities", () => {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type {
|
||||
ConversationRef,
|
||||
SessionBindingAdapter,
|
||||
@@ -9,8 +8,10 @@ import type {
|
||||
} from "../infra/outbound/session-binding-service.js";
|
||||
import { createEmptyPluginRegistry } from "./registry-empty.js";
|
||||
import type { PluginRegistry } from "./registry.js";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-binding-"));
|
||||
const tempDirs: string[] = [];
|
||||
const tempRoot = makeTrackedTempDir("openclaw-plugin-binding", tempDirs);
|
||||
const approvalsPath = path.join(tempRoot, "plugin-binding-approvals.json");
|
||||
|
||||
const sessionBindingState = vi.hoisted(() => {
|
||||
@@ -157,6 +158,10 @@ function createAdapter(channel: string, accountId: string): SessionBindingAdapte
|
||||
};
|
||||
}
|
||||
|
||||
afterAll(() => {
|
||||
cleanupTrackedTempDirs(tempDirs);
|
||||
});
|
||||
|
||||
function createDiscordCodexBindRequest(
|
||||
conversationId: string,
|
||||
summary: string,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { stageBundledPluginRuntime } from "../../scripts/stage-bundled-plugin-runtime.mjs";
|
||||
import { bundledDistPluginFile } from "../../test/helpers/bundled-plugin-paths.js";
|
||||
import { loadPluginBoundaryModuleWithJiti } from "./runtime/runtime-plugin-boundary.js";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
type LightModule = {
|
||||
getActiveWebListener: (accountId?: string | null) => unknown;
|
||||
@@ -25,8 +25,7 @@ function writeRuntimeFixtureText(rootDir: string, relativePath: string, value: s
|
||||
}
|
||||
|
||||
function createBundledWhatsAppRuntimeFixture() {
|
||||
const rootDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-whatsapp-boundary-"));
|
||||
tempDirs.push(rootDir);
|
||||
const rootDir = makeTrackedTempDir("openclaw-whatsapp-boundary", tempDirs);
|
||||
for (const [relativePath, value] of Object.entries({
|
||||
"package.json": JSON.stringify(
|
||||
{
|
||||
@@ -107,9 +106,7 @@ function expectSharedWhatsAppListenerState(runtimePluginDir: string, accountId:
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0, tempDirs.length)) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
cleanupTrackedTempDirs(tempDirs);
|
||||
});
|
||||
|
||||
describe("runtime plugin boundary whatsapp seam", () => {
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "../test-helpers/fs-fixtures.js";
|
||||
import { loadSiblingRuntimeModuleSync } from "./local-runtime-module.js";
|
||||
|
||||
const tempDirs = new Set<string>();
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
function createTempDir(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-local-runtime-module-"));
|
||||
tempDirs.add(dir);
|
||||
return dir;
|
||||
return makeTrackedTempDir("openclaw-local-runtime-module", tempDirs);
|
||||
}
|
||||
|
||||
function writeFile(filePath: string, content: string): void {
|
||||
@@ -19,10 +17,7 @@ function writeFile(filePath: string, content: string): void {
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
tempDirs.clear();
|
||||
cleanupTrackedTempDirs(tempDirs);
|
||||
});
|
||||
|
||||
describe("loadSiblingRuntimeModuleSync", () => {
|
||||
|
||||
Reference in New Issue
Block a user