From f11145045b033b7104e875d3efb3e2ab16c654cc Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 14 Oct 2022 13:25:33 -0400 Subject: [PATCH] Introduce and use ApplicationBuilder.quit in afterEach() hooks Signed-off-by: Sebastian Malton --- src/common/app-paths/app-paths.test.ts | 4 + ...e-stream.global-override-for-injectable.ts | 11 +++ src/common/utils/channel/channel.test.ts | 74 ++++++++++++------- src/common/utils/sync-box/sync-box.test.ts | 24 +++--- ...navigation-using-application-menu.test.tsx | 14 ++-- .../analytics-for-installing-update.test.ts | 4 + ...alling-update-using-topbar-button.test.tsx | 18 +++-- .../installing-update-using-tray.test.ts | 4 + ...g-time-since-update-was-downloaded.test.ts | 16 ++-- .../periodical-checking-of-updates.test.ts | 4 + .../selection-of-update-stability.test.ts | 4 + .../downgrading-version-update.test.ts | 14 ++-- .../installing-update.test.ts | 4 + .../delete-cluster-dialog.test.tsx | 4 + ...ages-when-cluster-is-not-relevant.test.tsx | 4 + ...tems-when-cluster-is-not-relevant.test.tsx | 4 + .../reactively-disable-cluster-pages.test.tsx | 4 + ...tems-when-cluster-is-not-relevant.test.tsx | 4 + ...vely-hide-kube-object-detail-item.test.tsx | 5 ++ ...tems-when-cluster-is-not-relevant.test.tsx | 4 + ...tively-hide-kube-object-menu-item.test.tsx | 4 + ...uses-when-cluster-is-not-relevant.test.tsx | 4 + ...eactively-hide-kube-object-status.test.tsx | 4 + .../show-status-for-a-kube-object.test.tsx | 4 + .../edit-namespace-from-new-tab.test.tsx | 4 + ...espace-from-previously-opened-tab.test.tsx | 4 + .../cluster/order-of-sidebar-items.test.tsx | 4 + ...debar-and-tab-navigation-for-core.test.tsx | 4 + ...and-tab-navigation-for-extensions.test.tsx | 34 +++++---- .../visibility-of-sidebar-items.test.tsx | 4 + ...ails-when-cluster-is-not-relevant.test.tsx | 4 + ...rder-of-workload-overview-details.test.tsx | 8 +- ...e-workloads-overview-details-item.test.tsx | 4 + .../keyboard-shortcuts.test.tsx | 4 + ...-characters-in-page-registrations.test.tsx | 4 + .../navigation-using-application-menu.test.ts | 4 + ...tom-helm-repository-in-preferences.test.ts | 4 + ...epository-from-list-in-preferences.test.ts | 4 + ...installing-helm-chart-from-new-tab.test.ts | 4 + ...m-chart-from-previously-opened-tab.test.ts | 4 + ...dock-tab-for-installing-helm-chart.test.ts | 4 + ...e-helm-repositories-in-preferences.test.ts | 4 + ...f-active-repository-in-preferences.test.ts | 4 + .../upgrade-chart-new-tab.test.ts | 4 + .../showing-details-for-helm-release.test.ts | 4 + .../navigate-to-extension-page.test.tsx | 8 +- .../navigating-between-routes.test.tsx | 4 + src/features/pod-logs/download-logs.test.tsx | 44 ++++++----- .../preferences/closing-preferences.test.tsx | 4 + .../extension-adding-preference-tabs.test.tsx | 4 + ...gation-to-application-preferences.test.tsx | 7 +- .../navigation-to-editor-preferences.test.ts | 17 +++-- ...to-extension-specific-preferences.test.tsx | 4 + ...vigation-to-kubernetes-preferences.test.ts | 4 + .../navigation-to-proxy-preferences.test.ts | 16 ++-- ...vigation-to-telemetry-preferences.test.tsx | 4 + ...navigation-to-terminal-preferences.test.ts | 17 +++-- .../navigation-using-application-menu.test.ts | 12 ++- .../preferences/navigation-using-tray.test.ts | 12 ++- ...ning-application-window-using-tray.test.ts | 4 + ...ing-the-app-using-application-menu.test.ts | 4 + .../resolve-system-proxy.test.ts | 4 + .../reactively-disable-global-pages.test.tsx | 4 + ...items-originating-from-extensions.test.tsx | 18 +++-- .../opening-terminal-tab.test.tsx.snap | 2 +- .../terminal/opening-terminal-tab.test.tsx | 4 + ...nu-item-originating-from-extension.test.ts | 4 + .../tray/extension-adding-tray-items.test.tsx | 4 + ...arators-originating-from-extension.test.ts | 4 + .../navigation-using-application-menu.test.ts | 14 ++-- .../welcome/setting-welcome-page.test.tsx | 28 ++++--- .../stop-proxy-on-quit.injectable.ts | 24 ++++++ .../runnables/setup-lens-proxy.injectable.ts | 2 - .../components/dock/terminal/terminal.ts | 1 + .../components/status-bar/status-bar.test.tsx | 4 + .../test-utils/get-application-builder.tsx | 10 +++ 76 files changed, 497 insertions(+), 153 deletions(-) create mode 100644 src/common/fs/create-read-file-stream.global-override-for-injectable.ts create mode 100644 src/main/lens-proxy/stop-proxy-on-quit.injectable.ts diff --git a/src/common/app-paths/app-paths.test.ts b/src/common/app-paths/app-paths.test.ts index 6e645f96fa..095973344f 100644 --- a/src/common/app-paths/app-paths.test.ts +++ b/src/common/app-paths/app-paths.test.ts @@ -56,6 +56,10 @@ describe("app-paths", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("normally", () => { let windowDi: DiContainer; let mainDi: DiContainer; diff --git a/src/common/fs/create-read-file-stream.global-override-for-injectable.ts b/src/common/fs/create-read-file-stream.global-override-for-injectable.ts new file mode 100644 index 0000000000..e4048476b0 --- /dev/null +++ b/src/common/fs/create-read-file-stream.global-override-for-injectable.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +import { getGlobalOverride } from "../test-utils/get-global-override"; +import createReadFileStreamInjectable from "./create-read-file-stream.injectable"; + +export default getGlobalOverride(createReadFileStreamInjectable, () => () => { + throw new Error("tried to create read stream for a file without override"); +}); diff --git a/src/common/utils/channel/channel.test.ts b/src/common/utils/channel/channel.test.ts index 7f2eb69787..1cd5df2264 100644 --- a/src/common/utils/channel/channel.test.ts +++ b/src/common/utils/channel/channel.test.ts @@ -60,6 +60,10 @@ describe("channel", () => { messageToChannel = mainDi.inject(sendMessageToChannelInjectionToken); }); + afterEach(() => { + builder.quit(); + }); + describe("given window is started", () => { let someWindowFake: LensWindow; @@ -103,10 +107,10 @@ describe("channel", () => { describe("messaging from renderer to main, given listener for channel in a main and application has started", () => { let messageListenerInMainMock: jest.Mock; let messageToChannel: SendMessageToChannel; + let builder: ApplicationBuilder; beforeEach(async () => { - const applicationBuilder = getApplicationBuilder(); - + builder = getApplicationBuilder(); messageListenerInMainMock = jest.fn(); const testChannelListenerInMainInjectable = getInjectable({ @@ -120,19 +124,23 @@ describe("channel", () => { injectionToken: messageChannelListenerInjectionToken, }); - applicationBuilder.beforeApplicationStart((mainDi) => { + builder.beforeApplicationStart((mainDi) => { runInAction(() => { mainDi.register(testChannelListenerInMainInjectable); }); }); - await applicationBuilder.render(); + await builder.render(); - const windowDi = applicationBuilder.applicationWindow.only.di; + const windowDi = builder.applicationWindow.only.di; messageToChannel = windowDi.inject(sendMessageToChannelInjectionToken); }); + afterEach(() => { + builder.quit(); + }); + it("when sending message, triggers listener in main", () => { messageToChannel(testMessageChannel, "some-message"); @@ -143,10 +151,10 @@ describe("channel", () => { describe("requesting from main in renderer, given listener for channel in a main and application has started", () => { let requestListenerInMainMock: AsyncFnMock>; let requestFromChannel: RequestFromChannel; + let builder: ApplicationBuilder; beforeEach(async () => { - const applicationBuilder = getApplicationBuilder(); - + builder = getApplicationBuilder(); requestListenerInMainMock = asyncFn(); const testChannelListenerInMainInjectable = getRequestChannelListenerInjectable({ @@ -154,19 +162,23 @@ describe("channel", () => { handler: () => requestListenerInMainMock, }); - applicationBuilder.beforeApplicationStart((mainDi) => { + builder.beforeApplicationStart((mainDi) => { runInAction(() => { mainDi.register(testChannelListenerInMainInjectable); }); }); - await applicationBuilder.render(); + await builder.render(); - const windowDi = applicationBuilder.applicationWindow.only.di; + const windowDi = builder.applicationWindow.only.di; requestFromChannel = windowDi.inject(requestFromChannelInjectable); }); + afterEach(() => { + builder.quit(); + }); + describe("when requesting from channel", () => { let actualPromise: Promise; @@ -194,28 +206,38 @@ describe("channel", () => { }); }); - it("when registering multiple handlers for the same channel, throws", async () => { - const applicationBuilder = getApplicationBuilder(); + describe("when registering multiple handlers for the same channel", () => { + let builder: ApplicationBuilder; - const testChannelListenerInMainInjectable = getRequestChannelListenerInjectable({ - channel: testRequestChannel, - handler: () => () => "some-value", - }); - const testChannelListenerInMain2Injectable = getRequestChannelListenerInjectable({ - channel: testRequestChannel, - handler: () => () => "some-other-value", - }); + beforeEach(() => { + builder = getApplicationBuilder(); - testChannelListenerInMain2Injectable.id += "2"; + const testChannelListenerInMainInjectable = getRequestChannelListenerInjectable({ + channel: testRequestChannel, + handler: () => () => "some-value", + }); + const testChannelListenerInMain2Injectable = getRequestChannelListenerInjectable({ + channel: testRequestChannel, + handler: () => () => "some-other-value", + }); - applicationBuilder.beforeApplicationStart((mainDi) => { - runInAction(() => { - mainDi.register(testChannelListenerInMainInjectable); - mainDi.register(testChannelListenerInMain2Injectable); + testChannelListenerInMain2Injectable.id += "2"; + + builder.beforeApplicationStart((mainDi) => { + runInAction(() => { + mainDi.register(testChannelListenerInMainInjectable); + mainDi.register(testChannelListenerInMain2Injectable); + }); }); }); - await expect(applicationBuilder.render()).rejects.toThrow('Tried to register a multiple channel handlers for "some-request-channel-id", only one handler is supported for a request channel.'); + afterEach(() => { + builder.quit(); + }); + + it("throws on startup", async () => { + await expect(builder.render()).rejects.toThrow('Tried to register a multiple channel handlers for "some-request-channel-id", only one handler is supported for a request channel.'); + }); }); }); diff --git a/src/common/utils/sync-box/sync-box.test.ts b/src/common/utils/sync-box/sync-box.test.ts index 95f139a8cd..48e420a43e 100644 --- a/src/common/utils/sync-box/sync-box.test.ts +++ b/src/common/utils/sync-box/sync-box.test.ts @@ -12,32 +12,36 @@ import type { SyncBox } from "./sync-box-injection-token"; import { syncBoxInjectionToken } from "./sync-box-injection-token"; describe("sync-box", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.beforeApplicationStart(mainDi => { + builder.beforeApplicationStart(mainDi => { runInAction(() => { mainDi.register(someInjectable); }); }); - applicationBuilder.beforeWindowStart((windowDi) => { + builder.beforeWindowStart((windowDi) => { runInAction(() => { windowDi.register(someInjectable); }); }); }); + afterEach(() => { + builder.quit(); + }); + describe("given application is started, when value is set in main", () => { let valueInMain: string; let syncBoxInMain: SyncBox; beforeEach(async () => { - await applicationBuilder.startHidden(); + await builder.startHidden(); - syncBoxInMain = applicationBuilder.mainDi.inject(someInjectable); + syncBoxInMain = builder.mainDi.inject(someInjectable); observe(syncBoxInMain.value, ({ newValue }) => { valueInMain = newValue as string; @@ -59,7 +63,7 @@ describe("sync-box", () => { beforeEach(async () => { const applicationWindow = - applicationBuilder.applicationWindow.create("some-window-id"); + builder.applicationWindow.create("some-window-id"); await applicationWindow.start(); @@ -101,11 +105,11 @@ describe("sync-box", () => { let syncBoxInRenderer: SyncBox; beforeEach(async () => { - await applicationBuilder.render(); + await builder.render(); - const applicationWindow = applicationBuilder.applicationWindow.only; + const applicationWindow = builder.applicationWindow.only; - syncBoxInMain = applicationBuilder.mainDi.inject(someInjectable); + syncBoxInMain = builder.mainDi.inject(someInjectable); syncBoxInRenderer = applicationWindow.di.inject(someInjectable); observe(syncBoxInRenderer.value, ({ newValue }) => { diff --git a/src/features/add-cluster/navigation-using-application-menu.test.tsx b/src/features/add-cluster/navigation-using-application-menu.test.tsx index 19b11672c9..725015c8e2 100644 --- a/src/features/add-cluster/navigation-using-application-menu.test.tsx +++ b/src/features/add-cluster/navigation-using-application-menu.test.tsx @@ -8,13 +8,17 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/ge import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; describe("add-cluster - navigation using application menu", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered: RenderResult; beforeEach(async () => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); + }); + + afterEach(() => { + builder.quit(); }); it("renders", () => { @@ -28,8 +32,8 @@ describe("add-cluster - navigation using application menu", () => { }); describe("when navigating to add cluster using application menu", () => { - beforeEach(async () => { - await applicationBuilder.applicationMenu.click( + beforeEach(() => { + builder.applicationMenu.click( "root", "file", "add-cluster", diff --git a/src/features/application-update/analytics-for-installing-update.test.ts b/src/features/application-update/analytics-for-installing-update.test.ts index ce77d37229..ae95051a4a 100644 --- a/src/features/application-update/analytics-for-installing-update.test.ts +++ b/src/features/application-update/analytics-for-installing-update.test.ts @@ -62,6 +62,10 @@ describe("analytics for installing update", () => { mainDi = builder.mainDi; }); + afterEach(() => { + builder.quit(); + }); + describe("given application is started and checking updates periodically", () => { beforeEach(async () => { mainDi.unoverride(periodicalCheckForUpdatesInjectable); diff --git a/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx b/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx index adede427d2..b7d37a8cd6 100644 --- a/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx +++ b/src/features/application-update/child-features/application-update-using-top-bar/installing-update-using-topbar-button.test.tsx @@ -23,7 +23,7 @@ function daysToMilliseconds(days: number) { } describe("encourage user to update when sufficient time passed since update was downloaded", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let checkForPlatformUpdatesMock: AsyncFnMock; let downloadPlatformUpdateMock: AsyncFnMock; let quitAndInstallUpdateMock: jest.MockedFunction<() => void>; @@ -31,9 +31,9 @@ describe("encourage user to update when sufficient time passed since update was beforeEach(() => { testUsingFakeTime("2015-10-21T07:28:00Z"); - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.beforeApplicationStart((mainDi) => { + builder.beforeApplicationStart((mainDi) => { checkForPlatformUpdatesMock = asyncFn(); downloadPlatformUpdateMock = asyncFn(); @@ -55,11 +55,15 @@ describe("encourage user to update when sufficient time passed since update was }); }); + afterEach(() => { + builder.quit(); + }); + describe("when started", () => { let rendered: RenderResult; beforeEach(async () => { - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); it("renders", () => { @@ -76,7 +80,7 @@ describe("encourage user to update when sufficient time passed since update was let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>; beforeEach(async () => { - processCheckingForUpdates = applicationBuilder.mainDi.inject( + processCheckingForUpdates = builder.mainDi.inject( processCheckingForUpdatesInjectable, ); @@ -106,9 +110,9 @@ describe("encourage user to update when sufficient time passed since update was }); it("given closing the application window, when starting the application window again, still shows the button", async () => { - applicationBuilder.applicationWindow.closeAll(); + builder.applicationWindow.closeAll(); - const window = applicationBuilder.applicationWindow.create("some-window-id"); + const window = builder.applicationWindow.create("some-window-id"); await window.start(); diff --git a/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts b/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts index af38da12b7..ad1d20cb53 100644 --- a/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts +++ b/src/features/application-update/child-features/application-update-using-tray/installing-update-using-tray.test.ts @@ -43,6 +43,10 @@ describe("installing update using tray", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("when started", () => { let rendered: RenderResult; diff --git a/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts b/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts index 39ac24570a..73fa30d293 100644 --- a/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts +++ b/src/features/application-update/child-features/force-user-to-update-when-too-long-time-since-update-was-downloaded/force-user-to-update-when-too-long-time-since-update-was-downloaded.test.ts @@ -24,7 +24,7 @@ const TIME_AFTER_UPDATE_MUST_BE_INSTALLED = 1000; const TIME_AFTER_INSTALL_STARTS = 5 * 1000; describe("force user to update when too long since update was downloaded", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let checkForPlatformUpdatesMock: AsyncFnMock; let downloadPlatformUpdateMock: AsyncFnMock; let mainDi: DiContainer; @@ -33,9 +33,9 @@ describe("force user to update when too long since update was downloaded", () => beforeEach(() => { testUsingFakeTime("2015-10-21T07:28:00Z"); - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.beforeApplicationStart(mainDi => { + builder.beforeApplicationStart(mainDi => { checkForPlatformUpdatesMock = asyncFn(); mainDi.override(checkForPlatformUpdatesInjectable, () => checkForPlatformUpdatesMock); @@ -49,7 +49,7 @@ describe("force user to update when too long since update was downloaded", () => mainDi.override(quitAndInstallUpdateInjectable, () => quitAndInstallUpdateMock); }); - applicationBuilder.beforeWindowStart(windowDi => { + builder.beforeWindowStart(windowDi => { windowDi.unoverride(forceUpdateModalRootFrameComponentInjectable); windowDi.permitSideEffects(forceUpdateModalRootFrameComponentInjectable); @@ -57,14 +57,18 @@ describe("force user to update when too long since update was downloaded", () => windowDi.override(secondsAfterInstallStartsInjectable, () => TIME_AFTER_INSTALL_STARTS / 1000); }); - mainDi = applicationBuilder.mainDi; + mainDi = builder.mainDi; + }); + + afterEach(() => { + builder.quit(); }); describe("when application is started", () => { let rendered: RenderResult; beforeEach(async () => { - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); describe("given checking for updates and it resolves, when update was downloaded", () => { diff --git a/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts b/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts index 22765b85de..6961538d4c 100644 --- a/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts +++ b/src/features/application-update/child-features/periodical-checking-of-updates/periodical-checking-of-updates.test.ts @@ -35,6 +35,10 @@ describe("periodical checking of updates", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given updater is enabled and configuration exists, when started", () => { let rendered: RenderResult; diff --git a/src/features/application-update/child-features/selection-of-update-stability/selection-of-update-stability.test.ts b/src/features/application-update/child-features/selection-of-update-stability/selection-of-update-stability.test.ts index 8e84d4d32f..7e864085df 100644 --- a/src/features/application-update/child-features/selection-of-update-stability/selection-of-update-stability.test.ts +++ b/src/features/application-update/child-features/selection-of-update-stability/selection-of-update-stability.test.ts @@ -73,6 +73,10 @@ describe("selection of update stability", () => { mainDi = builder.mainDi; }); + afterEach(() => { + builder.quit(); + }); + describe("when started", () => { let rendered: RenderResult; let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>; diff --git a/src/features/application-update/downgrading-version-update.test.ts b/src/features/application-update/downgrading-version-update.test.ts index 69c6b5c6ff..f0ad80d099 100644 --- a/src/features/application-update/downgrading-version-update.test.ts +++ b/src/features/application-update/downgrading-version-update.test.ts @@ -17,14 +17,14 @@ import { updateChannels } from "./common/update-channels"; import getBuildVersionInjectable from "../../main/vars/build-version/get-build-version.injectable"; describe("downgrading version update", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let checkForPlatformUpdatesMock: AsyncFnMock; let mainDi: DiContainer; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.beforeApplicationStart(mainDi => { + builder.beforeApplicationStart(mainDi => { checkForPlatformUpdatesMock = asyncFn(); mainDi.override( @@ -36,7 +36,11 @@ describe("downgrading version update", () => { mainDi.override(publishIsConfiguredInjectable, () => true); }); - mainDi = applicationBuilder.mainDi; + mainDi = builder.mainDi; + }); + + afterEach(() => { + builder.quit(); }); [ @@ -104,7 +108,7 @@ describe("downgrading version update", () => { it(`given application version "${appVersion}" and update channel "${updateChannel.id}", when checking for updates, can${downgradeIsAllowed ? "": "not"} downgrade`, async () => { mainDi.override(getBuildVersionInjectable, () => () => appVersion); - await applicationBuilder.render(); + await builder.render(); const selectedUpdateChannel = mainDi.inject(selectedUpdateChannelInjectable); diff --git a/src/features/application-update/installing-update.test.ts b/src/features/application-update/installing-update.test.ts index 81529a851f..cf5d79965b 100644 --- a/src/features/application-update/installing-update.test.ts +++ b/src/features/application-update/installing-update.test.ts @@ -61,6 +61,10 @@ describe("installing update", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("when started", () => { let rendered: RenderResult; let processCheckingForUpdates: (source: string) => Promise<{ updateIsReadyToBeInstalled: boolean }>; diff --git a/src/features/cluster/delete-dialog/delete-cluster-dialog.test.tsx b/src/features/cluster/delete-dialog/delete-cluster-dialog.test.tsx index 5cbf8267de..ac6b59adef 100644 --- a/src/features/cluster/delete-dialog/delete-cluster-dialog.test.tsx +++ b/src/features/cluster/delete-dialog/delete-cluster-dialog.test.tsx @@ -104,6 +104,10 @@ describe("Deleting a cluster", () => { rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when the kubeconfig has multiple clusters", () => { let currentCluster: Cluster; let nonCurrentCluster: Cluster; diff --git a/src/features/cluster/extension-api/disable-cluster-pages-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/extension-api/disable-cluster-pages-when-cluster-is-not-relevant.test.tsx index fcd5044639..aceeb31cfa 100644 --- a/src/features/cluster/extension-api/disable-cluster-pages-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/extension-api/disable-cluster-pages-when-cluster-is-not-relevant.test.tsx @@ -47,6 +47,10 @@ describe("disable-cluster-pages-when-cluster-is-not-relevant", () => { builder.extensions.get("test-extension-id").applicationWindows.only; }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster, when navigating", () => { beforeEach(() => { rendererTestExtension.navigate(); diff --git a/src/features/cluster/extension-api/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/extension-api/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx index efc16c8ef2..739de9c65f 100644 --- a/src/features/cluster/extension-api/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/extension-api/disable-sidebar-items-when-cluster-is-not-relevant.test.tsx @@ -53,6 +53,10 @@ describe("disable sidebar items when cluster is not relevant", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster", () => { it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); diff --git a/src/features/cluster/extension-api/reactively-disable-cluster-pages.test.tsx b/src/features/cluster/extension-api/reactively-disable-cluster-pages.test.tsx index 57dc83d810..8323767b37 100644 --- a/src/features/cluster/extension-api/reactively-disable-cluster-pages.test.tsx +++ b/src/features/cluster/extension-api/reactively-disable-cluster-pages.test.tsx @@ -46,6 +46,10 @@ describe("reactively disable cluster pages", () => { builder.extensions.get("test-extension-id").applicationWindows.only; }); + afterEach(() => { + builder.quit(); + }); + it("when navigating to the page, does not show the page", () => { testExtensionInstance.navigate(); diff --git a/src/features/cluster/kube-object-details/extension-api/disable-kube-object-detail-items-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/kube-object-details/extension-api/disable-kube-object-detail-items-when-cluster-is-not-relevant.test.tsx index 3804ea7046..a29d07bb14 100644 --- a/src/features/cluster/kube-object-details/extension-api/disable-kube-object-detail-items-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/kube-object-details/extension-api/disable-kube-object-detail-items-when-cluster-is-not-relevant.test.tsx @@ -75,6 +75,10 @@ describe("disable kube object detail items when cluster is not relevant", () => builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster", () => { it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); diff --git a/src/features/cluster/kube-object-details/extension-api/reactively-hide-kube-object-detail-item.test.tsx b/src/features/cluster/kube-object-details/extension-api/reactively-hide-kube-object-detail-item.test.tsx index 1a22d5d0b0..f374a115ff 100644 --- a/src/features/cluster/kube-object-details/extension-api/reactively-hide-kube-object-detail-item.test.tsx +++ b/src/features/cluster/kube-object-details/extension-api/reactively-hide-kube-object-detail-item.test.tsx @@ -74,6 +74,11 @@ describe("reactively hide kube object detail item", () => { builder.extensions.enable(testExtension); }); + + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); }); diff --git a/src/features/cluster/kube-object-menu/extension-api/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/kube-object-menu/extension-api/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx index f7dff90f24..343ee461bf 100644 --- a/src/features/cluster/kube-object-menu/extension-api/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/kube-object-menu/extension-api/disable-kube-object-menu-items-when-cluster-is-not-relevant.test.tsx @@ -70,6 +70,10 @@ describe("disable kube object menu items when cluster is not relevant", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster", () => { it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); diff --git a/src/features/cluster/kube-object-menu/extension-api/reactively-hide-kube-object-menu-item.test.tsx b/src/features/cluster/kube-object-menu/extension-api/reactively-hide-kube-object-menu-item.test.tsx index be8cc96ed9..b7a6ccb31c 100644 --- a/src/features/cluster/kube-object-menu/extension-api/reactively-hide-kube-object-menu-item.test.tsx +++ b/src/features/cluster/kube-object-menu/extension-api/reactively-hide-kube-object-menu-item.test.tsx @@ -66,6 +66,10 @@ describe("reactively hide kube object menu item", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + it("does not show the kube object menu item", () => { const actual = rendered.queryByTestId("some-kube-object-menu-item"); diff --git a/src/features/cluster/kube-object-status-icon/extension-api/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/kube-object-status-icon/extension-api/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx index 49fae34daf..e14373548f 100644 --- a/src/features/cluster/kube-object-status-icon/extension-api/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/kube-object-status-icon/extension-api/disable-kube-object-statuses-when-cluster-is-not-relevant.test.tsx @@ -71,6 +71,10 @@ describe("disable kube object statuses when cluster is not relevant", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster", () => { it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); diff --git a/src/features/cluster/kube-object-status-icon/extension-api/reactively-hide-kube-object-status.test.tsx b/src/features/cluster/kube-object-status-icon/extension-api/reactively-hide-kube-object-status.test.tsx index aebc03a0f4..72da364956 100644 --- a/src/features/cluster/kube-object-status-icon/extension-api/reactively-hide-kube-object-status.test.tsx +++ b/src/features/cluster/kube-object-status-icon/extension-api/reactively-hide-kube-object-status.test.tsx @@ -67,6 +67,10 @@ describe("reactively hide kube object status", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + it("does not show the kube object status", () => { const actual = rendered.baseElement.querySelectorAll( ".KubeObjectStatusIcon", diff --git a/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx b/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx index 49fe7f9efd..997eb1f3ea 100644 --- a/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx +++ b/src/features/cluster/kube-object-status-icon/show-status-for-a-kube-object.test.tsx @@ -110,6 +110,10 @@ describe("show status for a kube object", () => { builder.setEnvironmentToClusterFrame(); }); + afterEach(() => { + builder.quit(); + }); + describe("given application starts and in test page", () => { let windowDi: DiContainer; let rendered: RenderResult; diff --git a/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx b/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx index a3761caf21..df316f8562 100644 --- a/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx +++ b/src/features/cluster/namespaces/edit-namespace-from-new-tab.test.tsx @@ -70,6 +70,10 @@ describe("cluster/namespaces - edit namespace from new tab", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("when navigating to namespaces", () => { let rendered: RenderResult; let windowDi: DiContainer; diff --git a/src/features/cluster/namespaces/edit-namespace-from-previously-opened-tab.test.tsx b/src/features/cluster/namespaces/edit-namespace-from-previously-opened-tab.test.tsx index 0d49469951..1ad5dcaf3e 100644 --- a/src/features/cluster/namespaces/edit-namespace-from-previously-opened-tab.test.tsx +++ b/src/features/cluster/namespaces/edit-namespace-from-previously-opened-tab.test.tsx @@ -41,6 +41,10 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () = }); }); + afterEach(() => { + builder.quit(); + }); + describe("given tab was previously opened, when application is started", () => { let rendered: RenderResult; diff --git a/src/features/cluster/order-of-sidebar-items.test.tsx b/src/features/cluster/order-of-sidebar-items.test.tsx index 449fb838c1..bd1454c3a0 100644 --- a/src/features/cluster/order-of-sidebar-items.test.tsx +++ b/src/features/cluster/order-of-sidebar-items.test.tsx @@ -28,6 +28,10 @@ describe("cluster - order of sidebar items", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("when rendered", () => { beforeEach(async () => { rendered = await builder.render(); diff --git a/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx b/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx index a4995c38ae..6f28ce1b1e 100644 --- a/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx +++ b/src/features/cluster/sidebar-and-tab-navigation-for-core.test.tsx @@ -40,6 +40,10 @@ describe("cluster - sidebar and tab navigation for core", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given core registrations", () => { beforeEach(() => { builder.beforeWindowStart((windowDi) => { diff --git a/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx b/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx index 27a211a0cb..37c17efa90 100644 --- a/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx +++ b/src/features/cluster/sidebar-and-tab-navigation-for-extensions.test.tsx @@ -23,17 +23,17 @@ import type { DiContainer } from "@ogre-tools/injectable"; import { flushPromises } from "../../common/test-utils/flush-promises"; describe("cluster - sidebar and tab navigation for extensions", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered: RenderResult; beforeEach(() => { testUsingFakeTime("2015-10-21T07:28:00Z"); - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.setEnvironmentToClusterFrame(); + builder.setEnvironmentToClusterFrame(); - applicationBuilder.beforeWindowStart((windowDi) => { + builder.beforeWindowStart((windowDi) => { windowDi.override(storageSaveDelayInjectable, () => 250); windowDi.override( @@ -43,6 +43,10 @@ describe("cluster - sidebar and tab navigation for extensions", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given extension with cluster pages and cluster page menus", () => { let someObservable: IObservableValue; @@ -125,14 +129,14 @@ describe("cluster - sidebar and tab navigation for extensions", () => { }, }; - applicationBuilder.extensions.enable(testExtension); + builder.extensions.enable(testExtension); }); describe("given no state for expanded sidebar items exists, and navigated to child sidebar item, when rendered", () => { beforeEach(async () => { - rendered = await applicationBuilder.render(); + rendered = await builder.render(); - const windowDi = applicationBuilder.applicationWindow.only.di; + const windowDi = builder.applicationWindow.only.di; const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken); @@ -173,7 +177,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { describe("given state for expanded sidebar items already exists, when rendered", () => { beforeEach(async () => { - applicationBuilder.beforeWindowStart(async (windowDi) => { + builder.beforeWindowStart(async (windowDi) => { const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable); await writeJsonFileFake( @@ -187,7 +191,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { ); }); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); it("renders", () => { @@ -209,7 +213,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { describe("given state for expanded unknown sidebar items already exists, when rendered", () => { beforeEach(async () => { - applicationBuilder.beforeWindowStart(async (windowDi) => { + builder.beforeWindowStart(async (windowDi) => { const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable); await writeJsonFileFake( @@ -223,7 +227,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { ); }); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); it("renders without errors", () => { @@ -239,7 +243,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { describe("given empty state for expanded sidebar items already exists, when rendered", () => { beforeEach(async () => { - applicationBuilder.beforeWindowStart(async (windowDi) => { + builder.beforeWindowStart(async (windowDi) => { const writeJsonFileFake = windowDi.inject(writeJsonFileInjectable); await writeJsonFileFake( @@ -250,7 +254,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => { ); }); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); it("renders without errors", () => { @@ -268,9 +272,9 @@ describe("cluster - sidebar and tab navigation for extensions", () => { let windowDi: DiContainer; beforeEach(async () => { - rendered = await applicationBuilder.render(); + rendered = await builder.render(); - windowDi = applicationBuilder.applicationWindow.only.di; + windowDi = builder.applicationWindow.only.di; }); it("renders", () => { diff --git a/src/features/cluster/visibility-of-sidebar-items.test.tsx b/src/features/cluster/visibility-of-sidebar-items.test.tsx index 2eb42b7fdf..b4abf0a655 100644 --- a/src/features/cluster/visibility-of-sidebar-items.test.tsx +++ b/src/features/cluster/visibility-of-sidebar-items.test.tsx @@ -33,6 +33,10 @@ describe("cluster - visibility of sidebar items", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given kube resource for route is not allowed", () => { beforeEach(async () => { rendered = await builder.render(); diff --git a/src/features/cluster/workloads/overview/extension-api/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx b/src/features/cluster/workloads/overview/extension-api/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx index e40b7361fb..de3f8e8303 100644 --- a/src/features/cluster/workloads/overview/extension-api/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx +++ b/src/features/cluster/workloads/overview/extension-api/disable-workloads-overview-details-when-cluster-is-not-relevant.test.tsx @@ -57,6 +57,10 @@ describe("disable workloads overview details when cluster is not relevant", () = builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given not yet known if extension should be enabled for the cluster", () => { it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); diff --git a/src/features/cluster/workloads/overview/extension-api/order-of-workload-overview-details.test.tsx b/src/features/cluster/workloads/overview/extension-api/order-of-workload-overview-details.test.tsx index 620b2cabb1..70bcb6204e 100644 --- a/src/features/cluster/workloads/overview/extension-api/order-of-workload-overview-details.test.tsx +++ b/src/features/cluster/workloads/overview/extension-api/order-of-workload-overview-details.test.tsx @@ -3,6 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { RenderResult } from "@testing-library/react"; +import type { ApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../../../../renderer/components/test-utils/get-application-builder"; import React from "react"; import getRandomIdInjectable from "../../../../../common/utils/get-random-id.injectable"; @@ -12,9 +13,10 @@ import { computed, runInAction } from "mobx"; describe("order of workload overview details", () => { let rendered: RenderResult; + let builder: ApplicationBuilder; beforeEach(async () => { - const builder = getApplicationBuilder(); + builder = getApplicationBuilder(); builder.beforeWindowStart((windowDi) => { windowDi.unoverride(getRandomIdInjectable); @@ -78,6 +80,10 @@ describe("order of workload overview details", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + it("shows items in correct order", () => { const actual = rendered.queryAllByTestId("workload-overview-detail").map(x => x.id); diff --git a/src/features/cluster/workloads/overview/extension-api/reactively-hide-workloads-overview-details-item.test.tsx b/src/features/cluster/workloads/overview/extension-api/reactively-hide-workloads-overview-details-item.test.tsx index fbc8ceebca..ac62c021fc 100644 --- a/src/features/cluster/workloads/overview/extension-api/reactively-hide-workloads-overview-details-item.test.tsx +++ b/src/features/cluster/workloads/overview/extension-api/reactively-hide-workloads-overview-details-item.test.tsx @@ -54,6 +54,10 @@ describe("reactively hide workloads overview details item", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + it("does not show the workload overview detail item", () => { const actual = rendered.queryByTestId("some-workload-overview-detail-item"); diff --git a/src/features/command-pallet/keyboard-shortcuts.test.tsx b/src/features/command-pallet/keyboard-shortcuts.test.tsx index ddf18b2f76..5419e98f69 100644 --- a/src/features/command-pallet/keyboard-shortcuts.test.tsx +++ b/src/features/command-pallet/keyboard-shortcuts.test.tsx @@ -16,6 +16,10 @@ describe("Command Pallet: keyboard shortcut tests", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("when on macOS", () => { beforeEach(async () => { builder.beforeWindowStart((windowDi) => { diff --git a/src/features/extension-special-characters-in-page-registrations.test.tsx b/src/features/extension-special-characters-in-page-registrations.test.tsx index ac038a5743..756bf8249c 100644 --- a/src/features/extension-special-characters-in-page-registrations.test.tsx +++ b/src/features/extension-special-characters-in-page-registrations.test.tsx @@ -25,6 +25,10 @@ describe("extension special characters in page registrations", () => { windowDi = builder.applicationWindow.only.di; }); + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.container).toMatchSnapshot(); }); diff --git a/src/features/extensions/navigation-using-application-menu.test.ts b/src/features/extensions/navigation-using-application-menu.test.ts index 237e0a93a1..8e7d67c42d 100644 --- a/src/features/extensions/navigation-using-application-menu.test.ts +++ b/src/features/extensions/navigation-using-application-menu.test.ts @@ -28,6 +28,10 @@ describe("extensions - navigation using application menu", () => { rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.container).toMatchSnapshot(); }); diff --git a/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts b/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts index 495d2e9fb3..451b6228bd 100644 --- a/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts +++ b/src/features/helm-charts/add-custom-helm-repository-in-preferences.test.ts @@ -58,6 +58,10 @@ describe("add custom helm repository in preferences", () => { rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when navigating to preferences containing helm repositories", () => { beforeEach(async () => { builder.preferences.navigate(); diff --git a/src/features/helm-charts/add-helm-repository-from-list-in-preferences.test.ts b/src/features/helm-charts/add-helm-repository-from-list-in-preferences.test.ts index 8bdfb4e507..07bb53b420 100644 --- a/src/features/helm-charts/add-helm-repository-from-list-in-preferences.test.ts +++ b/src/features/helm-charts/add-helm-repository-from-list-in-preferences.test.ts @@ -50,6 +50,10 @@ describe("add helm repository from list in preferences", () => { rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when navigating to preferences containing helm repositories", () => { beforeEach(() => { builder.preferences.navigate(); diff --git a/src/features/helm-charts/installing-chart/installing-helm-chart-from-new-tab.test.ts b/src/features/helm-charts/installing-chart/installing-helm-chart-from-new-tab.test.ts index f7aef8dd88..112d07d2cb 100644 --- a/src/features/helm-charts/installing-chart/installing-helm-chart-from-new-tab.test.ts +++ b/src/features/helm-charts/installing-chart/installing-helm-chart-from-new-tab.test.ts @@ -71,6 +71,10 @@ describe("installing helm chart from new tab", () => { builder.namespaces.add("some-other-namespace"); }); + afterEach(() => { + builder.quit(); + }); + describe("given tab for installing chart was not previously opened and application is started", () => { let rendered: RenderResult; let windowDi: DiContainer; diff --git a/src/features/helm-charts/installing-chart/installing-helm-chart-from-previously-opened-tab.test.ts b/src/features/helm-charts/installing-chart/installing-helm-chart-from-previously-opened-tab.test.ts index db11c245aa..e890e8d557 100644 --- a/src/features/helm-charts/installing-chart/installing-helm-chart-from-previously-opened-tab.test.ts +++ b/src/features/helm-charts/installing-chart/installing-helm-chart-from-previously-opened-tab.test.ts @@ -48,6 +48,10 @@ describe("installing helm chart from previously opened tab", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given tab for installing chart was previously opened, when application is started", () => { let rendered: RenderResult; diff --git a/src/features/helm-charts/installing-chart/opening-dock-tab-for-installing-helm-chart.test.ts b/src/features/helm-charts/installing-chart/opening-dock-tab-for-installing-helm-chart.test.ts index 3fd6a7deb7..9de86c8ed9 100644 --- a/src/features/helm-charts/installing-chart/opening-dock-tab-for-installing-helm-chart.test.ts +++ b/src/features/helm-charts/installing-chart/opening-dock-tab-for-installing-helm-chart.test.ts @@ -56,6 +56,10 @@ describe("opening dock tab for installing helm chart", () => { builder.setEnvironmentToClusterFrame(); }); + afterEach(() => { + builder.quit(); + }); + describe("given application is started, when navigating to helm charts", () => { let rendered: RenderResult; diff --git a/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts b/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts index 49a8d0c28e..5158a18c48 100644 --- a/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts +++ b/src/features/helm-charts/listing-active-helm-repositories-in-preferences.test.ts @@ -56,6 +56,10 @@ describe("listing active helm repositories in preferences", () => { rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when navigating to preferences containing helm repositories", () => { beforeEach(async () => { builder.preferences.navigate(); diff --git a/src/features/helm-charts/remove-helm-repository-from-list-of-active-repository-in-preferences.test.ts b/src/features/helm-charts/remove-helm-repository-from-list-of-active-repository-in-preferences.test.ts index 59743be36d..ce1de119e0 100644 --- a/src/features/helm-charts/remove-helm-repository-from-list-of-active-repository-in-preferences.test.ts +++ b/src/features/helm-charts/remove-helm-repository-from-list-of-active-repository-in-preferences.test.ts @@ -41,6 +41,10 @@ describe("remove helm repository from list of active repositories in preferences rendered = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when navigating to preferences containing helm repositories", () => { beforeEach(async () => { builder.preferences.navigate(); diff --git a/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts b/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts index 7d46856fec..f1b7ada401 100644 --- a/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts +++ b/src/features/helm-charts/upgrade-chart/upgrade-chart-new-tab.test.ts @@ -64,6 +64,10 @@ describe("New Upgrade Helm Chart Dock Tab", () => { dockStore.closeTab("terminal"); }); + afterEach(() => { + builder.quit(); + }); + describe("given a namespace is selected", () => { beforeEach(() => { builder.namespaces.select("my-second-namespace"); diff --git a/src/features/helm-releases/showing-details-for-helm-release.test.ts b/src/features/helm-releases/showing-details-for-helm-release.test.ts index 9294b3057e..517c3af1bb 100644 --- a/src/features/helm-releases/showing-details-for-helm-release.test.ts +++ b/src/features/helm-releases/showing-details-for-helm-release.test.ts @@ -83,6 +83,10 @@ describe("showing details for helm release", () => { builder.namespaces.select("some-other-namespace"); }); + afterEach(() => { + builder.quit(); + }); + describe("given application is started", () => { let rendered: RenderResult; diff --git a/src/features/navigate-to-extension-page.test.tsx b/src/features/navigate-to-extension-page.test.tsx index 24f5ec729b..f88f02b5b0 100644 --- a/src/features/navigate-to-extension-page.test.tsx +++ b/src/features/navigate-to-extension-page.test.tsx @@ -9,6 +9,7 @@ import isEmpty from "lodash/isEmpty"; import queryParametersInjectable from "../renderer/routes/query-parameters.injectable"; import currentPathInjectable from "../renderer/routes/current-path.injectable"; import type { IComputedValue } from "mobx"; +import type { ApplicationBuilder } from "../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder"; import type { FakeExtensionOptions } from "../renderer/components/test-utils/get-extension-fake"; import type { LensRendererExtension } from "../extensions/lens-renderer-extension"; @@ -18,9 +19,10 @@ describe("navigate to extension page", () => { let testExtension: LensRendererExtension; let queryParameters: IComputedValue; let currentPath: IComputedValue; + let builder: ApplicationBuilder; beforeEach(async () => { - const builder = getApplicationBuilder(); + builder = getApplicationBuilder(); builder.extensions.enable(extensionWithPagesHavingParameters); @@ -35,6 +37,10 @@ describe("navigate to extension page", () => { currentPath = windowDi.inject(currentPathInjectable); }); + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.container).toMatchSnapshot(); }); diff --git a/src/features/navigating-between-routes.test.tsx b/src/features/navigating-between-routes.test.tsx index cf2dda5cc1..6fe047da22 100644 --- a/src/features/navigating-between-routes.test.tsx +++ b/src/features/navigating-between-routes.test.tsx @@ -27,6 +27,10 @@ describe("navigating between routes", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given route without path parameters", () => { let windowDi: DiContainer; diff --git a/src/features/pod-logs/download-logs.test.tsx b/src/features/pod-logs/download-logs.test.tsx index bfcc859435..d0c17b6536 100644 --- a/src/features/pod-logs/download-logs.test.tsx +++ b/src/features/pod-logs/download-logs.test.tsx @@ -95,11 +95,15 @@ describe("download logs options in logs dock tab", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("opening pod logs", () => { beforeEach(async () => { rendered = await builder.render(); windowDi = builder.applicationWindow.only.di; - + const dockStore = windowDi.inject(dockStoreInjectable); dockStore.closeTab("terminal"); @@ -108,10 +112,10 @@ describe("download logs options in logs dock tab", () => { describe("when logs not available", () => { beforeEach(async () => { const createLogsTab = windowDi.inject(createPodLogsTabInjectable); - + getLogsMock.mockReturnValue([]); getSplittedLogsMock.mockReturnValue([]); - + createLogsTab({ selectedPod: pod, selectedContainer: container, @@ -132,10 +136,10 @@ describe("download logs options in logs dock tab", () => { describe("when logs available", () => { beforeEach(async () => { const createLogsTab = windowDi.inject(createPodLogsTabInjectable); - + getLogsMock.mockReturnValue(["some-logs"]); getSplittedLogsMock.mockReturnValue([...logs]); - + createLogsTab({ selectedPod: pod, selectedContainer: container, @@ -157,7 +161,7 @@ describe("download logs options in logs dock tab", () => { describe("when clicking on dropdown", () => { beforeEach(() => { const button = rendered.getByTestId("download-logs-dropdown"); - + act(() => button.click()); }); @@ -182,7 +186,7 @@ describe("download logs options in logs dock tab", () => { beforeEach(async () => { await act(async () => { const button = rendered.getByTestId("download-all-logs"); - + button.click(); }); }); @@ -193,11 +197,11 @@ describe("download logs options in logs dock tab", () => { { "previous": true, "timestamps": false }, ); }); - + it("shows save dialog with proper attributes", async () => { expect(openSaveFileDialogMock).toHaveBeenCalledWith("dockerExporter.log", "all-logs", "text/plain"); }); - + it("doesn't block download dropdown for interaction after click", async () => { expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled"); }); @@ -206,19 +210,19 @@ describe("download logs options in logs dock tab", () => { describe("blocking user interaction after menu item click", () => { it("block download dropdown for interaction when selected 'download all logs'", async () => { const downloadMenuItem = rendered.getByTestId("download-all-logs"); - + act(() => downloadMenuItem.click()); - + await waitFor(() => { expect(rendered.getByTestId("download-logs-dropdown")).toHaveAttribute("disabled"); }); }); - + it("doesn't block dropdown for interaction when selected 'download visible logs'", () => { const downloadMenuItem = rendered.getByTestId("download-visible-logs"); - + act(() => downloadMenuItem.click()); - + expect(rendered.getByTestId("download-logs-dropdown")).not.toHaveAttribute("disabled"); }); }); @@ -233,7 +237,7 @@ describe("download logs options in logs dock tab", () => { beforeEach(async () => { await act(async () => { const button = rendered.getByTestId("download-all-logs"); - + button.click(); }); }); @@ -241,7 +245,7 @@ describe("download logs options in logs dock tab", () => { it("doesn't show save dialog", () => { expect(openSaveFileDialogMock).not.toHaveBeenCalled(); }); - + it("shows error notification", () => { expect(showErrorNotificationMock).toHaveBeenCalled(); }); @@ -252,23 +256,23 @@ describe("download logs options in logs dock tab", () => { beforeEach(() => { callForLogsMock.mockRejectedValue("error"); }); - + describe("when selected 'download all logs'", () => { beforeEach(async () => { await act(async () => { const button = rendered.getByTestId("download-all-logs"); - + button.click(); }); }); - + it("logs have been called", () => { expect(callForLogsMock).toHaveBeenCalledWith( { name: "dockerExporter", namespace: "default" }, { "previous": true, "timestamps": false }, ); }); - + it("doesn't show save dialog", async () => { expect(openSaveFileDialogMock).not.toHaveBeenCalled(); }); diff --git a/src/features/preferences/closing-preferences.test.tsx b/src/features/preferences/closing-preferences.test.tsx index 7d30400589..d9f7f8ff1c 100644 --- a/src/features/preferences/closing-preferences.test.tsx +++ b/src/features/preferences/closing-preferences.test.tsx @@ -49,6 +49,10 @@ describe("preferences - closing-preferences", () => { }); }); + afterEach(() => { + builder.quit(); + }); + describe("given already in a page and then navigated to preferences", () => { let rendered: RenderResult; let windowDi: DiContainer; diff --git a/src/features/preferences/extension-adding-preference-tabs.test.tsx b/src/features/preferences/extension-adding-preference-tabs.test.tsx index a68f39f547..8d015c9f2d 100644 --- a/src/features/preferences/extension-adding-preference-tabs.test.tsx +++ b/src/features/preferences/extension-adding-preference-tabs.test.tsx @@ -18,6 +18,10 @@ describe("preferences: extension adding preference tabs", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in preferences, when extension with preference tabs is enabled", () => { let rendered: RenderResult; let someObservable: IObservableValue; diff --git a/src/features/preferences/navigation-to-application-preferences.test.tsx b/src/features/preferences/navigation-to-application-preferences.test.tsx index 1176bc984c..b13de1d93d 100644 --- a/src/features/preferences/navigation-to-application-preferences.test.tsx +++ b/src/features/preferences/navigation-to-application-preferences.test.tsx @@ -18,6 +18,10 @@ describe("preferences - navigation to application preferences", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in preferences, when rendered", () => { let rendered: RenderResult; let discover: Discover; @@ -57,8 +61,7 @@ describe("preferences - navigation to application preferences", () => { }); it("shows preference items of the extension as last", () => { - const { attributeValues } = - discover.queryAllElements("preference-item"); + const { attributeValues } = discover.queryAllElements("preference-item"); expect(attributeValues.at(-1)).toBe("preference-item-for-extension-some-test-extension-name-item-some-application-preference-item-id"); }); diff --git a/src/features/preferences/navigation-to-editor-preferences.test.ts b/src/features/preferences/navigation-to-editor-preferences.test.ts index 018a27210a..d478fdd5d0 100644 --- a/src/features/preferences/navigation-to-editor-preferences.test.ts +++ b/src/features/preferences/navigation-to-editor-preferences.test.ts @@ -9,23 +9,26 @@ import type { Discover } from "../../renderer/components/test-utils/discovery-of import { discoverFor } from "../../renderer/components/test-utils/discovery-of-html-elements"; describe("preferences - navigation to editor preferences", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let discover: Discover; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); + }); + + afterEach(() => { + builder.quit(); }); describe("given in preferences, when rendered", () => { let rendered: RenderResult; beforeEach(async () => { - applicationBuilder.beforeWindowStart(() => { - applicationBuilder.preferences.navigate(); + builder.beforeWindowStart(() => { + builder.preferences.navigate(); }); - rendered = await applicationBuilder.render(); - + rendered = await builder.render(); discover = discoverFor(() => rendered); }); @@ -43,7 +46,7 @@ describe("preferences - navigation to editor preferences", () => { describe("when navigating to editor preferences using navigation", () => { beforeEach(() => { - applicationBuilder.preferences.navigation.click("editor"); + builder.preferences.navigation.click("editor"); }); it("renders", () => { diff --git a/src/features/preferences/navigation-to-extension-specific-preferences.test.tsx b/src/features/preferences/navigation-to-extension-specific-preferences.test.tsx index 4480871986..17a03a7a74 100644 --- a/src/features/preferences/navigation-to-extension-specific-preferences.test.tsx +++ b/src/features/preferences/navigation-to-extension-specific-preferences.test.tsx @@ -19,6 +19,10 @@ describe("preferences - navigation to extension specific preferences", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in preferences, when rendered", () => { let rendered: RenderResult; let logErrorMock: jest.Mock; diff --git a/src/features/preferences/navigation-to-kubernetes-preferences.test.ts b/src/features/preferences/navigation-to-kubernetes-preferences.test.ts index 1f4bd9b490..d02bc80532 100644 --- a/src/features/preferences/navigation-to-kubernetes-preferences.test.ts +++ b/src/features/preferences/navigation-to-kubernetes-preferences.test.ts @@ -17,6 +17,10 @@ describe("preferences - navigation to kubernetes preferences", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in preferences, when rendered", () => { let rendered: RenderResult; let discover: Discover; diff --git a/src/features/preferences/navigation-to-proxy-preferences.test.ts b/src/features/preferences/navigation-to-proxy-preferences.test.ts index 2372b78187..3edec4b9fb 100644 --- a/src/features/preferences/navigation-to-proxy-preferences.test.ts +++ b/src/features/preferences/navigation-to-proxy-preferences.test.ts @@ -9,10 +9,14 @@ import type { Discover } from "../../renderer/components/test-utils/discovery-of import { discoverFor } from "../../renderer/components/test-utils/discovery-of-html-elements"; describe("preferences - navigation to proxy preferences", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); + }); + + afterEach(() => { + builder.quit(); }); describe("given in preferences, when rendered", () => { @@ -20,11 +24,11 @@ describe("preferences - navigation to proxy preferences", () => { let discover: Discover; beforeEach(async () => { - applicationBuilder.beforeWindowStart(() => { - applicationBuilder.preferences.navigate(); + builder.beforeWindowStart(() => { + builder.preferences.navigate(); }); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); discover = discoverFor(() => rendered); }); @@ -43,7 +47,7 @@ describe("preferences - navigation to proxy preferences", () => { describe("when navigating to proxy preferences using navigation", () => { beforeEach(() => { - applicationBuilder.preferences.navigation.click("proxy"); + builder.preferences.navigation.click("proxy"); }); it("renders", () => { diff --git a/src/features/preferences/navigation-to-telemetry-preferences.test.tsx b/src/features/preferences/navigation-to-telemetry-preferences.test.tsx index 71d6900f6e..2e18785b0c 100644 --- a/src/features/preferences/navigation-to-telemetry-preferences.test.tsx +++ b/src/features/preferences/navigation-to-telemetry-preferences.test.tsx @@ -19,6 +19,10 @@ describe("preferences - navigation to telemetry preferences", () => { builder = getApplicationBuilder(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in preferences, when rendered", () => { let rendered: RenderResult; let discover: Discover; diff --git a/src/features/preferences/navigation-to-terminal-preferences.test.ts b/src/features/preferences/navigation-to-terminal-preferences.test.ts index 3023852481..5d065555dc 100644 --- a/src/features/preferences/navigation-to-terminal-preferences.test.ts +++ b/src/features/preferences/navigation-to-terminal-preferences.test.ts @@ -9,10 +9,14 @@ import type { Discover } from "../../renderer/components/test-utils/discovery-of import { discoverFor } from "../../renderer/components/test-utils/discovery-of-html-elements"; describe("preferences - navigation to terminal preferences", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); + }); + + afterEach(() => { + builder.quit(); }); describe("given in preferences, when rendered", () => { @@ -20,12 +24,11 @@ describe("preferences - navigation to terminal preferences", () => { let discover: Discover; beforeEach(async () => { - applicationBuilder.beforeWindowStart(() => { - applicationBuilder.preferences.navigate(); + builder.beforeWindowStart(() => { + builder.preferences.navigate(); }); - rendered = await applicationBuilder.render(); - + rendered = await builder.render(); discover = discoverFor(() => rendered); }); @@ -44,7 +47,7 @@ describe("preferences - navigation to terminal preferences", () => { describe("when navigating to terminal preferences using navigation", () => { beforeEach(() => { - applicationBuilder.preferences.navigation.click("terminal"); + builder.preferences.navigation.click("terminal"); }); it("renders", () => { diff --git a/src/features/preferences/navigation-using-application-menu.test.ts b/src/features/preferences/navigation-using-application-menu.test.ts index ae143fe468..c627dc27a6 100644 --- a/src/features/preferences/navigation-using-application-menu.test.ts +++ b/src/features/preferences/navigation-using-application-menu.test.ts @@ -10,17 +10,21 @@ import type { Discover } from "../../renderer/components/test-utils/discovery-of import { discoverFor } from "../../renderer/components/test-utils/discovery-of-html-elements"; describe("preferences - navigation using application menu", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered: RenderResult; let discover: Discover; beforeEach(async () => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); discover = discoverFor(() => rendered); }); + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.container).toMatchSnapshot(); }); @@ -36,7 +40,7 @@ describe("preferences - navigation using application menu", () => { describe("when navigating to preferences using application menu", () => { beforeEach(() => { - applicationBuilder.applicationMenu.click( + builder.applicationMenu.click( "root", "mac", "navigate-to-preferences", diff --git a/src/features/preferences/navigation-using-tray.test.ts b/src/features/preferences/navigation-using-tray.test.ts index e48dba482e..2853ea4c93 100644 --- a/src/features/preferences/navigation-using-tray.test.ts +++ b/src/features/preferences/navigation-using-tray.test.ts @@ -9,17 +9,21 @@ import type { Discover } from "../../renderer/components/test-utils/discovery-of import { discoverFor } from "../../renderer/components/test-utils/discovery-of-html-elements"; describe("show-about-using-tray", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered: RenderResult; let discover: Discover; beforeEach(async () => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); discover = discoverFor(() => rendered); }); + afterEach(() => { + builder.quit(); + }); + it("renders", () => { expect(rendered.baseElement).toMatchSnapshot(); }); @@ -35,7 +39,7 @@ describe("show-about-using-tray", () => { describe("when navigating using tray", () => { beforeEach(async () => { - await applicationBuilder.tray.click("open-preferences"); + await builder.tray.click("open-preferences"); }); it("renders", () => { diff --git a/src/features/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts b/src/features/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts index 23b8d55992..ed56364bf9 100644 --- a/src/features/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts +++ b/src/features/quitting-and-restarting-the-app/opening-application-window-using-tray.test.ts @@ -75,6 +75,10 @@ describe("opening application window using tray", () => { await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + it("only the first application window is open", () => { expectWindowsToBeOpen(["first-application-window"]); }); diff --git a/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts b/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts index a7a6e4ae60..d43edfb5e6 100644 --- a/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts +++ b/src/features/quitting-and-restarting-the-app/quitting-the-app-using-application-menu.test.ts @@ -37,6 +37,10 @@ describe("quitting the app using application menu", () => { await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + it("first application window is open", () => { const windows = builder.applicationWindow.getAll(); diff --git a/src/features/resolve-system-proxy/resolve-system-proxy.test.ts b/src/features/resolve-system-proxy/resolve-system-proxy.test.ts index d2e021ef98..64e3108ec0 100644 --- a/src/features/resolve-system-proxy/resolve-system-proxy.test.ts +++ b/src/features/resolve-system-proxy/resolve-system-proxy.test.ts @@ -31,6 +31,10 @@ describe("resolve-system-proxy", () => { await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("given in main, when called with URL", () => { beforeEach(async () => { const resolveSystemProxyInMain = builder.mainDi.inject( diff --git a/src/features/routes/extension-api/reactively-disable-global-pages.test.tsx b/src/features/routes/extension-api/reactively-disable-global-pages.test.tsx index deb4015480..5772f91b3e 100644 --- a/src/features/routes/extension-api/reactively-disable-global-pages.test.tsx +++ b/src/features/routes/extension-api/reactively-disable-global-pages.test.tsx @@ -43,6 +43,10 @@ describe("reactively disable global pages", () => { rendererTestExtension = builder.extensions.get("test-extension-id").applicationWindows.only; }); + afterEach(() => { + builder.quit(); + }); + it("when navigating to the page, does not show the page", () => { rendererTestExtension.navigate(); diff --git a/src/features/status-bar/status-bar-items-originating-from-extensions.test.tsx b/src/features/status-bar/status-bar-items-originating-from-extensions.test.tsx index a23ffa2dd1..164973fdd9 100644 --- a/src/features/status-bar/status-bar-items-originating-from-extensions.test.tsx +++ b/src/features/status-bar/status-bar-items-originating-from-extensions.test.tsx @@ -11,22 +11,26 @@ import type { FakeExtensionOptions } from "../../renderer/components/test-utils/ import { computed } from "mobx"; describe("status-bar-items-originating-from-extensions", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - applicationBuilder.beforeWindowStart((windowDi) => { + builder.beforeWindowStart((windowDi) => { windowDi.unoverride(getRandomIdInjectable); windowDi.permitSideEffects(getRandomIdInjectable); }); }); + afterEach(() => { + builder.quit(); + }); + describe("when application starts", () => { let rendered: RenderResult; beforeEach(async () => { - rendered = await applicationBuilder.render(); + rendered = await builder.render(); }); it("when multiple extensions with status bar items are loaded, shows items in correct order", () => { @@ -62,7 +66,7 @@ describe("status-bar-items-originating-from-extensions", () => { }, }; - applicationBuilder.extensions.enable(testExtension1, testExtension2); + builder.extensions.enable(testExtension1, testExtension2); const rightSide = rendered.getByTestId("status-bar-right"); @@ -119,7 +123,7 @@ describe("status-bar-items-originating-from-extensions", () => { }, }; - applicationBuilder.extensions.enable(testExtensionOptions); + builder.extensions.enable(testExtensionOptions); }); it("renders", () => { @@ -153,7 +157,7 @@ describe("status-bar-items-originating-from-extensions", () => { }); it("when the extension is removed, shows there are no extension status bar items", () => { - applicationBuilder.extensions.disable(testExtensionOptions); + builder.extensions.disable(testExtensionOptions); const actual = rendered.queryAllByTestId("some-testId"); diff --git a/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap b/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap index 99b888bc11..57c2e1b5cc 100644 --- a/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap +++ b/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap @@ -545,7 +545,7 @@ exports[`test for opening terminal tab within cluster frame when new terminal ta diff --git a/src/features/terminal/opening-terminal-tab.test.tsx b/src/features/terminal/opening-terminal-tab.test.tsx index 49aadb40af..5559fd2cd0 100644 --- a/src/features/terminal/opening-terminal-tab.test.tsx +++ b/src/features/terminal/opening-terminal-tab.test.tsx @@ -32,6 +32,10 @@ describe("test for opening terminal tab within cluster frame", () => { result = await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when new terminal tab is opened", () => { beforeEach(() => { result.getByTestId("dock-tab-for-terminal").click(); diff --git a/src/features/tray/clicking-tray-menu-item-originating-from-extension.test.ts b/src/features/tray/clicking-tray-menu-item-originating-from-extension.test.ts index 4ba4ecbcd7..9c0010d75e 100644 --- a/src/features/tray/clicking-tray-menu-item-originating-from-extension.test.ts +++ b/src/features/tray/clicking-tray-menu-item-originating-from-extension.test.ts @@ -25,6 +25,10 @@ describe("clicking tray menu item originating from extension", () => { await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + describe("when extension is enabled", () => { let someExtension: FakeExtensionOptions; let clickMock: jest.Mock; diff --git a/src/features/tray/extension-adding-tray-items.test.tsx b/src/features/tray/extension-adding-tray-items.test.tsx index 2b640be07c..9a099e1d0f 100644 --- a/src/features/tray/extension-adding-tray-items.test.tsx +++ b/src/features/tray/extension-adding-tray-items.test.tsx @@ -85,6 +85,10 @@ describe("preferences: extension adding tray items", () => { builder.extensions.enable(testExtension); }); + afterEach(() => { + builder.quit(); + }); + describe("given controlled label", () => { it("has the label", () => { const item = builder.tray.get( diff --git a/src/features/tray/multiple-separators-originating-from-extension.test.ts b/src/features/tray/multiple-separators-originating-from-extension.test.ts index fd21d78bae..8747d61d80 100644 --- a/src/features/tray/multiple-separators-originating-from-extension.test.ts +++ b/src/features/tray/multiple-separators-originating-from-extension.test.ts @@ -20,6 +20,10 @@ describe("multiple separators originating from extension", () => { await builder.render(); }); + afterEach(() => { + builder.quit(); + }); + it("given extension with multiple separators, when extension is enabled, does not throw", () => { const someExtension = { id: "some-extension-id", diff --git a/src/features/welcome/navigation-using-application-menu.test.ts b/src/features/welcome/navigation-using-application-menu.test.ts index 02ccf18e40..d5405d1dfe 100644 --- a/src/features/welcome/navigation-using-application-menu.test.ts +++ b/src/features/welcome/navigation-using-application-menu.test.ts @@ -8,13 +8,17 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/ge import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder"; describe("welcome - navigation using application menu", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered: RenderResult; beforeEach(async () => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); - rendered = await applicationBuilder.render(); + rendered = await builder.render(); + }); + + afterEach(() => { + builder.quit(); }); it("renders", () => { @@ -29,7 +33,7 @@ describe("welcome - navigation using application menu", () => { describe("when navigated somewhere else", () => { beforeEach(() => { - applicationBuilder.applicationMenu.click( + builder.applicationMenu.click( "root", "mac", "navigate-to-preferences", @@ -48,7 +52,7 @@ describe("welcome - navigation using application menu", () => { describe("when navigated to welcome using application menu", () => { beforeEach(() => { - applicationBuilder.applicationMenu.click( + builder.applicationMenu.click( "root", "help", "navigate-to-welcome", diff --git a/src/features/welcome/setting-welcome-page.test.tsx b/src/features/welcome/setting-welcome-page.test.tsx index fc5a0fe4a9..34e4025e05 100644 --- a/src/features/welcome/setting-welcome-page.test.tsx +++ b/src/features/welcome/setting-welcome-page.test.tsx @@ -14,29 +14,33 @@ import type { Route } from "../../common/front-end-routing/front-end-route-injec describe("setting-welcome-page", () => { - let applicationBuilder: ApplicationBuilder; + let builder: ApplicationBuilder; let rendered : RenderResult; let welcomeRoute: Route; beforeEach(() => { - applicationBuilder = getApplicationBuilder(); + builder = getApplicationBuilder(); + }); + + afterEach(() => { + builder.quit(); }); describe("given configuration of welcome page route is the default", () => { beforeEach(async () => { - applicationBuilder.beforeApplicationStart((mainDi) => { + builder.beforeApplicationStart((mainDi) => { mainDi.override(welcomeRouteConfigInjectable, () => "/welcome"); }); - applicationBuilder.beforeWindowStart((windowDi) => { + builder.beforeWindowStart((windowDi) => { windowDi.override(welcomeRouteConfigInjectable, () => "/welcome"); }); // enable the extension even though the welcomeRoute is not overriden - applicationBuilder.extensions.enable(extensionWithWelcomePage); - rendered = await applicationBuilder.render(); + builder.extensions.enable(extensionWithWelcomePage); + rendered = await builder.render(); - const windowDi = applicationBuilder.applicationWindow.only.di; + const windowDi = builder.applicationWindow.only.di; welcomeRoute = windowDi.inject(welcomeRouteInjectable); }); @@ -54,18 +58,18 @@ describe("setting-welcome-page", () => { describe("given configuration of welcome page route is set to a custom page", () => { beforeEach(async () => { - applicationBuilder.beforeApplicationStart((mainDi) => { + builder.beforeApplicationStart((mainDi) => { mainDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page"); }); - applicationBuilder.beforeWindowStart((windowDi) => { + builder.beforeWindowStart((windowDi) => { windowDi.override(welcomeRouteConfigInjectable, () => "/extension/some-extension-name/some-welcome-page"); }); - applicationBuilder.extensions.enable(extensionWithWelcomePage); - rendered = await applicationBuilder.render(); + builder.extensions.enable(extensionWithWelcomePage); + rendered = await builder.render(); - const windowDi = applicationBuilder.applicationWindow.only.di; + const windowDi = builder.applicationWindow.only.di; welcomeRoute = windowDi.inject(welcomeRouteInjectable); }); diff --git a/src/main/lens-proxy/stop-proxy-on-quit.injectable.ts b/src/main/lens-proxy/stop-proxy-on-quit.injectable.ts new file mode 100644 index 0000000000..71132527fa --- /dev/null +++ b/src/main/lens-proxy/stop-proxy-on-quit.injectable.ts @@ -0,0 +1,24 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import { beforeQuitOfBackEndInjectionToken } from "../start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; +import lensProxyInjectable from "./lens-proxy.injectable"; + +const stopLensProxyOnQuitInjectable = getInjectable({ + id: "stop-lens-proxy-on-quit", + instantiate: (di) => { + const lensProxy = di.inject(lensProxyInjectable); + + return { + id: "stop-lens-proxy", + run: () => { + lensProxy.close(); + }, + }; + }, + injectionToken: beforeQuitOfBackEndInjectionToken, +}); + +export default stopLensProxyOnQuitInjectable; diff --git a/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts b/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts index a5461862c4..333e3aed08 100644 --- a/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts +++ b/src/main/start-main-application/runnables/setup-lens-proxy.injectable.ts @@ -82,8 +82,6 @@ const setupLensProxyInjectable = getInjectable({ }; }, - // causesSideEffects: true, - injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/src/renderer/components/dock/terminal/terminal.ts b/src/renderer/components/dock/terminal/terminal.ts index b02ac12d5d..22a35d47f1 100644 --- a/src/renderer/components/dock/terminal/terminal.ts +++ b/src/renderer/components/dock/terminal/terminal.ts @@ -176,6 +176,7 @@ export class Terminal { }; onClear = () => { + console.log("clearing"); this.xterm.clear(); }; diff --git a/src/renderer/components/status-bar/status-bar.test.tsx b/src/renderer/components/status-bar/status-bar.test.tsx index 82ce2e2852..8aef89766c 100644 --- a/src/renderer/components/status-bar/status-bar.test.tsx +++ b/src/renderer/components/status-bar/status-bar.test.tsx @@ -39,6 +39,10 @@ describe("", () => { }); }); + afterEach(() => { + builder.quit(); + }); + it("renders w/o errors", async () => { const { container } = await builder.render(); diff --git a/src/renderer/components/test-utils/get-application-builder.tsx b/src/renderer/components/test-utils/get-application-builder.tsx index cb78742482..9e9a1567fd 100644 --- a/src/renderer/components/test-utils/get-application-builder.tsx +++ b/src/renderer/components/test-utils/get-application-builder.tsx @@ -71,6 +71,8 @@ import createClusterInjectable from "../../../main/create-cluster/create-cluster import { onLoadOfApplicationInjectionToken } from "../../../main/start-main-application/runnable-tokens/on-load-of-application-injection-token"; import currentLocationInjectable from "../../api/current-location.injectable"; import lensProxyPortInjectable from "../../../main/lens-proxy/lens-proxy-port.injectable"; +import { runManyFor } from "../../../common/runnable/run-many-for"; +import { beforeQuitOfBackEndInjectionToken } from "../../../main/start-main-application/runnable-tokens/before-quit-of-back-end-injection-token"; type Callback = (di: DiContainer) => void | Promise; @@ -122,6 +124,7 @@ export interface ApplicationBuilder { startHidden: () => Promise; render: () => Promise; + quit: () => void; tray: { click: (id: string) => Promise; @@ -703,6 +706,13 @@ export const getApplicationBuilder = () => { await startApplication({ shouldStartHidden: true }); }, + quit() { + const runMany = runManyFor(builder.mainDi); + const beforeQuitOfBackEnd = runMany(beforeQuitOfBackEndInjectionToken); + + beforeQuitOfBackEnd(); + }, + async render() { await startApplication({ shouldStartHidden: false });