Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Isolate CLI removal tests from inherited XDG configuration (#7612)

Nick Gomez176b68aaf0f1
diff --git a/packages/cli/src/commands/removal-plan.test.ts b/packages/cli/src/commands/removal-plan.test.ts
index 93bc0ce9a..85bafbb17 100644
--- a/packages/cli/src/commands/removal-plan.test.ts
+++ b/packages/cli/src/commands/removal-plan.test.ts
@@ -45,6 +45,7 @@ import {
let OWN_ENTRY: ReturnType<typeof buildManagedServerEntry>;
beforeEach(() => {
+ vi.stubEnv('XDG_CONFIG_HOME', undefined);
vi.stubEnv('OK_CHANNEL', 'stable');
OWN_ENTRY = buildManagedServerEntry({ mode: 'published' });
});
diff --git a/packages/cli/src/commands/uninstall-feedback.test.ts b/packages/cli/src/commands/uninstall-feedback.test.ts
index e8334b616..3201a2e4f 100644
--- a/packages/cli/src/commands/uninstall-feedback.test.ts
+++ b/packages/cli/src/commands/uninstall-feedback.test.ts
@@ -8,7 +8,7 @@ import {
type UninstallFeedbackResult,
type UninstallFeedbackSubmission,
} from '@inkeep/open-knowledge-core';
-import { describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { runUninstall } from './uninstall.ts';
import { collectUninstallFeedbackAnswers, promptUninstallFeedback } from './uninstall-feedback.ts';
@@ -69,6 +69,14 @@ function drive(steps: Array<{ when: string; send: string }>): {
return { io: { input, output }, transcript: () => seen };
}
+beforeEach(() => {
+ vi.stubEnv('XDG_CONFIG_HOME', undefined);
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
describe('collectUninstallFeedbackAnswers', () => {
test('offers every reason plus a skip choice, all on one screen', async () => {
const driver = drive([{ when: 'mind sharing why', send: ENTER }]);
diff --git a/packages/cli/src/commands/uninstall-lock-recovery.test.ts b/packages/cli/src/commands/uninstall-lock-recovery.test.ts
index 9b32c46f3..f04b37c1f 100644
--- a/packages/cli/src/commands/uninstall-lock-recovery.test.ts
+++ b/packages/cli/src/commands/uninstall-lock-recovery.test.ts
@@ -17,7 +17,7 @@ import {
type LockProcessScan,
scanLockProcesses,
} from '@inkeep/open-knowledge-server';
-import { afterEach, beforeEach, describe, expect, test } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { hasLsof } from '../../../../test-support/capabilities.test-helper.ts';
import {
buildDeinitPlan,
@@ -34,10 +34,12 @@ describe.skipIf(process.platform === 'win32')('uninstall lock recovery in an iso
| { candidates: LockProcessScan['candidates']; livePidsAtScanTime: number[] }
| undefined;
beforeEach(() => {
+ vi.stubEnv('XDG_CONFIG_HOME', undefined);
root = realpathSync(mkdtempSync(join(tmpdir(), 'ok-uninstall-recovery-')));
observedScan = undefined;
});
afterEach(async () => {
+ vi.unstubAllEnvs();
for (const child of children.splice(0)) {
if (child.exitCode !== null || child.signalCode !== null) continue;
const exited = once(child, 'exit');
diff --git a/packages/cli/src/commands/uninstall.test.ts b/packages/cli/src/commands/uninstall.test.ts
index cdaabec77..f747b5e51 100644
--- a/packages/cli/src/commands/uninstall.test.ts
+++ b/packages/cli/src/commands/uninstall.test.ts
@@ -3,7 +3,7 @@ import { tmpdir } from 'node:os';
import { dirname, join } from 'node:path';
import { Readable } from 'node:stream';
import { SHARED_OK_ENTRIES } from '@inkeep/open-knowledge-core';
-import { afterEach, describe, expect, test, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
import { ensurePiBridge } from './pi-acp-bridge.ts';
import {
detectInstallMethods,
@@ -17,6 +17,14 @@ function write(path: string, content: string): void {
writeFileSync(path, content);
}
+beforeEach(() => {
+ vi.stubEnv('XDG_CONFIG_HOME', undefined);
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+});
+
describe('detectInstallMethods', () => {
test('detects an app bundle, npm-global, and npx', () => {
const home = mkdtempSync(join(tmpdir(), 'ok-detect-'));