mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Start showing different tray icon when checking for updates
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
23cbc2a2af
commit
cf8dbad569
@ -14,15 +14,12 @@ import asyncFn from "@async-fn/jest";
|
||||
import type { DownloadPlatformUpdate } from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||
import downloadPlatformUpdateInjectable from "../../main/application-update/download-platform-update/download-platform-update.injectable";
|
||||
import showApplicationWindowInjectable from "../../main/start-main-application/lens-window/show-application-window.injectable";
|
||||
import type { TrayIconPaths } from "../../main/tray/tray-icon-path.injectable";
|
||||
import trayIconPathsInjectable from "../../main/tray/tray-icon-path.injectable";
|
||||
|
||||
describe("installing update using tray", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
let checkForPlatformUpdatesMock: AsyncFnMock<CheckForPlatformUpdates>;
|
||||
let downloadPlatformUpdateMock: AsyncFnMock<DownloadPlatformUpdate>;
|
||||
let showApplicationWindowMock: jest.Mock;
|
||||
let trayIconPaths: TrayIconPaths;
|
||||
|
||||
beforeEach(() => {
|
||||
applicationBuilder = getApplicationBuilder();
|
||||
@ -46,7 +43,6 @@ describe("installing update using tray", () => {
|
||||
|
||||
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
|
||||
mainDi.override(publishIsConfiguredInjectable, () => true);
|
||||
trayIconPaths = mainDi.inject(trayIconPathsInjectable);
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,10 +57,6 @@ describe("installing update using tray", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should use the normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
|
||||
});
|
||||
|
||||
it("user cannot install update yet", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
@ -80,10 +72,6 @@ describe("installing update using tray", () => {
|
||||
expect(showApplicationWindowMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should still use the normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
|
||||
});
|
||||
|
||||
it("user cannot check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
@ -117,10 +105,6 @@ describe("installing update using tray", () => {
|
||||
expect(showApplicationWindowMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should still use the normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
|
||||
});
|
||||
|
||||
it("user cannot install update", () => {
|
||||
expect(applicationBuilder.tray.get("install-update")).toBeNull();
|
||||
});
|
||||
@ -156,10 +140,6 @@ describe("installing update using tray", () => {
|
||||
expect(showApplicationWindowMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should use the update available icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.updateAvailable);
|
||||
});
|
||||
|
||||
it("user cannot check for updates again yet", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
@ -199,10 +179,6 @@ describe("installing update using tray", () => {
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("should revert to use the normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
|
||||
});
|
||||
|
||||
it("user can check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
@ -231,10 +207,6 @@ describe("installing update using tray", () => {
|
||||
).toBe("Install update some-version");
|
||||
});
|
||||
|
||||
it("should use the update available icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.updateAvailable);
|
||||
});
|
||||
|
||||
it("user can check for updates again", () => {
|
||||
expect(
|
||||
applicationBuilder.tray.get("check-for-updates")?.enabled,
|
||||
|
||||
@ -17,6 +17,7 @@ import downloadPlatformUpdateInjectable from "../../main/application-update/down
|
||||
import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-update-on-quit.injectable";
|
||||
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
|
||||
import { useFakeTime } from "../../common/test-utils/use-fake-time";
|
||||
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
|
||||
|
||||
describe("installing update", () => {
|
||||
let applicationBuilder: ApplicationBuilder;
|
||||
@ -36,6 +37,8 @@ describe("installing update", () => {
|
||||
downloadPlatformUpdateMock = asyncFn();
|
||||
setUpdateOnQuitMock = jest.fn();
|
||||
|
||||
mainDi.override(staticFilesDirectoryInjectable, () => "/some-static-files-directory");
|
||||
|
||||
mainDi.override(setUpdateOnQuitInjectable, () => setUpdateOnQuitMock);
|
||||
|
||||
mainDi.override(
|
||||
@ -65,13 +68,21 @@ describe("installing update", () => {
|
||||
beforeEach(async () => {
|
||||
rendered = await applicationBuilder.render();
|
||||
|
||||
processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(processCheckingForUpdatesInjectable);
|
||||
processCheckingForUpdates = applicationBuilder.dis.mainDi.inject(
|
||||
processCheckingForUpdatesInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("shows normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
describe("when user checks for updates", () => {
|
||||
let processCheckingForUpdatesPromise: Promise<void>;
|
||||
|
||||
@ -86,6 +97,12 @@ describe("installing update", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("shows tray icon for checking for updates", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
@ -99,6 +116,12 @@ describe("installing update", () => {
|
||||
await processCheckingForUpdatesPromise;
|
||||
});
|
||||
|
||||
it("shows tray icon for normal", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not start downloading update", () => {
|
||||
expect(downloadPlatformUpdateMock).not.toHaveBeenCalled();
|
||||
});
|
||||
@ -122,6 +145,12 @@ describe("installing update", () => {
|
||||
expect(downloadPlatformUpdateMock).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("still shows tray icon for downloading", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconCheckingForUpdatesTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
@ -135,6 +164,12 @@ describe("installing update", () => {
|
||||
expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("still shows normal tray icon", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
@ -149,6 +184,12 @@ describe("installing update", () => {
|
||||
expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows tray icon for update being available", () => {
|
||||
expect(applicationBuilder.tray.getIconPath()).toBe(
|
||||
"/some-static-files-directory/icons/trayIconUpdateAvailableTemplate.png",
|
||||
);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
expect(rendered.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import getTrayIconPathInjectable from "../../tray/menu-icon/get-tray-icon-path.injectable";
|
||||
import { trayIconInjectionToken } from "../../tray/menu-icon/tray-icon-injection-token";
|
||||
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||
import updateIsBeingDownloadedInjectable from "../../../common/application-update/update-is-being-downloaded/update-is-being-downloaded.injectable";
|
||||
|
||||
const checkingForUpdatesTrayIconInjectable = getInjectable({
|
||||
id: "checking-for-updates-tray-icon",
|
||||
|
||||
instantiate: (di) => {
|
||||
const getTrayIconPath = di.inject(getTrayIconPathInjectable);
|
||||
const updatesAreBeingDiscovered = di.inject(updatesAreBeingDiscoveredInjectable);
|
||||
const updateIsBeingDownloaded = di.inject(updateIsBeingDownloadedInjectable);
|
||||
|
||||
return {
|
||||
iconPath: getTrayIconPath("checking-for-updates"),
|
||||
priority: 1,
|
||||
shouldBeShown: computed(
|
||||
() =>
|
||||
updatesAreBeingDiscovered.value.get() ||
|
||||
updateIsBeingDownloaded.value.get(),
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: trayIconInjectionToken,
|
||||
});
|
||||
|
||||
export default checkingForUpdatesTrayIconInjectable;
|
||||
Loading…
Reference in New Issue
Block a user