mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
test(deadcode): dedupe wizard prompter helpers
This commit is contained in:
@@ -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. */
|
||||
|
||||
@@ -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 () => {}),
|
||||
|
||||
Reference in New Issue
Block a user