mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 14:50:21 +00:00
test: stabilize isolated runtime and config suites
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ChannelPluginCatalogEntry } from "../channels/plugins/catalog.js";
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { DEFAULT_ACCOUNT_ID } from "../routing/session-key.js";
|
||||
import { createChannelTestPluginBase, createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
import {
|
||||
@@ -231,6 +231,7 @@ describe("channelsAddCommand", () => {
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
configMocks.readConfigFileSnapshot.mockClear();
|
||||
configMocks.writeConfigFile.mockClear();
|
||||
configMocks.replaceConfigFile
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ChannelPluginCatalogEntry } from "../channels/plugins/catalog.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
import { createTestRegistry } from "../test-utils/channel-plugins.js";
|
||||
import {
|
||||
ensureChannelSetupPluginInstalled,
|
||||
@@ -46,6 +46,7 @@ describe("channelsRemoveCommand", () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
configMocks.readConfigFileSnapshot.mockClear();
|
||||
configMocks.writeConfigFile.mockClear();
|
||||
configMocks.replaceConfigFile
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { normalizeCompatibilityConfigValues } from "./doctor-legacy-config.js";
|
||||
|
||||
let normalizeCompatibilityConfigValues: typeof import("./doctor-legacy-config.js").normalizeCompatibilityConfigValues;
|
||||
let clearPluginSetupRegistryCache: typeof import("../plugins/setup-registry.js").clearPluginSetupRegistryCache;
|
||||
|
||||
function asLegacyConfig(value: unknown): OpenClawConfig {
|
||||
return value as OpenClawConfig;
|
||||
@@ -34,11 +36,20 @@ describe("normalizeCompatibilityConfigValues", () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.doUnmock("./doctor-legacy-config.js");
|
||||
vi.doUnmock("openclaw/plugin-sdk/text-runtime");
|
||||
vi.resetModules();
|
||||
previousOauthDir = process.env.OPENCLAW_OAUTH_DIR;
|
||||
tempOauthDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-oauth-"));
|
||||
process.env.OPENCLAW_OAUTH_DIR = tempOauthDir;
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
({ normalizeCompatibilityConfigValues } = await import("./doctor-legacy-config.js"));
|
||||
({ clearPluginSetupRegistryCache } = await import("../plugins/setup-registry.js"));
|
||||
clearPluginSetupRegistryCache();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (previousOauthDir === undefined) {
|
||||
delete process.env.OPENCLAW_OAUTH_DIR;
|
||||
|
||||
@@ -33,6 +33,7 @@ describe("doctor command", () => {
|
||||
});
|
||||
|
||||
const runtime = { log: vi.fn(), error: vi.fn(), exit: vi.fn() };
|
||||
writeConfigFile.mockClear();
|
||||
|
||||
await doctorCommand(runtime, { nonInteractive: true, repair: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user