From 85fa939051af798a0e8421db2515a115f18db191 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Wed, 8 Apr 2026 17:26:00 +0900 Subject: [PATCH] test(skill-mcp): fix connection env var tests after oauth-handler import changes Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../manager-oauth-retry.test.ts | 18 +++++++++--------- .../skill-mcp-manager/oauth-handler.test.ts | 14 +++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) 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()