From 68ab999eede42037f3f98acc0d0105dad2ec5ba1 Mon Sep 17 00:00:00 2001 From: momen Date: Sun, 12 Apr 2026 19:00:14 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=9B=B4=E6=96=B0=E5=90=8E=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E5=88=B0=E4=B8=8B=E8=BD=BD=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__tests__/unit/processInstall.test.ts | 36 +++++++++++++++++++++++ src/modules/processInstall.ts | 6 ++++ 2 files changed, 42 insertions(+) create mode 100644 src/__tests__/unit/processInstall.test.ts 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); +});