Skip to content

Commit 061a370

Browse files
committed
test(plugin-sdk): isolate runtime facade tests
1 parent 9e5ac0c commit 061a370

4 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/plugin-sdk/anthropic-vertex-auth-presence.preflight.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Preflight tests for Anthropic Vertex auth presence helpers.
33
*/
4-
import { afterEach, describe, expect, it, vi } from "vitest";
4+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
55

66
const { existsSyncMock, readFileSyncMock } = vi.hoisted(() => ({
77
existsSyncMock: vi.fn(),
@@ -28,17 +28,20 @@ vi.mock("node:fs", async () => {
2828
};
2929
});
3030

31-
import { hasAnthropicVertexAvailableAuth } from "./anthropic-vertex-auth-presence.js";
32-
3331
describe("hasAnthropicVertexAvailableAuth ADC preflight", () => {
32+
beforeEach(() => {
33+
vi.resetModules();
34+
});
35+
3436
afterEach(() => {
3537
existsSyncMock.mockClear();
3638
readFileSyncMock.mockClear();
3739
});
3840

39-
it("reads explicit ADC credentials without an existsSync preflight", () => {
41+
it("reads explicit ADC credentials without an existsSync preflight", async () => {
4042
existsSyncMock.mockClear();
4143
readFileSyncMock.mockClear();
44+
const { hasAnthropicVertexAvailableAuth } = await import("./anthropic-vertex-auth-presence.js");
4245

4346
expect(
4447
hasAnthropicVertexAvailableAuth({

src/plugin-sdk/browser-bridge.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ vi.mock("./facade-runtime.js", () => ({
1010

1111
describe("browser bridge facade", () => {
1212
beforeEach(() => {
13+
vi.resetModules();
1314
loadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
1415
});
1516

src/plugin-sdk/qa-runner-runtime.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ function firstPublicSurfaceCall(): PublicSurfaceCall | undefined {
5050
describe("plugin-sdk qa-runner-runtime", () => {
5151
const tempDirs: string[] = [];
5252
const originalPrivateQaCli = process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
53+
const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
5354

5455
beforeEach(() => {
56+
vi.resetModules();
5557
loadPluginManifestRegistry.mockReset().mockReturnValue({
5658
plugins: [],
5759
diagnostics: [],
@@ -60,11 +62,17 @@ describe("plugin-sdk qa-runner-runtime", () => {
6062
tryLoadActivatedBundledPluginPublicSurfaceModuleSync.mockReset();
6163
resolveOpenClawPackageRootSync.mockReset().mockReturnValue(null);
6264
delete process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
65+
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
6366
});
6467

6568
afterEach(() => {
6669
cleanupTempDirs(tempDirs);
6770
restorePrivateQaCliEnv(originalPrivateQaCli);
71+
if (originalBundledPluginsDir === undefined) {
72+
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
73+
} else {
74+
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;
75+
}
6876
});
6977

7078
it("stays cold until runner discovery is requested", async () => {

src/plugin-sdk/qa-runtime.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,24 @@ vi.mock("../infra/openclaw-root.js", () => ({
2525
describe("plugin-sdk qa-runtime", () => {
2626
const tempDirs: string[] = [];
2727
const originalPrivateQaCli = process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
28+
const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
2829

2930
beforeEach(() => {
31+
vi.resetModules();
3032
loadBundledPluginPublicSurfaceModuleSync.mockReset();
3133
resolveOpenClawPackageRootSync.mockReset().mockReturnValue(null);
3234
delete process.env.OPENCLAW_ENABLE_PRIVATE_QA_CLI;
35+
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
3336
});
3437

3538
afterEach(() => {
3639
cleanupTempDirs(tempDirs);
3740
restorePrivateQaCliEnv(originalPrivateQaCli);
41+
if (originalBundledPluginsDir === undefined) {
42+
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
43+
} else {
44+
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;
45+
}
3846
});
3947

4048
async function occupyLoopbackPort(): Promise<{ close: () => Promise<void>; port: number }> {

0 commit comments

Comments
 (0)