From e257683390407fe5e93c4cb986202640d3d89d1b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 9 Aug 2026 04:29:34 -0700 Subject: [PATCH] test(wizard): restore stdin TTY state (#113345) --- .../setup.post-install-migration.test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wizard/setup.post-install-migration.test.ts b/src/wizard/setup.post-install-migration.test.ts index d77531e9e058..203ccecc62d2 100644 --- a/src/wizard/setup.post-install-migration.test.ts +++ b/src/wizard/setup.post-install-migration.test.ts @@ -1,5 +1,5 @@ // Post-install migration tests cover migration prompts and command guidance. -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { createWizardPrompter } from "../../test/helpers/wizard-prompter.js"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import { createNonExitingRuntime } from "../runtime.js"; @@ -42,6 +42,8 @@ vi.mock("../commands/migrate.js", () => ({ migrateDefaultCommand })); import { offerPostInstallMigrations } from "./setup.post-install-migration.js"; +const originalStdinIsTTYDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY"); + type ProviderMock = { id: string; label: string; @@ -110,6 +112,20 @@ describe("offerPostInstallMigrations", () => { setTTY(true); }); + afterEach(() => { + if (originalStdinIsTTYDescriptor) { + Object.defineProperty(process.stdin, "isTTY", originalStdinIsTTYDescriptor); + } else { + delete (process.stdin as Partial).isTTY; + } + }); + + afterAll(() => { + expect(Object.getOwnPropertyDescriptor(process.stdin, "isTTY")).toEqual( + originalStdinIsTTYDescriptor, + ); + }); + it("returns early when no plugins were installed in this onboarding step", async () => { const config = { plugins: { entries: { codex: { enabled: true } } } } as OpenClawConfig; const result = await offerPostInstallMigrations(