Skip to content

Commit 95a13d3

Browse files
committed
test(wizard): restore stdin TTY state
1 parent 8362f74 commit 95a13d3

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎src/wizard/setup.post-install-migration.test.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Post-install migration tests cover migration prompts and command guidance.
2-
import { beforeEach, describe, expect, it, vi } from "vitest";
2+
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
33
import { createWizardPrompter } from "../../test/helpers/wizard-prompter.js";
44
import type { OpenClawConfig } from "../config/types.openclaw.js";
55
import { createNonExitingRuntime } from "../runtime.js";
@@ -42,6 +42,8 @@ vi.mock("../commands/migrate.js", () => ({ migrateDefaultCommand }));
4242

4343
import { offerPostInstallMigrations } from "./setup.post-install-migration.js";
4444

45+
const originalStdinIsTTYDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY");
46+
4547
type ProviderMock = {
4648
id: string;
4749
label: string;
@@ -110,6 +112,20 @@ describe("offerPostInstallMigrations", () => {
110112
setTTY(true);
111113
});
112114

115+
afterEach(() => {
116+
if (originalStdinIsTTYDescriptor) {
117+
Object.defineProperty(process.stdin, "isTTY", originalStdinIsTTYDescriptor);
118+
} else {
119+
delete (process.stdin as Partial<typeof process.stdin>).isTTY;
120+
}
121+
});
122+
123+
afterAll(() => {
124+
expect(Object.getOwnPropertyDescriptor(process.stdin, "isTTY")).toEqual(
125+
originalStdinIsTTYDescriptor,
126+
);
127+
});
128+
113129
it("returns early when no plugins were installed in this onboarding step", async () => {
114130
const config = { plugins: { entries: { codex: { enabled: true } } } } as OpenClawConfig;
115131
const result = await offerPostInstallMigrations(

0 commit comments

Comments
 (0)