mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-21 13:44:03 +00:00
test: speed up agent config auth tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { CliBackendConfig } from "../config/types.js";
|
||||
import type { CliBundleMcpMode } from "../plugins/types.js";
|
||||
@@ -60,14 +60,16 @@ function createBackendEntry(params: {
|
||||
};
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
beforeAll(async () => {
|
||||
vi.doUnmock("../plugins/setup-registry.js");
|
||||
vi.doUnmock("../plugins/cli-backends.runtime.js");
|
||||
vi.resetModules();
|
||||
({ createEmptyPluginRegistry } = await import("../plugins/registry.js"));
|
||||
({ setActivePluginRegistry } = await import("../plugins/runtime.js"));
|
||||
({ normalizeClaudeBackendConfig, resolveCliBackendConfig, resolveCliBackendLiveTest } =
|
||||
await import("./cli-backends.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
const registry = createEmptyPluginRegistry();
|
||||
registry.cliBackends = [
|
||||
createBackendEntry({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { streamSimpleOpenAICompletions, type Model } from "@mariozechner/pi-ai";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ModelProviderConfig } from "../config/config.js";
|
||||
import { withFetchPreconnect } from "../test-utils/fetch-mock.js";
|
||||
import type { AuthProfileStore } from "./auth-profiles.js";
|
||||
@@ -114,10 +114,8 @@ let resolveUsableCustomProviderApiKey: typeof import("./model-auth.js").resolveU
|
||||
let clearRuntimeConfigSnapshot: typeof import("../config/config.js").clearRuntimeConfigSnapshot;
|
||||
let setRuntimeConfigSnapshot: typeof import("../config/config.js").setRuntimeConfigSnapshot;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
({ clearRuntimeConfigSnapshot, setRuntimeConfigSnapshot } = await import("../config/config.js"));
|
||||
clearRuntimeConfigSnapshot();
|
||||
({
|
||||
applyAuthHeaderOverride,
|
||||
applyLocalNoAuthHeaderOverride,
|
||||
@@ -130,6 +128,10 @@ beforeEach(async () => {
|
||||
} = await import("./model-auth.js"));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
clearRuntimeConfigSnapshot();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
clearRuntimeConfigSnapshot();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resetLogger, setLoggerOverride } from "../logging/logger.js";
|
||||
import { resetProviderRuntimeHookCacheForTest } from "../plugins/provider-runtime.js";
|
||||
@@ -51,8 +51,7 @@ function mockSingleOpenAiCatalogModel() {
|
||||
}
|
||||
|
||||
describe("loadModelCatalog", () => {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
vi.doMock("./models-config.js", () => ({
|
||||
ensureOpenClawModelsJson: vi.fn().mockResolvedValue({ agentDir: "/tmp", wrote: false }),
|
||||
}));
|
||||
@@ -71,7 +70,9 @@ describe("loadModelCatalog", () => {
|
||||
} = await import("./model-catalog.js"));
|
||||
const providerRuntime = await import("../plugins/provider-runtime.runtime.js");
|
||||
augmentCatalogMock = vi.mocked(providerRuntime.augmentModelCatalogWithProviderPlugins);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
resetModelCatalogCacheForTest();
|
||||
resetProviderRuntimeHookCacheForTest();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user