From 89a73d08c80564228fa2152c8f5f33e917c93933 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 21 Jun 2026 19:19:49 +0800 Subject: [PATCH] test(deadcode): dedupe wizard prompter helpers --- test/helpers/auth-wizard.ts | 16 ++-------------- test/helpers/wizard-prompter.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/test/helpers/auth-wizard.ts b/test/helpers/auth-wizard.ts index 0e34f666959f..d226c95a500d 100644 --- a/test/helpers/auth-wizard.ts +++ b/test/helpers/auth-wizard.ts @@ -6,12 +6,10 @@ import type { RuntimeEnv } from "../../src/runtime.js"; import { makeTempWorkspace } from "../../src/test-helpers/workspace.js"; import { captureEnv } from "../../src/test-utils/env.js"; import type { WizardPrompter } from "../../src/wizard/prompts.js"; +import { createWizardPrompter as createBaseWizardPrompter } from "./wizard-prompter.js"; // Shared auth wizard test helpers for runtime/env setup. -const noopAsync = async () => {}; -const noop = () => {}; - /** Create a RuntimeEnv whose exit method throws for assertions. */ export function createExitThrowingRuntime(): RuntimeEnv { return { @@ -28,17 +26,7 @@ export function createWizardPrompter( overrides: Partial, options?: { defaultSelect?: string }, ): WizardPrompter { - return { - intro: vi.fn(noopAsync), - outro: vi.fn(noopAsync), - note: vi.fn(noopAsync), - select: vi.fn(async () => (options?.defaultSelect ?? "") as never), - multiselect: vi.fn(async () => []), - text: vi.fn(async () => "") as unknown as WizardPrompter["text"], - confirm: vi.fn(async () => false), - progress: vi.fn(() => ({ update: noop, stop: noop })), - ...overrides, - }; + return createBaseWizardPrompter(overrides, { defaultSelect: options?.defaultSelect ?? "" }); } /** Create isolated auth state and agent directories for auth tests. */ diff --git a/test/helpers/wizard-prompter.ts b/test/helpers/wizard-prompter.ts index de0c953e9e36..dae6b5dcee98 100644 --- a/test/helpers/wizard-prompter.ts +++ b/test/helpers/wizard-prompter.ts @@ -5,8 +5,13 @@ import type { WizardPrompter } from "../../src/wizard/prompts.js"; // Vitest mock prompter for wizard tests. /** Create a WizardPrompter with default mocked responses and optional overrides. */ -export function createWizardPrompter(overrides?: Partial): WizardPrompter { - const select = vi.fn(async () => "quickstart") as unknown as WizardPrompter["select"]; +export function createWizardPrompter( + overrides?: Partial, + options?: { defaultSelect?: string }, +): WizardPrompter { + const select = vi.fn( + async () => options?.defaultSelect ?? "quickstart", + ) as unknown as WizardPrompter["select"]; return { intro: vi.fn(async () => {}), outro: vi.fn(async () => {}),