mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(wizard): handle undefined setup prompt text
Co-authored-by: mm1ord <101250822+mm1ord@users.noreply.github.com> Co-authored-by: Nikil Viswanathan <1175050+nikilster@users.noreply.github.com> Co-authored-by: tobemorelucky <205934056+tobemorelucky@users.noreply.github.com> Co-authored-by: dagangtj <65108318+dagangtj@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
@@ -75,6 +75,17 @@ describe("createClackPrompter", () => {
|
||||
expect(result).toBe("");
|
||||
});
|
||||
|
||||
it("preserves string clack text results without trimming", async () => {
|
||||
vi.mocked(text).mockResolvedValueOnce(" Alice ");
|
||||
const prompter = createClackPrompter();
|
||||
|
||||
const result = await prompter.text({
|
||||
message: "Name",
|
||||
});
|
||||
|
||||
expect(result).toBe(" Alice ");
|
||||
});
|
||||
|
||||
it("normalizes non-string clack password results to empty strings", async () => {
|
||||
vi.mocked(password).mockResolvedValueOnce({ cancelled: true } as never);
|
||||
const prompter = createClackPrompter();
|
||||
|
||||
@@ -13,10 +13,7 @@ import {
|
||||
spinner,
|
||||
text,
|
||||
} from "@clack/prompts";
|
||||
import {
|
||||
normalizeLowercaseStringOrEmpty,
|
||||
normalizeOptionalString,
|
||||
} from "@openclaw/normalization-core/string-coerce";
|
||||
import { normalizeLowercaseStringOrEmpty } from "@openclaw/normalization-core/string-coerce";
|
||||
import { stripAnsi } from "../../packages/terminal-core/src/ansi.js";
|
||||
import { note as emitNote } from "../../packages/terminal-core/src/note.js";
|
||||
import {
|
||||
@@ -54,7 +51,7 @@ function buildOptionSearchText<T>(option: Option<T>): string {
|
||||
}
|
||||
|
||||
function normalizeTextPromptResult(value: unknown): string {
|
||||
return normalizeOptionalString(value) ?? "";
|
||||
return typeof value === "string" ? value : "";
|
||||
}
|
||||
|
||||
export function tokenizedOptionFilter<T>(search: string, option: Option<T>): boolean {
|
||||
|
||||
Reference in New Issue
Block a user