test(wizard): restore stdin TTY state (#113345)

This commit is contained in:
Peter Steinberger
2026-08-09 04:29:34 -07:00
committed by GitHub
parent 05e534eae5
commit e257683390
@@ -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<typeof process.stdin>).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(