|
1 | 1 | // 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"; |
3 | 3 | import { createWizardPrompter } from "../../test/helpers/wizard-prompter.js"; |
4 | 4 | import type { OpenClawConfig } from "../config/types.openclaw.js"; |
5 | 5 | import { createNonExitingRuntime } from "../runtime.js"; |
@@ -42,6 +42,8 @@ vi.mock("../commands/migrate.js", () => ({ migrateDefaultCommand })); |
42 | 42 |
|
43 | 43 | import { offerPostInstallMigrations } from "./setup.post-install-migration.js"; |
44 | 44 |
|
| 45 | +const originalStdinIsTTYDescriptor = Object.getOwnPropertyDescriptor(process.stdin, "isTTY"); |
| 46 | + |
45 | 47 | type ProviderMock = { |
46 | 48 | id: string; |
47 | 49 | label: string; |
@@ -110,6 +112,20 @@ describe("offerPostInstallMigrations", () => { |
110 | 112 | setTTY(true); |
111 | 113 | }); |
112 | 114 |
|
| 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 | + |
113 | 129 | it("returns early when no plugins were installed in this onboarding step", async () => { |
114 | 130 | const config = { plugins: { entries: { codex: { enabled: true } } } } as OpenClawConfig; |
115 | 131 | const result = await offerPostInstallMigrations( |
|
0 commit comments