test: stabilize ci test isolation

This commit is contained in:
Peter Steinberger
2026-04-08 17:34:45 +01:00
parent 5d46e4dc4f
commit c945ae7be5
4 changed files with 19 additions and 0 deletions

View File

@@ -5,11 +5,14 @@ import { logAuthProfileFailureStateChange } from "./state-observation.js";
afterEach(() => {
setLoggerOverride(null);
resetLogger();
vi.unstubAllEnvs();
});
describe("logAuthProfileFailureStateChange", () => {
it("sanitizes consoleMessage fields before logging", () => {
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
vi.stubEnv("FORCE_COLOR", "0");
vi.stubEnv("NO_COLOR", "1");
setLoggerOverride({ level: "silent", consoleLevel: "warn" });
logAuthProfileFailureStateChange({

View File

@@ -12,6 +12,7 @@ import { loadOpenClawPlugins } from "../plugins/loader.js";
import { guardSessionManager } from "./session-tool-result-guard-wrapper.js";
const EMPTY_PLUGIN_SCHEMA = { type: "object", additionalProperties: false, properties: {} };
const originalBundledPluginsDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
function writeTempPlugin(params: { dir: string; id: string; body: string }): string {
const pluginDir = path.join(params.dir, params.id);
@@ -60,6 +61,11 @@ function getPersistedToolResult(sm: ReturnType<typeof SessionManager.inMemory>)
afterEach(() => {
resetGlobalHookRunner();
if (originalBundledPluginsDir === undefined) {
delete process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
} else {
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = originalBundledPluginsDir;
}
});
describe("tool_result_persist hook", () => {