Skip to content

Commit 1ef85c7

Browse files
authored
test: make suites safe without isolation (#78834)
* test: make suites safe without isolation * fix: narrow auth profile credential types * test: inject channel module loader factory locally
1 parent 9ffe290 commit 1ef85c7

182 files changed

Lines changed: 1503 additions & 836 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ Docs: https://docs.openclaw.ai
159159
- CLI/infer: normalize HEIC/HEIF image files to JPEG before model-run requests, avoiding providers that reject Apple image container formats. Fixes #50081.
160160
- OpenRouter: keep the default `openrouter/auto` model ref canonical while preventing TUI and Control UI catalog pickers from displaying or submitting `openrouter/openrouter/auto`. Fixes #62655.
161161
- Status/Claude CLI: show `oauth (claude-cli)` for working Claude CLI OAuth runtime sessions instead of `unknown` when no local auth profile exists. Fixes #78632. Thanks @gorkem2020.
162+
- Memory search: preserve keyword-only hybrid FTS matches when vector scoring is unavailable or below the configured minimum score, so exact lexical hits are not dropped by weighted min-score filtering.
162163
- Exec approvals/node: let trusted backend node invokes complete no-device Control UI approvals after the original request connection changes, while keeping node, command, cwd, env, and allow-once replay bindings enforced. Fixes #78569. Thanks @naturedogdog.
163164
- Agents/subagents: keep background completion delivery on the requester-agent handoff/queue-retry path instead of raw-sending child results directly, and strip child-result wrapper or OpenClaw runtime-context scaffolding from queued outbound retries. Fixes #78531. Thanks @EthanSK.
164165
- CLI/completion: guard the shell-profile source line written by `openclaw completion --install` with a file existence check (`[ -f ... ] && source ...` for bash/zsh, `test -f ...; and source ...` for fish) so uninstalling OpenClaw no longer makes new login shells error on a missing completion cache. (#78659) Thanks @sjf.

extensions/acpx/src/service.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ import { getAcpRuntimeBackend } from "../runtime-api.js";
9292
import { createAcpxRuntimeService } from "./service.js";
9393

9494
const tempDirs: string[] = [];
95+
const previousEnv = {
96+
OPENCLAW_ACPX_RUNTIME_STARTUP_PROBE: process.env.OPENCLAW_ACPX_RUNTIME_STARTUP_PROBE,
97+
OPENCLAW_SKIP_ACPX_RUNTIME: process.env.OPENCLAW_SKIP_ACPX_RUNTIME,
98+
OPENCLAW_SKIP_ACPX_RUNTIME_PROBE: process.env.OPENCLAW_SKIP_ACPX_RUNTIME_PROBE,
99+
};
100+
101+
function restoreEnv(name: keyof typeof previousEnv): void {
102+
const value = previousEnv[name];
103+
if (value === undefined) {
104+
delete process.env[name];
105+
} else {
106+
process.env[name] = value;
107+
}
108+
}
95109

96110
async function makeTempDir(): Promise<string> {
97111
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-acpx-service-"));
@@ -107,9 +121,9 @@ afterEach(async () => {
107121
acpxRuntimeConstructorMock.mockClear();
108122
createAgentRegistryMock.mockClear();
109123
createFileSessionStoreMock.mockClear();
110-
delete process.env.OPENCLAW_ACPX_RUNTIME_STARTUP_PROBE;
111-
delete process.env.OPENCLAW_SKIP_ACPX_RUNTIME;
112-
delete process.env.OPENCLAW_SKIP_ACPX_RUNTIME_PROBE;
124+
restoreEnv("OPENCLAW_ACPX_RUNTIME_STARTUP_PROBE");
125+
restoreEnv("OPENCLAW_SKIP_ACPX_RUNTIME");
126+
restoreEnv("OPENCLAW_SKIP_ACPX_RUNTIME_PROBE");
113127
for (const dir of tempDirs.splice(0)) {
114128
await fs.rm(dir, { recursive: true, force: true });
115129
}

extensions/active-memory/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ describe("active-memory plugin", () => {
213213
afterEach(async () => {
214214
vi.useRealTimers();
215215
vi.restoreAllMocks();
216+
__testing.resetActiveRecallCacheForTests();
216217
if (stateDir) {
217218
await fs.rm(stateDir, { recursive: true, force: true });
218219
stateDir = "";

extensions/amazon-bedrock-mantle/discovery.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ describe("bedrock mantle discovery", () => {
2828
});
2929

3030
afterEach(() => {
31+
vi.restoreAllMocks();
32+
resetMantleDiscoveryCacheForTest();
33+
resetIamTokenCacheForTest();
3134
process.env = originalEnv;
3235
});
3336

extensions/amazon-bedrock/discovery.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { BedrockClient } from "@aws-sdk/client-bedrock";
2-
import { beforeEach, describe, expect, it, vi } from "vitest";
2+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33
import {
44
discoverBedrockModels,
55
mergeImplicitBedrockProvider,
@@ -36,6 +36,10 @@ describe("bedrock discovery", () => {
3636
resetBedrockDiscoveryCacheForTest();
3737
});
3838

39+
afterEach(() => {
40+
resetBedrockDiscoveryCacheForTest();
41+
});
42+
3943
it("filters to active streaming text models and maps modalities", async () => {
4044
sendMock
4145
.mockResolvedValueOnce({

extensions/amazon-bedrock/index.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
buildPluginApi,
77
registerSingleProviderPlugin,
88
} from "openclaw/plugin-sdk/plugin-test-runtime";
9-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
9+
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1010
import { setAwsSharedIniFileLoaderForTest } from "./aws-credential-refresh.js";
1111
import { resetBedrockDiscoveryCacheForTest } from "./discovery.js";
1212
import amazonBedrockPlugin from "./index.js";
@@ -239,6 +239,13 @@ describe("amazon-bedrock provider plugin", () => {
239239
afterEach(() => {
240240
setBedrockAppProfileControlPlaneForTest(undefined);
241241
setAwsSharedIniFileLoaderForTest(undefined);
242+
resetBedrockDiscoveryCacheForTest();
243+
resetBedrockAppProfileCacheEligibilityForTest();
244+
});
245+
246+
afterAll(() => {
247+
vi.doUnmock("@aws-sdk/client-bedrock");
248+
vi.resetModules();
242249
});
243250

244251
it("marks Claude 4.6 Bedrock models as adaptive by default", async () => {

extensions/amazon-bedrock/memory-embedding-adapter.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1+
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22

33
const hasAwsCredentialsMock = vi.hoisted(() => vi.fn());
44
const createBedrockEmbeddingProviderMock = vi.hoisted(() => vi.fn());
@@ -44,6 +44,11 @@ describe("bedrockMemoryEmbeddingProviderAdapter", () => {
4444
vi.restoreAllMocks();
4545
});
4646

47+
afterAll(() => {
48+
vi.doUnmock("./embedding-provider.js");
49+
vi.resetModules();
50+
});
51+
4752
it("registers the expected adapter metadata", () => {
4853
expect(bedrockMemoryEmbeddingProviderAdapter.id).toBe("bedrock");
4954
expect(bedrockMemoryEmbeddingProviderAdapter.transport).toBe("remote");

extensions/anthropic-vertex/index.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";
2-
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
2+
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33

44
const { hasAnthropicVertexAvailableAuthMock } = vi.hoisted(() => ({
55
hasAnthropicVertexAvailableAuthMock: vi.fn(),
@@ -24,6 +24,11 @@ describe("anthropic-vertex provider plugin", () => {
2424
vi.clearAllMocks();
2525
});
2626

27+
afterAll(() => {
28+
vi.doUnmock("./api.js");
29+
vi.resetModules();
30+
});
31+
2732
it("resolves the ADC marker through the provider hook", async () => {
2833
const provider = await registerSingleProviderPlugin(anthropicVertexPlugin);
2934

extensions/anthropic-vertex/region.adc.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { platform } from "node:os";
22
import path from "node:path";
3-
import { afterEach, describe, expect, it, vi } from "vitest";
3+
import { afterAll, afterEach, describe, expect, it, vi } from "vitest";
44

55
const { existsSyncMock, readFileSyncMock } = vi.hoisted(() => ({
66
existsSyncMock: vi.fn(),
@@ -35,6 +35,11 @@ describe("anthropic-vertex ADC reads", () => {
3535
readFileSyncMock.mockClear();
3636
});
3737

38+
afterAll(() => {
39+
vi.doUnmock("node:fs");
40+
vi.resetModules();
41+
});
42+
3843
it("reads explicit ADC credentials without an existsSync preflight", () => {
3944
const env = {
4045
GOOGLE_APPLICATION_CREDENTIALS: "/tmp/vertex-adc.json",

extensions/anthropic/cli-migration.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {
22
ProviderAuthContext,
33
ProviderAuthMethodNonInteractiveContext,
44
} from "openclaw/plugin-sdk/plugin-entry";
5-
import { describe, expect, it, vi } from "vitest";
5+
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
66

77
const { readClaudeCliCredentialsForSetup, readClaudeCliCredentialsForSetupNonInteractive } =
88
vi.hoisted(() => ({
@@ -24,6 +24,16 @@ const { createTestWizardPrompter, registerSingleProviderPlugin } =
2424
await import("openclaw/plugin-sdk/plugin-test-runtime");
2525
const { default: anthropicPlugin } = await import("./index.js");
2626

27+
beforeEach(() => {
28+
readClaudeCliCredentialsForSetup.mockReset();
29+
readClaudeCliCredentialsForSetupNonInteractive.mockReset();
30+
});
31+
32+
afterAll(() => {
33+
vi.doUnmock("./cli-auth-seam.js");
34+
vi.resetModules();
35+
});
36+
2737
async function resolveAnthropicCliAuthMethod() {
2838
const provider = await registerSingleProviderPlugin(anthropicPlugin);
2939
const method = provider.auth.find((entry) => entry.id === "cli");

0 commit comments

Comments
 (0)