From cd265e5fd1bbebf401eeedc34156cdf5a42b850f Mon Sep 17 00:00:00 2001 From: Gabriel Date: Mon, 3 Apr 2023 17:50:36 +0200 Subject: [PATCH] test stubs - wip Signed-off-by: Gabriel --- ...tion-update-using-application-menu.test.ts | 67 +++++++++++++++++++ .../installing-update-using-tray.test.ts | 12 +++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/features/application-update/child-features/application-update-using-application-menu/application-update-using-application-menu.test.ts 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..fbb3820860 --- /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,67 @@ +/** + * 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"; + +describe("installing update using application menu", () => { + let applicationBuilder: ApplicationBuilder; + let checkForPlatformUpdatesMock: AsyncFnMock; + + beforeEach(() => { + applicationBuilder = getApplicationBuilder(); + applicationBuilder.beforeApplicationStart(({ mainDi }) => { + checkForPlatformUpdatesMock = asyncFn(); + mainDi.override( + checkForPlatformUpdatesInjectable, + () => checkForPlatformUpdatesMock, + ); + }); + }); + + 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 displays a popup + // 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..ba521d0292 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"; @@ -164,6 +164,16 @@ describe("installing update using tray", () => { }); }); + // it displays a popup + // showMessagePopup( + // "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(); });