From b970e691658b3271d3caebe3ac7c306ed5bfabd6 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Wed, 11 May 2022 13:24:24 +0300 Subject: [PATCH] Show application window when checking of updates has happened Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- .../installing-update-using-tray.test.ts | 17 +++++++++++++++++ .../check-for-updates-tray-item.injectable.ts | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/behaviours/update-app/installing-update-using-tray.test.ts b/src/behaviours/update-app/installing-update-using-tray.test.ts index a1961daef3..dfd8fa817b 100644 --- a/src/behaviours/update-app/installing-update-using-tray.test.ts +++ b/src/behaviours/update-app/installing-update-using-tray.test.ts @@ -19,6 +19,7 @@ import selectedUpdateChannelInjectable from "../../main/update-app/selected-upda import progressOfUpdateDownloadInjectable from "../../main/update-app/progress-of-update-download.injectable"; import type { IComputedValue } from "mobx"; import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable"; +import showApplicationWindowInjectable from "../../main/start-main-application/lens-window/show-application-window.injectable"; describe("installing update using tray", () => { let applicationBuilder: ApplicationBuilder; @@ -26,6 +27,7 @@ describe("installing update using tray", () => { let checkForPlatformUpdatesMock: AsyncFnMock; let downloadPlatformUpdateMock: AsyncFnMock<() => void>; let setUpdateOnQuitMock: jest.Mock; + let showApplicationWindowMock: jest.Mock; beforeEach(() => { applicationBuilder = getApplicationBuilder(); @@ -35,6 +37,9 @@ describe("installing update using tray", () => { checkForPlatformUpdatesMock = asyncFn(); downloadPlatformUpdateMock = asyncFn(); setUpdateOnQuitMock = jest.fn(); + showApplicationWindowMock = jest.fn(); + + mainDi.override(showApplicationWindowInjectable, () => showApplicationWindowMock); mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock); @@ -87,6 +92,10 @@ describe("installing update using tray", () => { ); }); + it("does not show application window yet", () => { + expect(showApplicationWindowMock).not.toHaveBeenCalled(); + }); + xit("notifies the user that checking for updates is happening", () => {}); it("user cannot check for updates again", () => { @@ -118,6 +127,10 @@ describe("installing update using tray", () => { await checkForUpdatesPromise; }); + it("shows application window", () => { + expect(showApplicationWindowMock).toHaveBeenCalled(); + }); + xit("notifies the user", () => {}); it("does not start downloading update", () => { @@ -155,6 +168,10 @@ describe("installing update using tray", () => { await checkForUpdatesPromise; }); + it("shows application window", () => { + expect(showApplicationWindowMock).toHaveBeenCalled(); + }); + it("starts downloading the update", () => { expect(downloadPlatformUpdateMock).toHaveBeenCalled(); }); diff --git a/src/main/update-app/check-for-updates-tray-item.injectable.ts b/src/main/update-app/check-for-updates-tray-item.injectable.ts index 1009edc408..cb56962c90 100644 --- a/src/main/update-app/check-for-updates-tray-item.injectable.ts +++ b/src/main/update-app/check-for-updates-tray-item.injectable.ts @@ -44,11 +44,11 @@ const checkForUpdatesTrayItemInjectable = getInjectable({ const { updateWasDiscovered } = await versionUpdate.checkForUpdates(); if (updateWasDiscovered) { + // Note: intentional orphan promise to make download happen in the background versionUpdate.downloadUpdate(); } - - // await showApplicationWindow(); + await showApplicationWindow(); }, }; },