Add reactive tray icon for when update is available (#5567)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2022-06-08 08:37:19 -04:00
1 parent db65a89ee0
commit 17c7b6a1bf
32 files changed
+399 -241

No files matched your search

@@ -44,7 +44,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_13"
data-testid="close-notification-for-notification_16"
tabindex="0"
>
<span
@@ -95,7 +95,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_96"
data-testid="close-notification-for-notification_115"
tabindex="0"
>
<span
@@ -135,7 +135,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_99"
data-testid="close-notification-for-notification_118"
tabindex="0"
>
<span
@@ -186,7 +186,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_149"
data-testid="close-notification-for-notification_183"
tabindex="0"
>
<span
@@ -226,7 +226,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_152"
data-testid="close-notification-for-notification_186"
tabindex="0"
>
<span
@@ -266,7 +266,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_157"
data-testid="close-notification-for-notification_191"
tabindex="0"
>
<span
@@ -317,7 +317,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_215"
data-testid="close-notification-for-notification_266"
tabindex="0"
>
<span
@@ -357,7 +357,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_218"
data-testid="close-notification-for-notification_269"
tabindex="0"
>
<span
@@ -478,7 +478,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_48"
data-testid="close-notification-for-notification_59"
tabindex="0"
>
<span
@@ -518,7 +518,7 @@ exports[`installing update using tray when started when user checks for updates
>
<i
class="Icon close material interactive focusable"
data-testid="close-notification-for-notification_51"
data-testid="close-notification-for-notification_62"
tabindex="0"
>
<span
@@ -15,12 +15,15 @@ import type { DownloadPlatformUpdate } from "../../main/application-update/downl
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 progressOfUpdateDownloadInjectable from "../../common/application-update/progress-of-update-download/progress-of-update-download.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();
@@ -44,6 +47,7 @@ describe("installing update using tray", () => {
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
mainDi.override(publishIsConfiguredInjectable, () => true);
trayIconPaths = mainDi.inject(trayIconPathsInjectable);
});
});
@@ -58,22 +62,29 @@ 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")).toBeUndefined();
expect(applicationBuilder.tray.get("install-update")).toBeNull();
});
describe("when user checks for updates using tray", () => {
let processCheckingForUpdatesPromise: Promise<void>;
beforeEach(async () => {
processCheckingForUpdatesPromise =
applicationBuilder.tray.click("check-for-updates");
processCheckingForUpdatesPromise = applicationBuilder.tray.click("check-for-updates");
});
it("does not show application window yet", () => {
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.get(),
@@ -87,7 +98,7 @@ describe("installing update using tray", () => {
});
it("user cannot install update yet", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined();
expect(applicationBuilder.tray.get("install-update")).toBeNull();
});
it("renders", () => {
@@ -107,8 +118,12 @@ 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")).toBeUndefined();
expect(applicationBuilder.tray.get("install-update")).toBeNull();
});
it("user can check for updates again", () => {
@@ -142,6 +157,10 @@ 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.get(),
@@ -167,7 +186,7 @@ describe("installing update using tray", () => {
});
it("user still cannot install update", () => {
expect(applicationBuilder.tray.get("install-update")).toBeUndefined();
expect(applicationBuilder.tray.get("install-update")).toBeNull();
});
it("renders", () => {
@@ -182,7 +201,11 @@ describe("installing update using tray", () => {
it("user cannot install update", () => {
expect(
applicationBuilder.tray.get("install-update"),
).toBeUndefined();
).toBeNull();
});
it("should revert to use the normal tray icon", () => {
expect(applicationBuilder.tray.getIconPath()).toBe(trayIconPaths.normal);
});
it("user can check for updates again", () => {
@@ -213,6 +236,10 @@ 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.get(),