From f6977428daa3f61482e7066689ebf7092b0fb2b1 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Tue, 18 Apr 2023 14:04:02 +0300 Subject: [PATCH] fix(core): hide update button if downloading of an update fails Signed-off-by: Jari Kolehmainen --- .../installing-update.test.ts.snap | 286 ++++++++++++++++++ .../installing-update.test.ts | 23 ++ .../download-update.injectable.ts | 1 + 3 files changed, 310 insertions(+) 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 a7d7d4b906..a0beecfa65 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 @@ -1144,6 +1144,292 @@ 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 succeeds given checking for updates again when check resolves with different update that was previously downloaded 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 + + . +

+ +
+
+
+
+
+
+
+
+
+
+
+ Ca +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + arrow_left + + +
+
+ 1 +
+
+ + + 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`] = `
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 c186753954..0981c8c8f1 100644 --- a/packages/core/src/features/application-update/installing-update.test.ts +++ b/packages/core/src/features/application-update/installing-update.test.ts @@ -308,6 +308,29 @@ describe("installing update", () => { expect(electronQuitAndInstallUpdateMock).toHaveBeenCalled(); }); }); + + describe("when download fails", () => { + beforeEach(async () => { + await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: false }); + }); + + it("does not show the update button", () => { + const button = + rendered.queryByTestId("update-button"); + + expect(button).not.toBeInTheDocument(); + }); + + it("shows normal tray icon", () => { + expect(builder.tray.getIconPath()).toBe( + "/some-static-files-directory/build/tray/trayIconTemplate.png", + ); + }); + + it("renders", () => { + expect(rendered.baseElement).toMatchSnapshot(); + }); + }); }); }); }); 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 662a2b272d..fb1cbe0684 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,6 +40,7 @@ const downloadUpdateInjectable = getInjectable({ if (!downloadWasSuccessful) { progressOfUpdateDownload.set({ percentage: 0, failed: "Download of update failed" }); discoveredVersionState.set(null); + updateDownloadedDate.set(null); } else { const currentDateTime = getCurrentDateTime();