diff --git a/src/features/skill-mcp-manager/manager-oauth-retry.test.ts b/src/features/skill-mcp-manager/manager-oauth-retry.test.ts index 5d6dabd77..f887e80e7 100644 --- a/src/features/skill-mcp-manager/manager-oauth-retry.test.ts +++ b/src/features/skill-mcp-manager/manager-oauth-retry.test.ts @@ -12,18 +12,18 @@ const mockGetOrCreateClientWithRetryImpl = mock(async () => ({ close: mock(async () => {}), })) -mock.module("./connection", () => ({ - getOrCreateClient: mockGetOrCreateClient, - getOrCreateClientWithRetryImpl: mockGetOrCreateClientWithRetryImpl, -})) - -mock.module("../mcp-oauth/provider", () => ({ - McpOAuthProvider: class MockMcpOAuthProvider {}, -})) - type ManagerModule = typeof import("./manager") async function importFreshManagerModule(): Promise { + mock.module("./connection", () => ({ + getOrCreateClient: mockGetOrCreateClient, + getOrCreateClientWithRetryImpl: mockGetOrCreateClientWithRetryImpl, + })) + + mock.module("../mcp-oauth/provider", () => ({ + McpOAuthProvider: class MockMcpOAuthProvider {}, + })) + return await import(new URL(`./manager.ts?oauth-retry-test=${Date.now()}-${Math.random()}`, import.meta.url).href) } diff --git a/src/features/skill-mcp-manager/oauth-handler.test.ts b/src/features/skill-mcp-manager/oauth-handler.test.ts index d6eb317bc..35823c6ae 100644 --- a/src/features/skill-mcp-manager/oauth-handler.test.ts +++ b/src/features/skill-mcp-manager/oauth-handler.test.ts @@ -1,15 +1,15 @@ -import { beforeEach, describe, expect, it, mock } from "bun:test" +import { describe, expect, it, mock } from "bun:test" import type { ClaudeCodeMcpServer } from "../claude-code-mcp-loader/types" import type { OAuthTokenData } from "../mcp-oauth/storage" import type { OAuthProviderFactory, OAuthProviderLike } from "./types" -mock.module("../mcp-oauth/provider", () => ({ - McpOAuthProvider: class MockMcpOAuthProvider {}, -})) - type OAuthHandlerModule = typeof import("./oauth-handler") async function importFreshOAuthHandlerModule(): Promise { + mock.module("../mcp-oauth/provider", () => ({ + McpOAuthProvider: class MockMcpOAuthProvider {}, + })) + return await import(new URL(`./oauth-handler.ts?oauth-handler-test=${Date.now()}-${Math.random()}`, import.meta.url).href) } @@ -41,10 +41,6 @@ function createConfig(serverUrl: string): ClaudeCodeMcpServer { } describe("oauth-handler refresh mutex wiring", () => { - beforeEach(() => { - mock.restore() - }) - it("deduplicates concurrent pre-request refresh attempts for the same server", async () => { // given const { buildHttpRequestInit } = await importFreshOAuthHandlerModule()