diff --git a/packages/core/src/features/application-update/child-features/application-update-using-application-menu/__snapshots__/application-update-using-application-menu.test.ts.snap b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/__snapshots__/application-update-using-application-menu.test.ts.snap
new file mode 100644
index 0000000000..3f42fc9c92
--- /dev/null
+++ b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/__snapshots__/application-update-using-application-menu.test.ts.snap
@@ -0,0 +1,286 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`installing update using application menu when started 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
+
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-application-menu/application-update-using-application-menu.test.ts b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/application-update-using-application-menu.test.ts
new file mode 100644
index 0000000000..f8edecd81b
--- /dev/null
+++ b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/application-update-using-application-menu.test.ts
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) OpenLens Authors. All rights reserved.
+ * Licensed under MIT License. See LICENSE in root directory for more information.
+ */
+
+import type { AsyncFnMock } from "@async-fn/jest";
+import asyncFn from "@async-fn/jest";
+import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
+import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
+import type { CheckForPlatformUpdates } from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
+import checkForPlatformUpdatesInjectable from "../../main/check-for-updates/check-for-platform-updates/check-for-platform-updates.injectable";
+import type { RenderResult } from "@testing-library/react";
+import showMessagePopupInjectable from "../../../../main/electron-app/features/show-message-popup.injectable";
+import type { ShowMessagePopup } from "../../../../main/electron-app/features/show-message-popup.injectable";
+import electronUpdaterIsActiveInjectable
+ from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
+import publishIsConfiguredInjectable
+ from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
+
+describe("installing update using application menu", () => {
+ let applicationBuilder: ApplicationBuilder;
+ let checkForPlatformUpdatesMock: AsyncFnMock;
+ let showMessagePopupMock: AsyncFnMock;
+
+ beforeEach(() => {
+ applicationBuilder = getApplicationBuilder();
+ applicationBuilder.beforeApplicationStart(({ mainDi }) => {
+ checkForPlatformUpdatesMock = asyncFn();
+ showMessagePopupMock = asyncFn();
+
+ mainDi.override(
+ checkForPlatformUpdatesInjectable,
+ () => checkForPlatformUpdatesMock,
+ );
+
+ mainDi.override(electronUpdaterIsActiveInjectable, () => true);
+ mainDi.override(publishIsConfiguredInjectable, () => true);
+
+ mainDi.override(
+ showMessagePopupInjectable,
+ () => showMessagePopupMock,
+ );
+ });
+ });
+
+ describe("when started", () => {
+ let rendered: RenderResult;
+
+ beforeEach(async () => {
+ rendered = await applicationBuilder.render();
+ });
+
+ it("renders", () => {
+ expect(rendered.baseElement).toMatchSnapshot();
+ });
+
+ describe("when user checks for updates using application menu", () => {
+ beforeEach(() => {
+ applicationBuilder.applicationMenu.click(
+ "root",
+ "mac",
+ "check-for-updates",
+ );
+ });
+ describe("when no new update is discovered", () => {
+ beforeEach(async () => {
+ await checkForPlatformUpdatesMock.resolve({
+ updateWasDiscovered: false,
+ });
+ });
+
+ it("it displays a popup", () => {
+ expect(showMessagePopupMock).toHaveBeenCalledWith(
+ "No Updates Available",
+ "You're all good",
+ "You've got the latest version of Lens,\nthanks for staying on the ball.",
+ { "textWidth": 300 },
+ );
+ });
+ });
+ });
+ });
+});
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-application-menu/main/check-for-updates-menu-item.injectable.ts b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/main/check-for-updates-menu-item.injectable.ts
index 97b9acf9f8..0bbf22abce 100644
--- a/packages/core/src/features/application-update/child-features/application-update-using-application-menu/main/check-for-updates-menu-item.injectable.ts
+++ b/packages/core/src/features/application-update/child-features/application-update-using-application-menu/main/check-for-updates-menu-item.injectable.ts
@@ -9,19 +9,17 @@ import processCheckingForUpdatesInjectable from "../../../main/process-checking-
import showApplicationWindowInjectable from "../../../../../main/start-main-application/lens-window/show-application-window.injectable";
import updatingIsEnabledInjectable from "../../../main/updating-is-enabled/updating-is-enabled.injectable";
import isMacInjectable from "../../../../../common/vars/is-mac.injectable";
+import showMessagePopupInjectable from "../../../../../main/electron-app/features/show-message-popup.injectable";
const checkForUpdatesMenuItemInjectable = getInjectable({
id: "check-for-updates-menu-item",
instantiate: (di) => {
- const processCheckingForUpdates = di.inject(
- processCheckingForUpdatesInjectable,
- );
-
+ const processCheckingForUpdates = di.inject(processCheckingForUpdatesInjectable);
const showApplicationWindow = di.inject(showApplicationWindowInjectable);
-
const updatingIsEnabled = di.inject(updatingIsEnabledInjectable);
const isMac = di.inject(isMacInjectable);
+ const showMessagePopup = di.inject(showMessagePopupInjectable);
return {
kind: "clickable-menu-item" as const,
@@ -31,11 +29,21 @@ const checkForUpdatesMenuItemInjectable = getInjectable({
label: "Check for Updates...",
isShown: updatingIsEnabled,
- onClick: () => {
- // Todo: implement using async/await
- processCheckingForUpdates("application-menu").then(() =>
- showApplicationWindow(),
- );
+ onClick: async () => {
+ const { updateIsReadyToBeInstalled } = await processCheckingForUpdates("application-menu");
+
+ if (updateIsReadyToBeInstalled) {
+ await showApplicationWindow();
+ } else {
+ showMessagePopup(
+ "No Updates Available",
+ "You're all good",
+ "You've got the latest version of Lens,\nthanks for staying on the ball.",
+ {
+ textWidth: 300,
+ },
+ );
+ }
},
};
},
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts b/packages/core/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts
index f18f288469..29f6cdbe48 100644
--- a/packages/core/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts
+++ b/packages/core/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts
@@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
-import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
+import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
import type { RenderResult } from "@testing-library/react";
import electronUpdaterIsActiveInjectable from "../../../../main/electron-app/features/electron-updater-is-active.injectable";
import publishIsConfiguredInjectable from "../../main/updating-is-enabled/publish-is-configured/publish-is-configured.injectable";
@@ -15,11 +15,14 @@ import type { DownloadPlatformUpdate } from "../../main/download-update/download
import downloadPlatformUpdateInjectable from "../../main/download-update/download-platform-update/download-platform-update.injectable";
import type { LensWindow } from "../../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable";
import getCurrentApplicationWindowInjectable from "../../../../main/start-main-application/lens-window/application-window/get-current-application-window.injectable";
+import showMessagePopupInjectable from "../../../../main/electron-app/features/show-message-popup.injectable";
+import type { ShowMessagePopup } from "../../../../main/electron-app/features/show-message-popup.injectable";
describe("installing update using tray", () => {
let builder: ApplicationBuilder;
let checkForPlatformUpdatesMock: AsyncFnMock;
let downloadPlatformUpdateMock: AsyncFnMock;
+ let showMessagePopupMock: AsyncFnMock;
beforeEach(() => {
builder = getApplicationBuilder();
@@ -27,6 +30,7 @@ describe("installing update using tray", () => {
builder.beforeApplicationStart(({ mainDi }) => {
checkForPlatformUpdatesMock = asyncFn();
downloadPlatformUpdateMock = asyncFn();
+ showMessagePopupMock = asyncFn();
mainDi.override(
checkForPlatformUpdatesInjectable,
@@ -40,6 +44,12 @@ describe("installing update using tray", () => {
mainDi.override(electronUpdaterIsActiveInjectable, () => true);
mainDi.override(publishIsConfiguredInjectable, () => true);
+
+ mainDi.override(
+ showMessagePopupInjectable,
+ () => showMessagePopupMock,
+ );
+
});
});
@@ -164,6 +174,15 @@ describe("installing update using tray", () => {
});
});
+ it("it displays a popup", () => {
+ expect(showMessagePopupMock).toHaveBeenCalledWith(
+ "No Updates Available",
+ "You're all good",
+ "You've got the latest version of Lens,\nthanks for staying on the ball.",
+ { "textWidth": 300 },
+ );
+ });
+
it("user cannot install update", () => {
expect(builder.tray.get("install-update")).toBeNull();
});
diff --git a/packages/core/src/features/application-update/child-features/application-update-using-tray/main/tray-items/check-for-updates-tray-item.injectable.ts b/packages/core/src/features/application-update/child-features/application-update-using-tray/main/tray-items/check-for-updates-tray-item.injectable.ts
index 3f05ddb71e..dd655708a8 100644
--- a/packages/core/src/features/application-update/child-features/application-update-using-tray/main/tray-items/check-for-updates-tray-item.injectable.ts
+++ b/packages/core/src/features/application-update/child-features/application-update-using-tray/main/tray-items/check-for-updates-tray-item.injectable.ts
@@ -16,6 +16,7 @@ import processCheckingForUpdatesInjectable from "../../../../main/process-checki
import { withErrorSuppression } from "../../../../../../common/utils/with-error-suppression/with-error-suppression";
import { pipeline } from "@ogre-tools/fp";
import withErrorLoggingInjectable from "../../../../../../common/utils/with-error-logging/with-error-logging.injectable";
+import showMessagePopupInjectable from "../../../../../../main/electron-app/features/show-message-popup.injectable";
const checkForUpdatesTrayItemInjectable = getInjectable({
id: "check-for-updates-tray-item",
@@ -29,6 +30,7 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
const processCheckingForUpdates = di.inject(processCheckingForUpdatesInjectable);
const withErrorLoggingFor = di.inject(withErrorLoggingInjectable);
+ const showMessagePopup = di.inject(showMessagePopupInjectable);
return {
id: "check-for-updates",
@@ -63,6 +65,15 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
if (updateIsReadyToBeInstalled) {
await showApplicationWindow();
+ } else {
+ showMessagePopup(
+ "No Updates Available",
+ "You're all good",
+ "You've got the latest version of Lens,\nthanks for staying on the ball.",
+ {
+ textWidth: 300,
+ },
+ );
}
},