From 09259de01c04d22596f006af76dfa3596291a941 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Wed, 30 Sep 2026 12:16:00 -0500 Subject: [PATCH] fix: cover the gnome close path in the desktop quit test (#1332) --- src/backend/tests/electron/app-quit.test.ts | 22 ++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/backend/tests/electron/app-quit.test.ts b/src/backend/tests/electron/app-quit.test.ts index af93fafc8..0705bb36b 100644 --- a/src/backend/tests/electron/app-quit.test.ts +++ b/src/backend/tests/electron/app-quit.test.ts @@ -12,17 +12,26 @@ const shell = fs.readFileSync( "utf8", ); -function harness(active = true, hasTray = true) { +function harness( + active = true, + hasTray = true, + platform: { platform: string; env: Record } = { + platform: "win32", + env: {}, + }, +) { const app = new EventEmitter(); const window = Object.assign(new EventEmitter(), { webContents: new EventEmitter(), hide: vi.fn(), + minimize: vi.fn(), }); const context = vm.createContext({ isQuitting: false, app, mainWindow: window, console, + process: platform, tray: hasTray ? { isDestroyed: () => false } : null, hasActiveConnection: () => active, }); @@ -91,6 +100,17 @@ describe("desktop quit with active connections", () => { expect(event.preventDefault).toHaveBeenCalledOnce(); expect(app.window.hide).toHaveBeenCalledOnce(); }); + it("minimizes instead of hiding on GNOME, which has no tray by default", () => { + const app = harness(true, true, { + platform: "linux", + env: { XDG_CURRENT_DESKTOP: "ubuntu:GNOME" }, + }); + const event = { preventDefault: vi.fn() }; + app.window.emit("close", event); + expect(event.preventDefault).toHaveBeenCalledOnce(); + expect(app.window.minimize).toHaveBeenCalledOnce(); + expect(app.window.hide).not.toHaveBeenCalled(); + }); it("quits normally when no connection blocks unloading", () => { expect(harness(false).attemptQuit()).toBe(true); });