diff --git a/src/agents/auth-profiles/order.test.ts b/src/agents/auth-profiles/order.test.ts index 1aeb0afc3ab..29251c86746 100644 --- a/src/agents/auth-profiles/order.test.ts +++ b/src/agents/auth-profiles/order.test.ts @@ -1,9 +1,7 @@ import { mkdtemp, rm } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { beforeEach, describe, expect, it, vi } from "vitest"; -import { resolveAuthProfileOrder } from "./order.js"; -import { markAuthProfileGood } from "./profiles.js"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { saveAuthProfileStore } from "./store.js"; import type { AuthProfileStore } from "./types.js"; @@ -28,12 +26,30 @@ vi.mock("./external-auth.js", () => ({ shouldPersistExternalAuthProfile: () => true, })); +async function importAuthProfileModulesWithAliasRegistry() { + vi.resetModules(); + vi.doMock("../../plugins/manifest-registry.js", () => ({ + loadPluginManifestRegistry, + })); + const [{ resolveAuthProfileOrder }, { markAuthProfileGood }] = await Promise.all([ + import("./order.js"), + import("./profiles.js"), + ]); + return { markAuthProfileGood, resolveAuthProfileOrder }; +} + describe("resolveAuthProfileOrder", () => { beforeEach(() => { loadPluginManifestRegistry.mockClear(); }); - it("accepts aliased provider credentials from manifest metadata", () => { + afterEach(() => { + vi.doUnmock("../../plugins/manifest-registry.js"); + vi.resetModules(); + }); + + it("accepts aliased provider credentials from manifest metadata", async () => { + const { resolveAuthProfileOrder } = await importAuthProfileModulesWithAliasRegistry(); const store: AuthProfileStore = { version: 1, profiles: { @@ -54,6 +70,7 @@ describe("resolveAuthProfileOrder", () => { }); it("marks aliased provider profiles good under the canonical auth provider", async () => { + const { markAuthProfileGood } = await importAuthProfileModulesWithAliasRegistry(); const agentDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-auth-profile-alias-")); try { const store: AuthProfileStore = {