Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions electron/auto-updater.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
blockedFromInstalling,
checkForSelfUpdate,
Expand Down Expand Up @@ -148,11 +148,23 @@ describe("self-update flow", () => {
expect(result).toMatchObject({ error: { message: "connection reset" } });
});

// isSilent=false so a per-machine Windows install can show its UAC prompt — a silent upgrade
// of a Program Files install hits elevation and, if dismissed, quits having done nothing.
// isForceRunAfter=true so the app comes back.
it("hands over to the installer non-silently and relaunches", async () => {
await installSelfUpdate();
expect(mocks.autoUpdater.quitAndInstall).toHaveBeenCalledWith(false, true);
describe("installSelfUpdate", () => {
const REAL_PLATFORM = process.platform;
const setPlatform = (value: NodeJS.Platform) =>
Object.defineProperty(process, "platform", { value, configurable: true });
afterEach(() => setPlatform(REAL_PLATFORM));

// Without /S the assisted NSIS installer opens on its install-mode page (#1437).
it("runs the Windows installer silently and relaunches", async () => {
setPlatform("win32");
await installSelfUpdate();
expect(mocks.autoUpdater.quitAndInstall).toHaveBeenCalledWith(true, true);
});

it.each(["darwin", "linux"] as const)("leaves %s non-silent", async (platform) => {
setPlatform(platform);
await installSelfUpdate();
expect(mocks.autoUpdater.quitAndInstall).toHaveBeenCalledWith(false, true);
});
});
});
10 changes: 6 additions & 4 deletions electron/auto-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ export async function downloadSelfUpdate(): Promise<UpdateOutcome> {
/** Quit and hand over to the installer. Callers MUST have checked `blockedFromInstalling`. */
export async function installSelfUpdate(): Promise<void> {
const autoUpdater = await getUpdater();
// isSilent=false so a per-machine Windows install can show its elevation prompt: a silent
// upgrade of a Program Files install hits UAC and, if the user dismisses it, quits having
// done nothing. isForceRunAfter=true so the app comes back up.
autoUpdater.quitAndInstall(false, true);
// Silent on Windows: our NSIS installer is assisted (`oneClick: false`), so without /S it
// shows its install-mode page and lets the user pick the copy to update — the wrong one when
// a per-user and a per-machine install coexist (#1437). Silent, it updates the per-machine
// install whenever there is one, elevating through UAC itself. The flag means nothing to the
// macOS and Linux updaters. isForceRunAfter=true so the app comes back up.
autoUpdater.quitAndInstall(process.platform === "win32", true);
}
Loading