From 78f24dcaa23a10059e2fe958a66e447038bf08dd Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 16 Mar 2026 00:40:33 -0700 Subject: [PATCH] Tests: type auth contract prompt mocks --- src/plugins/contracts/auth.contract.test.ts | 28 +++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/plugins/contracts/auth.contract.test.ts b/src/plugins/contracts/auth.contract.test.ts index 1d753ca2f53..386c7acb6e7 100644 --- a/src/plugins/contracts/auth.contract.test.ts +++ b/src/plugins/contracts/auth.contract.test.ts @@ -5,12 +5,26 @@ import { } from "../../agents/auth-profiles/store.js"; import { createNonExitingRuntime } from "../../runtime.js"; import { createCapturedPluginRegistration } from "../../test-utils/plugin-registration.js"; -import type { WizardPrompter, WizardProgress } from "../../wizard/prompts.js"; +import type { + WizardMultiSelectParams, + WizardPrompter, + WizardProgress, + WizardSelectParams, +} from "../../wizard/prompts.js"; import type { OpenClawPluginApi, ProviderPlugin } from "../types.js"; -const loginOpenAICodexOAuthMock = vi.hoisted(() => vi.fn()); -const loginQwenPortalOAuthMock = vi.hoisted(() => vi.fn()); -const githubCopilotLoginCommandMock = vi.hoisted(() => vi.fn()); +type LoginOpenAICodexOAuth = + (typeof import("../../commands/openai-codex-oauth.js"))["loginOpenAICodexOAuth"]; +type LoginQwenPortalOAuth = + (typeof import("../../../extensions/qwen-portal-auth/oauth.js"))["loginQwenPortalOAuth"]; +type GithubCopilotLoginCommand = + (typeof import("../../providers/github-copilot-auth.js"))["githubCopilotLoginCommand"]; +type CreateVpsAwareHandlers = + (typeof import("../../commands/oauth-flow.js"))["createVpsAwareOAuthHandlers"]; + +const loginOpenAICodexOAuthMock = vi.hoisted(() => vi.fn()); +const loginQwenPortalOAuthMock = vi.hoisted(() => vi.fn()); +const githubCopilotLoginCommandMock = vi.hoisted(() => vi.fn()); vi.mock("../../commands/openai-codex-oauth.js", () => ({ loginOpenAICodexOAuth: loginOpenAICodexOAuthMock, @@ -37,8 +51,8 @@ function buildPrompter(): WizardPrompter { intro: async () => {}, outro: async () => {}, note: async () => {}, - select: async () => "", - multiselect: async () => [], + select: async (params: WizardSelectParams) => params.options[0].value, + multiselect: async (params: WizardMultiSelectParams) => params.initialValues ?? [], text: async () => "", confirm: async () => false, progress: () => progress, @@ -53,7 +67,7 @@ function buildAuthContext() { isRemote: false, openUrl: async () => {}, oauth: { - createVpsAwareHandlers: vi.fn() as never, + createVpsAwareHandlers: vi.fn(), }, }; }