diff --git a/src/agents/auth-profiles.store-cache.test.ts b/src/agents/auth-profiles.store-cache.test.ts index 81a56a5040a..ea23d9c490b 100644 --- a/src/agents/auth-profiles.store-cache.test.ts +++ b/src/agents/auth-profiles.store-cache.test.ts @@ -2,6 +2,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { clearRuntimeAuthProfileStoreSnapshots, ensureAuthProfileStore } from "./auth-profiles.js"; import { AUTH_STORE_VERSION } from "./auth-profiles/constants.js"; import type { OAuthCredential } from "./auth-profiles/types.js"; @@ -19,15 +20,6 @@ vi.mock("../plugins/provider-runtime.js", () => ({ resolveExternalAuthProfilesWithPlugins: () => [], })); -let clearRuntimeAuthProfileStoreSnapshots: typeof import("./auth-profiles.js").clearRuntimeAuthProfileStoreSnapshots; -let ensureAuthProfileStore: typeof import("./auth-profiles.js").ensureAuthProfileStore; - -async function loadFreshAuthProfilesModuleForTest() { - vi.resetModules(); - ({ clearRuntimeAuthProfileStoreSnapshots, ensureAuthProfileStore } = - await import("./auth-profiles.js")); -} - async function withAgentDirEnv(prefix: string, run: (agentDir: string) => void | Promise) { const agentDir = fs.mkdtempSync(path.join(os.tmpdir(), prefix)); const previousAgentDir = process.env.OPENCLAW_AGENT_DIR; @@ -75,14 +67,15 @@ function writeAuthStore(agentDir: string, key: string) { } describe("auth profile store cache", () => { - beforeEach(async () => { - await loadFreshAuthProfilesModuleForTest(); + beforeEach(() => { + clearRuntimeAuthProfileStoreSnapshots(); + mocks.resolveExternalCliAuthProfiles.mockReset(); + mocks.resolveExternalCliAuthProfiles.mockReturnValue([]); }); afterEach(() => { vi.useRealTimers(); clearRuntimeAuthProfileStoreSnapshots(); - vi.clearAllMocks(); }); function createRuntimeOnlyOverlay(access: string): RuntimeOnlyOverlay {