From 2857805b666e6ce5ddd712ef6fac3e04f1a77dd1 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 08:40:47 -0700 Subject: [PATCH] test: isolate Ghostty import config env --- src/main/ghostty/index.test.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/ghostty/index.test.ts b/src/main/ghostty/index.test.ts index 518fdc0dadb..37d059c91fd 100644 --- a/src/main/ghostty/index.test.ts +++ b/src/main/ghostty/index.test.ts @@ -1,6 +1,6 @@ import type { Store } from '../persistence' import type { GlobalSettings } from '../../shared/types' -import { describe, expect, it, vi } from 'vitest' +import { afterEach, describe, expect, it, vi } from 'vitest' const { statMock, readFileMock } = vi.hoisted(() => ({ statMock: vi.fn(), @@ -19,6 +19,17 @@ vi.mock('os', () => ({ import { previewGhosttyImport } from './index' +const originalXdgConfigHome = process.env.XDG_CONFIG_HOME + +afterEach(() => { + vi.clearAllMocks() + if (originalXdgConfigHome !== undefined) { + process.env.XDG_CONFIG_HOME = originalXdgConfigHome + } else { + delete process.env.XDG_CONFIG_HOME + } +}) + function createStore(settings: Record = {}): Store { return { getSettings: () => settings as GlobalSettings @@ -67,6 +78,7 @@ background = #1a1a1a }) it('imports every discovered config file in Ghostty load order', async () => { + delete process.env.XDG_CONFIG_HOME statMock.mockImplementation(async (p: string) => { if ( p === '/Users/alice/.config/ghostty/config.ghostty' ||