1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Show application window when checking of updates has happened

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-05-11 13:24:24 +03:00
parent 244f283998
commit b970e69165
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 19 additions and 2 deletions

View File

@ -19,6 +19,7 @@ import selectedUpdateChannelInjectable from "../../main/update-app/selected-upda
import progressOfUpdateDownloadInjectable from "../../main/update-app/progress-of-update-download.injectable"; import progressOfUpdateDownloadInjectable from "../../main/update-app/progress-of-update-download.injectable";
import type { IComputedValue } from "mobx"; import type { IComputedValue } from "mobx";
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable"; 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", () => { describe("installing update using tray", () => {
let applicationBuilder: ApplicationBuilder; let applicationBuilder: ApplicationBuilder;
@ -26,6 +27,7 @@ describe("installing update using tray", () => {
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>; let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
let downloadPlatformUpdateMock: AsyncFnMock<() => void>; let downloadPlatformUpdateMock: AsyncFnMock<() => void>;
let setUpdateOnQuitMock: jest.Mock; let setUpdateOnQuitMock: jest.Mock;
let showApplicationWindowMock: jest.Mock;
beforeEach(() => { beforeEach(() => {
applicationBuilder = getApplicationBuilder(); applicationBuilder = getApplicationBuilder();
@ -35,6 +37,9 @@ describe("installing update using tray", () => {
checkForPlatformUpdatesMock = asyncFn(); checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn(); downloadPlatformUpdateMock = asyncFn();
setUpdateOnQuitMock = jest.fn(); setUpdateOnQuitMock = jest.fn();
showApplicationWindowMock = jest.fn();
mainDi.override(showApplicationWindowInjectable, () => showApplicationWindowMock);
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock); 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", () => {}); xit("notifies the user that checking for updates is happening", () => {});
it("user cannot check for updates again", () => { it("user cannot check for updates again", () => {
@ -118,6 +127,10 @@ describe("installing update using tray", () => {
await checkForUpdatesPromise; await checkForUpdatesPromise;
}); });
it("shows application window", () => {
expect(showApplicationWindowMock).toHaveBeenCalled();
});
xit("notifies the user", () => {}); xit("notifies the user", () => {});
it("does not start downloading update", () => { it("does not start downloading update", () => {
@ -155,6 +168,10 @@ describe("installing update using tray", () => {
await checkForUpdatesPromise; await checkForUpdatesPromise;
}); });
it("shows application window", () => {
expect(showApplicationWindowMock).toHaveBeenCalled();
});
it("starts downloading the update", () => { it("starts downloading the update", () => {
expect(downloadPlatformUpdateMock).toHaveBeenCalled(); expect(downloadPlatformUpdateMock).toHaveBeenCalled();
}); });

View File

@ -44,11 +44,11 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
const { updateWasDiscovered } = await versionUpdate.checkForUpdates(); const { updateWasDiscovered } = await versionUpdate.checkForUpdates();
if (updateWasDiscovered) { if (updateWasDiscovered) {
// Note: intentional orphan promise to make download happen in the background
versionUpdate.downloadUpdate(); versionUpdate.downloadUpdate();
} }
await showApplicationWindow();
// await showApplicationWindow();
}, },
}; };
}, },