test(deadcode): dedupe wizard prompter helpers

This commit is contained in:
Vincent Koc
2026-06-21 19:19:49 +08:00
parent e6f41a4df0
commit 89a73d08c8
2 changed files with 9 additions and 16 deletions
+2 -14
View File
@@ -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<WizardPrompter>,
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. */
+7 -2
View File
@@ -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>): WizardPrompter {
const select = vi.fn(async () => "quickstart") as unknown as WizardPrompter["select"];
export function createWizardPrompter(
overrides?: Partial<WizardPrompter>,
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 () => {}),