diff --git a/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap b/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
index 0b32c9483145..cd0d55e25f72 100644
--- a/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
+++ b/packages/core/src/features/application-update/__snapshots__/installing-update.test.ts.snap
@@ -856,6 +856,601 @@ exports[`installing update when started when user checks for updates when new up
`;
exports[`installing update when started when user checks for updates when new update is discovered when download fails renders 1`] = `
+
+
+
+
+
+
+
+
+ home
+
+
+
+
+
+
+
+ arrow_back
+
+
+
+
+
+
+
+ arrow_forward
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Welcome to some-product-name!
+
+
+ To get you started we have auto-detected your clusters in your
+
+ kubeconfig file and added them to the catalog, your centralized
+
+ view for managing all your cloud-native resources.
+
+
+ If you have any questions or feedback, please join our
+
+ Lens Forums
+
+ .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ arrow_left
+
+
+
+
+
+ arrow_right
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`installing update when started when user checks for updates when new update is discovered when download succeeds given checking for updates again when check resolves with different update that was previously downloaded when download resolves successfully renders 1`] = `
+
+
+
+
+
+
+
+
+ home
+
+
+
+
+
+
+
+ arrow_back
+
+
+
+
+
+
+
+ arrow_forward
+
+
+
+
+
+
+ Update
+
+
+ arrow_drop_down
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Welcome to some-product-name!
+
+
+ To get you started we have auto-detected your clusters in your
+
+ kubeconfig file and added them to the catalog, your centralized
+
+ view for managing all your cloud-native resources.
+
+
+ If you have any questions or feedback, please join our
+
+ Lens Forums
+
+ .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ arrow_left
+
+
+
+
+
+ arrow_right
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`installing update when started when user checks for updates when new update is discovered when download succeeds given checking for updates again when check resolves with same update that is already downloaded renders 1`] = `
-
-
-
- Update
-
-
- arrow_drop_down
-
-
-
-
diff --git a/packages/core/src/features/application-update/installing-update.test.ts b/packages/core/src/features/application-update/installing-update.test.ts
index 719bb879bfb0..88ccb8ce0f16 100644
--- a/packages/core/src/features/application-update/installing-update.test.ts
+++ b/packages/core/src/features/application-update/installing-update.test.ts
@@ -18,10 +18,11 @@ import setUpdateOnQuitInjectable from "../../main/electron-app/features/set-upda
import processCheckingForUpdatesInjectable from "./main/process-checking-for-updates.injectable";
import { testUsingFakeTime } from "../../test-utils/use-fake-time";
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
+import electronQuitAndInstallUpdateInjectable from "../../main/electron-app/features/electron-quit-and-install-update.injectable";
describe("installing update", () => {
let builder: ApplicationBuilder;
- let quitAndInstallUpdateMock: jest.Mock;
+ let electronQuitAndInstallUpdateMock: jest.Mock;
let checkForPlatformUpdatesMock: AsyncFnMock
;
let downloadPlatformUpdateMock: AsyncFnMock;
let setUpdateOnQuitMock: jest.Mock;
@@ -32,7 +33,7 @@ describe("installing update", () => {
builder = getApplicationBuilder();
builder.beforeApplicationStart((mainDi) => {
- quitAndInstallUpdateMock = jest.fn();
+ electronQuitAndInstallUpdateMock = jest.fn();
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
setUpdateOnQuitMock = jest.fn();
@@ -52,8 +53,8 @@ describe("installing update", () => {
);
mainDi.override(
- quitAndInstallUpdateInjectable,
- () => quitAndInstallUpdateMock,
+ electronQuitAndInstallUpdateInjectable,
+ () => electronQuitAndInstallUpdateMock,
);
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
@@ -64,6 +65,7 @@ describe("installing update", () => {
describe("when started", () => {
let rendered: RenderResult;
let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>;
+ let quitAndInstallUpdate: () => void;
beforeEach(async () => {
rendered = await builder.render();
@@ -71,6 +73,10 @@ describe("installing update", () => {
processCheckingForUpdates = builder.mainDi.inject(
processCheckingForUpdatesInjectable,
);
+
+ quitAndInstallUpdate = builder.mainDi.inject(
+ quitAndInstallUpdateInjectable,
+ );
});
it("renders", () => {
@@ -155,7 +161,7 @@ describe("installing update", () => {
});
it("does not quit and install update yet", () => {
- expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
+ expect(electronQuitAndInstallUpdateMock).not.toHaveBeenCalled();
});
it("still shows normal tray icon", () => {
@@ -167,6 +173,12 @@ describe("installing update", () => {
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();
});
+
+ it("does not show the update button", () => {
+ const button = rendered.queryByTestId("update-button");
+
+ expect(button).not.toBeInTheDocument();
+ });
});
describe("when download succeeds", () => {
@@ -175,7 +187,7 @@ describe("installing update", () => {
});
it("does not quit and install update yet", () => {
- expect(quitAndInstallUpdateMock).not.toHaveBeenCalled();
+ expect(electronQuitAndInstallUpdateMock).not.toHaveBeenCalled();
});
it("shows tray icon for update being available", () => {
@@ -218,6 +230,26 @@ describe("installing update", () => {
"/some-static-files-directory/build/tray/trayIconUpdateAvailableTemplate.png",
);
});
+
+ it("does not quit and install update yet", () => {
+ expect(electronQuitAndInstallUpdateMock).not.toHaveBeenCalled();
+ });
+
+ it("renders", () => {
+ expect(rendered.baseElement).toMatchSnapshot();
+ });
+
+ it("shows the update button", () => {
+ const button = rendered.getByTestId("update-button");
+
+ expect(button).toBeInTheDocument();
+ });
+
+ it("when triggering the update, quits and installs the update", () => {
+ quitAndInstallUpdate();
+
+ expect(electronQuitAndInstallUpdateMock).toHaveBeenCalled();
+ });
});
describe("when check resolves with different update that was previously downloaded", () => {
@@ -237,6 +269,45 @@ describe("installing update", () => {
"/some-static-files-directory/build/tray/trayIconCheckingForUpdatesTemplate.png",
);
});
+
+ it("still shows the update button", () => {
+ const button = rendered.getByTestId("update-button");
+
+ expect(button).toBeInTheDocument();
+ });
+
+ describe("when download resolves successfully", () => {
+ beforeEach(async () => {
+ await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true });
+ });
+
+ it("still shows the update button", () => {
+ const button =
+ rendered.getByTestId("update-button");
+
+ expect(button).toBeInTheDocument();
+ });
+
+ it("does not quit and install update yet", () => {
+ expect(electronQuitAndInstallUpdateMock).not.toHaveBeenCalled();
+ });
+
+ it("shows tray icon for update being available", () => {
+ expect(builder.tray.getIconPath()).toBe(
+ "/some-static-files-directory/build/tray/trayIconUpdateAvailableTemplate.png",
+ );
+ });
+
+ it("renders", () => {
+ expect(rendered.baseElement).toMatchSnapshot();
+ });
+
+ it("when triggering the update, quits and installs the update", () => {
+ quitAndInstallUpdate();
+
+ expect(electronQuitAndInstallUpdateMock).toHaveBeenCalled();
+ });
+ });
});
});
});
diff --git a/packages/core/src/features/application-update/main/download-update/download-update.injectable.ts b/packages/core/src/features/application-update/main/download-update/download-update.injectable.ts
index e9019dc7b2db..662a2b272ded 100644
--- a/packages/core/src/features/application-update/main/download-update/download-update.injectable.ts
+++ b/packages/core/src/features/application-update/main/download-update/download-update.injectable.ts
@@ -40,11 +40,11 @@ const downloadUpdateInjectable = getInjectable({
if (!downloadWasSuccessful) {
progressOfUpdateDownload.set({ percentage: 0, failed: "Download of update failed" });
discoveredVersionState.set(null);
- }
-
- const currentDateTime = getCurrentDateTime();
+ } else {
+ const currentDateTime = getCurrentDateTime();
- updateDownloadedDate.set(currentDateTime);
+ updateDownloadedDate.set(currentDateTime);
+ }
downloadingUpdateState.set(false);
});