diff --git a/src/__tests__/unit/processInstall.test.ts b/src/__tests__/unit/processInstall.test.ts new file mode 100644 index 00000000..60a5b24f --- /dev/null +++ b/src/__tests__/unit/processInstall.test.ts @@ -0,0 +1,36 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; + +describe("processInstall queue forwarding", () => { + beforeEach(() => { + vi.resetModules(); + }); + + it("forwards update-center queue-install events back to the main install queue", async () => { + const handlers = new Map void>(); + const send = vi.fn(); + const on = vi.fn( + (channel: string, handler: (...args: unknown[]) => void) => { + handlers.set(channel, handler); + }, + ); + + Object.assign(window.ipcRenderer, { + on, + send, + invoke: vi.fn(), + }); + + await import("@/modules/processInstall"); + + const payload = JSON.stringify({ + id: 7, + pkgname: "spark-weather", + origin: "spark", + upgradeOnly: true, + }); + + handlers.get("queue-install")?.({}, payload); + + expect(send).toHaveBeenCalledWith("queue-install", payload); + }); +}); diff --git a/src/modules/processInstall.ts b/src/modules/processInstall.ts index d67a43d2..c1d22aec 100644 --- a/src/modules/processInstall.ts +++ b/src/modules/processInstall.ts @@ -235,3 +235,9 @@ window.ipcRenderer.on("install-complete", (_event, log: DownloadResult) => { } } }); + +window.ipcRenderer.on("queue-install", (_event, payload: unknown) => { + const serializedPayload = + typeof payload === "string" ? payload : JSON.stringify(payload); + window.ipcRenderer.send("queue-install", serializedPayload); +});