From 17ca80f89503d211eb3ef73d4d7f98d051f89e09 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Fri, 20 May 2022 12:36:27 +0300 Subject: [PATCH] Consolidate usage of channel abstraction to same implementation Signed-off-by: Janne Savolainen --- .../navigation-using-application-menu.test.ts | 2 +- .../app-paths/app-path-injection-token.ts | 3 -- .../app-paths/app-paths-channel.injectable.ts | 22 ++++++++++ .../app-navigation-channel.injectable.ts | 22 ++++++++++ ...ter-frame-navigation-channel.injectable.ts | 22 ++++++++++ .../navigation-ipc-channel.ts | 9 ---- src/common/ipc-channel/channel.ts | 12 ----- .../create-channel/create-channel.ts | 13 ------ .../register-channel.injectable.ts | 3 ++ .../register-channel/register-channel.ts | 8 ++-- .../app-paths/setup-app-paths.injectable.ts | 5 ++- ...alue-from-registered-channel.injectable.ts | 20 --------- .../get-value-from-registered-channel.ts | 16 ------- ...egister-ipc-channel-listener.injectable.ts | 25 ----------- .../app-paths/setup-app-paths.injectable.ts | 33 +++++++++----- .../enlist-channel-listener.injectable.ts | 2 +- .../get-value-from-channel.injectable.ts | 22 ++++++++++ .../ipc-renderer.injectable.ts | 0 .../channel/send-to-main.injectable.ts | 2 +- .../components/+catalog/catalog.test.tsx | 5 --- .../__tests__/dialog.test.tsx | 5 --- .../+role-bindings/__tests__/dialog.test.tsx | 5 --- .../dock/__test__/dock-store.test.ts | 5 --- .../dock/__test__/dock-tabs.test.tsx | 5 --- .../__test__/log-resource-selector.test.tsx | 5 --- .../__tests__/hotbar-remove-command.test.tsx | 5 --- .../components/select/select.test.tsx | 7 +-- .../init-root-frame.injectable.ts | 2 +- src/renderer/getDiForUnitTesting.tsx | 10 ++--- .../ipc-channel-listener-injection-token.ts | 16 ------- ...gister-ipc-channel-listeners.injectable.ts | 28 ------------ .../focus-window.injectable.ts | 0 ...navigation-channel-listener.injectable.ts} | 32 ++++++++------ src/renderer/themes/store.injectable.ts | 2 +- src/test-utils/override-ipc-bridge.ts | 44 ++++++++----------- 35 files changed, 166 insertions(+), 251 deletions(-) create mode 100644 src/common/app-paths/app-paths-channel.injectable.ts create mode 100644 src/common/front-end-routing/app-navigation-channel.injectable.ts create mode 100644 src/common/front-end-routing/cluster-frame-navigation-channel.injectable.ts delete mode 100644 src/common/front-end-routing/navigation-ipc-channel.ts delete mode 100644 src/common/ipc-channel/channel.ts delete mode 100644 src/common/ipc-channel/create-channel/create-channel.ts delete mode 100644 src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.injectable.ts delete mode 100644 src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.ts delete mode 100644 src/renderer/app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable.ts create mode 100644 src/renderer/channel/get-value-from-channel.injectable.ts rename src/renderer/{app-paths/get-value-from-registered-channel/ipc-renderer => channel}/ipc-renderer.injectable.ts (100%) delete mode 100644 src/renderer/ipc-channel-listeners/ipc-channel-listener-injection-token.ts delete mode 100644 src/renderer/ipc-channel-listeners/register-ipc-channel-listeners.injectable.ts rename src/renderer/{ipc-channel-listeners => navigation}/focus-window.injectable.ts (100%) rename src/renderer/{ipc-channel-listeners/navigation-listener.injectable.ts => navigation/navigation-channel-listener.injectable.ts} (53%) diff --git a/src/behaviours/extensions/navigation-using-application-menu.test.ts b/src/behaviours/extensions/navigation-using-application-menu.test.ts index 369f097790..f91d457ddc 100644 --- a/src/behaviours/extensions/navigation-using-application-menu.test.ts +++ b/src/behaviours/extensions/navigation-using-application-menu.test.ts @@ -10,7 +10,7 @@ import extensionsStoreInjectable from "../../extensions/extensions-store/extensi import type { ExtensionsStore } from "../../extensions/extensions-store/extensions-store"; import fileSystemProvisionerStoreInjectable from "../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store.injectable"; import type { FileSystemProvisionerStore } from "../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store"; -import focusWindowInjectable from "../../renderer/ipc-channel-listeners/focus-window.injectable"; +import focusWindowInjectable from "../../renderer/navigation/focus-window.injectable"; // TODO: Make components free of side effects by making them deterministic jest.mock("../../renderer/components/input/input"); diff --git a/src/common/app-paths/app-path-injection-token.ts b/src/common/app-paths/app-path-injection-token.ts index 3b03e44daf..e29bcdbebf 100644 --- a/src/common/app-paths/app-path-injection-token.ts +++ b/src/common/app-paths/app-path-injection-token.ts @@ -4,12 +4,9 @@ */ import { getInjectionToken } from "@ogre-tools/injectable"; import type { PathName } from "./app-path-names"; -import { createChannel } from "../ipc-channel/create-channel/create-channel"; export type AppPaths = Record; export const appPathsInjectionToken = getInjectionToken({ id: "app-paths-token" }); -export const appPathsIpcChannel = createChannel("app-paths"); - diff --git a/src/common/app-paths/app-paths-channel.injectable.ts b/src/common/app-paths/app-paths-channel.injectable.ts new file mode 100644 index 0000000000..4f1836d2bb --- /dev/null +++ b/src/common/app-paths/app-paths-channel.injectable.ts @@ -0,0 +1,22 @@ +/** + * 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 type { Channel } from "../channel/channel-injection-token"; +import { channelInjectionToken } from "../channel/channel-injection-token"; +import type { AppPaths } from "./app-path-injection-token"; + +export type AppPathsChannel = Channel; + +const appPathsChannelInjectable = getInjectable({ + id: "app-paths-channel", + + instantiate: (): AppPathsChannel => ({ + id: "app-paths", + }), + + injectionToken: channelInjectionToken, +}); + +export default appPathsChannelInjectable; diff --git a/src/common/front-end-routing/app-navigation-channel.injectable.ts b/src/common/front-end-routing/app-navigation-channel.injectable.ts new file mode 100644 index 0000000000..95bf8db771 --- /dev/null +++ b/src/common/front-end-routing/app-navigation-channel.injectable.ts @@ -0,0 +1,22 @@ +/** + * 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 type { Channel } from "../channel/channel-injection-token"; +import { channelInjectionToken } from "../channel/channel-injection-token"; +import { IpcRendererNavigationEvents } from "../../renderer/navigation/events"; + +export type AppNavigationChannel = Channel; + +const appNavigationChannelInjectable = getInjectable({ + id: "app-navigation-channel", + + instantiate: (): AppNavigationChannel => ({ + id: IpcRendererNavigationEvents.NAVIGATE_IN_APP, + }), + + injectionToken: channelInjectionToken, +}); + +export default appNavigationChannelInjectable; diff --git a/src/common/front-end-routing/cluster-frame-navigation-channel.injectable.ts b/src/common/front-end-routing/cluster-frame-navigation-channel.injectable.ts new file mode 100644 index 0000000000..cc8704d65e --- /dev/null +++ b/src/common/front-end-routing/cluster-frame-navigation-channel.injectable.ts @@ -0,0 +1,22 @@ +/** + * 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 type { Channel } from "../channel/channel-injection-token"; +import { channelInjectionToken } from "../channel/channel-injection-token"; +import { IpcRendererNavigationEvents } from "../../renderer/navigation/events"; + +export type ClusterFrameNavigationChannel = Channel; + +const clusterFrameNavigationChannelInjectable = getInjectable({ + id: "cluster-frame-navigation-channel", + + instantiate: (): ClusterFrameNavigationChannel => ({ + id: IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER, + }), + + injectionToken: channelInjectionToken, +}); + +export default clusterFrameNavigationChannelInjectable; diff --git a/src/common/front-end-routing/navigation-ipc-channel.ts b/src/common/front-end-routing/navigation-ipc-channel.ts deleted file mode 100644 index 6094664f81..0000000000 --- a/src/common/front-end-routing/navigation-ipc-channel.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { createChannel } from "../ipc-channel/create-channel/create-channel"; -import { IpcRendererNavigationEvents } from "../../renderer/navigation/events"; - -export const appNavigationIpcChannel = createChannel(IpcRendererNavigationEvents.NAVIGATE_IN_APP); -export const clusterFrameNavigationIpcChannel = createChannel(IpcRendererNavigationEvents.NAVIGATE_IN_CLUSTER); diff --git a/src/common/ipc-channel/channel.ts b/src/common/ipc-channel/channel.ts deleted file mode 100644 index dfc2f2fcc6..0000000000 --- a/src/common/ipc-channel/channel.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ - -/** - * @deprecated Switch to using newer version of Channel abstraction - */ -export interface Channel { - name: string; - _template: TInstance; -} diff --git a/src/common/ipc-channel/create-channel/create-channel.ts b/src/common/ipc-channel/create-channel/create-channel.ts deleted file mode 100644 index 403bc1dcc0..0000000000 --- a/src/common/ipc-channel/create-channel/create-channel.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import type { Channel } from "../channel"; - -/** - * @deprecated Switch to using newer version of Channel abstraction - */ -export const createChannel = (name: string): Channel => ({ - name, - _template: null as never, -}); diff --git a/src/main/app-paths/register-channel/register-channel.injectable.ts b/src/main/app-paths/register-channel/register-channel.injectable.ts index d0b517cf25..379fb15975 100644 --- a/src/main/app-paths/register-channel/register-channel.injectable.ts +++ b/src/main/app-paths/register-channel/register-channel.injectable.ts @@ -6,6 +6,9 @@ import { getInjectable } from "@ogre-tools/injectable"; import ipcMainInjectable from "./ipc-main/ipc-main.injectable"; import { registerChannel } from "./register-channel"; +/** + * @deprecated Switch to using channelListenerInjectionToken + */ const registerChannelInjectable = getInjectable({ id: "register-channel", diff --git a/src/main/app-paths/register-channel/register-channel.ts b/src/main/app-paths/register-channel/register-channel.ts index 73f3e13243..ac3dfcb509 100644 --- a/src/main/app-paths/register-channel/register-channel.ts +++ b/src/main/app-paths/register-channel/register-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { IpcMain } from "electron"; -import type { Channel } from "../../../common/ipc-channel/channel"; +import type { Channel } from "../../../common/channel/channel-injection-token"; interface Dependencies { ipcMain: IpcMain; @@ -11,8 +11,8 @@ interface Dependencies { export const registerChannel = ({ ipcMain }: Dependencies) => - , TInstance>( + >( channel: TChannel, - getValue: () => TInstance, + getValue: () => TChannel["_messageTemplate"], ) => - ipcMain.handle(channel.name, getValue); + ipcMain.handle(channel.id, getValue); diff --git a/src/main/app-paths/setup-app-paths.injectable.ts b/src/main/app-paths/setup-app-paths.injectable.ts index 9a4283f063..910aa29477 100644 --- a/src/main/app-paths/setup-app-paths.injectable.ts +++ b/src/main/app-paths/setup-app-paths.injectable.ts @@ -12,10 +12,10 @@ import appPathsStateInjectable from "../../common/app-paths/app-paths-state.inje import { pathNames } from "../../common/app-paths/app-path-names"; import { fromPairs, map } from "lodash/fp"; import { pipeline } from "@ogre-tools/fp"; -import { appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token"; import registerChannelInjectable from "./register-channel/register-channel.injectable"; import joinPathsInjectable from "../../common/path/join-paths.injectable"; import { beforeElectronIsReadyInjectionToken } from "../start-main-application/runnable-tokens/before-electron-is-ready-injection-token"; +import appPathsChannelInjectable from "../../common/app-paths/app-paths-channel.injectable"; const setupAppPathsInjectable = getInjectable({ id: "setup-app-paths", @@ -26,6 +26,7 @@ const setupAppPathsInjectable = getInjectable({ const getAppPath = di.inject(getElectronAppPathInjectable); const appPathsState = di.inject(appPathsStateInjectable); const registerChannel = di.inject(registerChannelInjectable); + const appPathsChannel = di.inject(appPathsChannelInjectable); const directoryForIntegrationTesting = di.inject(directoryForIntegrationTestingInjectable); const joinPaths = di.inject(joinPathsInjectable); @@ -47,7 +48,7 @@ const setupAppPathsInjectable = getInjectable({ appPathsState.set(appPaths); - registerChannel(appPathsIpcChannel, () => appPaths); + registerChannel(appPathsChannel, () => appPaths); }, }; }, diff --git a/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.injectable.ts b/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.injectable.ts deleted file mode 100644 index b9ddee1007..0000000000 --- a/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.injectable.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * 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 ipcRendererInjectable from "./ipc-renderer/ipc-renderer.injectable"; -import { getValueFromRegisteredChannel } from "./get-value-from-registered-channel"; -import type { Channel } from "../../../common/ipc-channel/channel"; - -export type GetValueFromRegisteredChannel = , TInstance>(channel: TChannel) => Promise; - -const getValueFromRegisteredChannelInjectable = getInjectable({ - id: "get-value-from-registered-channel", - - instantiate: (di) => getValueFromRegisteredChannel({ - ipcRenderer: di.inject(ipcRendererInjectable), - }), -}); - -export default getValueFromRegisteredChannelInjectable; diff --git a/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.ts b/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.ts deleted file mode 100644 index 8e0c953784..0000000000 --- a/src/renderer/app-paths/get-value-from-registered-channel/get-value-from-registered-channel.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import type { IpcRenderer } from "electron"; -import type { Channel } from "../../../common/ipc-channel/channel"; - -interface Dependencies { - ipcRenderer: IpcRenderer; -} - -export const getValueFromRegisteredChannel = ({ ipcRenderer }: Dependencies) => - , TInstance>( - channel: TChannel, - ): Promise => - ipcRenderer.invoke(channel.name); diff --git a/src/renderer/app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable.ts b/src/renderer/app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable.ts deleted file mode 100644 index 151d77f097..0000000000 --- a/src/renderer/app-paths/get-value-from-registered-channel/register-ipc-channel-listener.injectable.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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 ipcRendererInjectable from "./ipc-renderer/ipc-renderer.injectable"; -import type { - IpcChannelListener, -} from "../../ipc-channel-listeners/ipc-channel-listener-injection-token"; - -const registerIpcChannelListenerInjectable = getInjectable({ - id: "register-ipc-channel-listener", - - instantiate: (di) => { - const ipc = di.inject(ipcRendererInjectable); - - return ({ channel, handle }: IpcChannelListener) => { - ipc.on(channel.name, (_, data) => { - handle(data); - }); - }; - }, -}); - -export default registerIpcChannelListenerInjectable; diff --git a/src/renderer/app-paths/setup-app-paths.injectable.ts b/src/renderer/app-paths/setup-app-paths.injectable.ts index e6cf30f0dd..2babf95019 100644 --- a/src/renderer/app-paths/setup-app-paths.injectable.ts +++ b/src/renderer/app-paths/setup-app-paths.injectable.ts @@ -3,27 +3,36 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import { appPathsIpcChannel } from "../../common/app-paths/app-path-injection-token"; -import getValueFromRegisteredChannelInjectable from "./get-value-from-registered-channel/get-value-from-registered-channel.injectable"; +import getValueFromChannelInjectable from "../channel/get-value-from-channel.injectable"; import appPathsStateInjectable from "../../common/app-paths/app-paths-state.injectable"; import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token"; +import appPathsChannelInjectable from "../../common/app-paths/app-paths-channel.injectable"; +import assert from "assert"; const setupAppPathsInjectable = getInjectable({ id: "setup-app-paths", - instantiate: (di) => ({ - run: async () => { - const getValueFromRegisteredChannel = di.inject( - getValueFromRegisteredChannelInjectable, - ); + instantiate: (di) => { + const getValueFromChannel = di.inject( + getValueFromChannelInjectable, + ); - const syncAppPaths = await getValueFromRegisteredChannel(appPathsIpcChannel); + const appPathsChannel = di.inject(appPathsChannelInjectable); - const appPathsState = di.inject(appPathsStateInjectable); + return { + run: async () => { + const appPaths = await getValueFromChannel( + appPathsChannel, + ); - appPathsState.set(syncAppPaths); - }, - }), + assert(appPaths); + + const appPathsState = di.inject(appPathsStateInjectable); + + appPathsState.set(appPaths); + }, + }; + }, injectionToken: beforeFrameStartsInjectionToken, }); diff --git a/src/renderer/channel/channel-listeners/enlist-channel-listener.injectable.ts b/src/renderer/channel/channel-listeners/enlist-channel-listener.injectable.ts index 0cc8a5c854..415980e1b9 100644 --- a/src/renderer/channel/channel-listeners/enlist-channel-listener.injectable.ts +++ b/src/renderer/channel/channel-listeners/enlist-channel-listener.injectable.ts @@ -2,7 +2,7 @@ * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ -import ipcRendererInjectable from "../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; +import ipcRendererInjectable from "../ipc-renderer.injectable"; import { getInjectable } from "@ogre-tools/injectable"; import type { IpcRendererEvent } from "electron"; import { enlistChannelListenerInjectionToken } from "../../../common/channel/enlist-channel-listener-injection-token"; diff --git a/src/renderer/channel/get-value-from-channel.injectable.ts b/src/renderer/channel/get-value-from-channel.injectable.ts new file mode 100644 index 0000000000..060800eba0 --- /dev/null +++ b/src/renderer/channel/get-value-from-channel.injectable.ts @@ -0,0 +1,22 @@ +/** + * 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 ipcRendererInjectable from "./ipc-renderer.injectable"; +import type { Channel } from "../../common/channel/channel-injection-token"; + +const getValueFromChannelInjectable = getInjectable({ + id: "get-value-from-channel", + + instantiate: (di) => { + const ipcRenderer = di.inject(ipcRendererInjectable); + + return >( + channel: TChannel, + ): Promise => + ipcRenderer.invoke(channel.id); + }, +}); + +export default getValueFromChannelInjectable; diff --git a/src/renderer/app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable.ts b/src/renderer/channel/ipc-renderer.injectable.ts similarity index 100% rename from src/renderer/app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable.ts rename to src/renderer/channel/ipc-renderer.injectable.ts diff --git a/src/renderer/channel/send-to-main.injectable.ts b/src/renderer/channel/send-to-main.injectable.ts index 80223ef56d..6eb4540062 100644 --- a/src/renderer/channel/send-to-main.injectable.ts +++ b/src/renderer/channel/send-to-main.injectable.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import ipcRendererInjectable from "../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; +import ipcRendererInjectable from "./ipc-renderer.injectable"; const sendToMainInjectable = getInjectable({ id: "send-to-main", diff --git a/src/renderer/components/+catalog/catalog.test.tsx b/src/renderer/components/+catalog/catalog.test.tsx index 0c61c73dcf..808226727c 100644 --- a/src/renderer/components/+catalog/catalog.test.tsx +++ b/src/renderer/components/+catalog/catalog.test.tsx @@ -26,7 +26,6 @@ import appVersionInjectable from "../../../common/get-configuration-file-model/a import type { AppEvent } from "../../../common/app-event-bus/event-bus"; import appEventBusInjectable from "../../../common/app-event-bus/app-event-bus.injectable"; import { computed } from "mobx"; -import ipcRendererInjectable from "../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; import broadcastMessageInjectable from "../../../common/ipc/broadcast-message.injectable"; mockWindow(); @@ -107,10 +106,6 @@ describe("", () => { catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable); di.override(catalogEntityRegistryInjectable, () => catalogEntityRegistry); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); emitEvent = jest.fn(); diff --git a/src/renderer/components/+user-management/+cluster-role-bindings/__tests__/dialog.test.tsx b/src/renderer/components/+user-management/+cluster-role-bindings/__tests__/dialog.test.tsx index e221c008ac..0d6b3fab6f 100644 --- a/src/renderer/components/+user-management/+cluster-role-bindings/__tests__/dialog.test.tsx +++ b/src/renderer/components/+user-management/+cluster-role-bindings/__tests__/dialog.test.tsx @@ -12,7 +12,6 @@ import type { DiRender } from "../../../test-utils/renderFor"; import { renderFor } from "../../../test-utils/renderFor"; import clusterRoleStoreInjectable from "../../+cluster-roles/store.injectable"; import storesAndApisCanBeCreatedInjectable from "../../../../stores-apis-can-be-created.injectable"; -import ipcRendererInjectable from "../../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; describe("ClusterRoleBindingDialog tests", () => { let render: DiRender; @@ -21,10 +20,6 @@ describe("ClusterRoleBindingDialog tests", () => { const di = getDiForUnitTesting({ doGeneralOverrides: true }); di.override(storesAndApisCanBeCreatedInjectable, () => true); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); render = renderFor(di); diff --git a/src/renderer/components/+user-management/+role-bindings/__tests__/dialog.test.tsx b/src/renderer/components/+user-management/+role-bindings/__tests__/dialog.test.tsx index 969de55ea4..82e3a7c9d7 100644 --- a/src/renderer/components/+user-management/+role-bindings/__tests__/dialog.test.tsx +++ b/src/renderer/components/+user-management/+role-bindings/__tests__/dialog.test.tsx @@ -13,7 +13,6 @@ import { renderFor } from "../../../test-utils/renderFor"; import directoryForUserDataInjectable from "../../../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable"; import clusterRoleStoreInjectable from "../../+cluster-roles/store.injectable"; import storesAndApisCanBeCreatedInjectable from "../../../../stores-apis-can-be-created.injectable"; -import ipcRendererInjectable from "../../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; describe("RoleBindingDialog tests", () => { let render: DiRender; @@ -23,10 +22,6 @@ describe("RoleBindingDialog tests", () => { di.override(storesAndApisCanBeCreatedInjectable, () => true); di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data"); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); render = renderFor(di); diff --git a/src/renderer/components/dock/__test__/dock-store.test.ts b/src/renderer/components/dock/__test__/dock-store.test.ts index e554b4dcdc..c9191c4928 100644 --- a/src/renderer/components/dock/__test__/dock-store.test.ts +++ b/src/renderer/components/dock/__test__/dock-store.test.ts @@ -5,7 +5,6 @@ import directoryForUserDataInjectable from "../../../../common/app-paths/directory-for-user-data/directory-for-user-data.injectable"; import hostedClusterIdInjectable from "../../../../common/cluster-store/hosted-cluster-id.injectable"; -import ipcRendererInjectable from "../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; import { getDiForUnitTesting } from "../../../getDiForUnitTesting"; import type { DockStore, DockTab } from "../dock/store"; import { TabKind } from "../dock/store"; @@ -26,10 +25,6 @@ describe("DockStore", () => { const di = getDiForUnitTesting({ doGeneralOverrides: true }); di.override(hostedClusterIdInjectable, () => "some-cluster-id"); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data"); dockStore = di.inject(dockStoreInjectable); diff --git a/src/renderer/components/dock/__test__/dock-tabs.test.tsx b/src/renderer/components/dock/__test__/dock-tabs.test.tsx index df9fc08ce2..aa4f755943 100644 --- a/src/renderer/components/dock/__test__/dock-tabs.test.tsx +++ b/src/renderer/components/dock/__test__/dock-tabs.test.tsx @@ -20,7 +20,6 @@ import getConfigurationFileModelInjectable from "../../../../common/get-configur import appVersionInjectable from "../../../../common/get-configuration-file-model/app-version/app-version.injectable"; import assert from "assert"; import hostedClusterIdInjectable from "../../../../common/cluster-store/hosted-cluster-id.injectable"; -import ipcRendererInjectable from "../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; jest.mock("electron", () => ({ app: { @@ -83,10 +82,6 @@ describe("", () => { directoryForUserDataInjectable, () => "some-test-suite-specific-directory-for-user-data", ); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); di.permitSideEffects(getConfigurationFileModelInjectable); di.permitSideEffects(appVersionInjectable); diff --git a/src/renderer/components/dock/logs/__test__/log-resource-selector.test.tsx b/src/renderer/components/dock/logs/__test__/log-resource-selector.test.tsx index c886b195cd..5fd6161052 100644 --- a/src/renderer/components/dock/logs/__test__/log-resource-selector.test.tsx +++ b/src/renderer/components/dock/logs/__test__/log-resource-selector.test.tsx @@ -22,7 +22,6 @@ import { SearchStore } from "../../../../search-store/search-store"; import getConfigurationFileModelInjectable from "../../../../../common/get-configuration-file-model/get-configuration-file-model.injectable"; import appVersionInjectable from "../../../../../common/get-configuration-file-model/app-version/app-version.injectable"; import assert from "assert"; -import ipcRendererInjectable from "../../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; jest.mock("electron", () => ({ app: { @@ -132,10 +131,6 @@ describe("", () => { di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data"); di.override(callForLogsInjectable, () => () => Promise.resolve("some-logs")); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); di.permitSideEffects(getConfigurationFileModelInjectable); di.permitSideEffects(appVersionInjectable); diff --git a/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx b/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx index c7ce186afb..48ee9e63b4 100644 --- a/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx +++ b/src/renderer/components/hotbar/__tests__/hotbar-remove-command.test.tsx @@ -19,7 +19,6 @@ import getConfigurationFileModelInjectable from "../../../../common/get-configur import appVersionInjectable from "../../../../common/get-configuration-file-model/app-version/app-version.injectable"; import type { HotbarStore } from "../../../../common/hotbars/store"; import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable"; -import ipcRendererInjectable from "../../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; const mockHotbars: Partial> = { "1": { @@ -47,10 +46,6 @@ describe("", () => { di.override(storesAndApisCanBeCreatedInjectable, () => true); di.override(directoryForUserDataInjectable, () => "some-directory-for-user-data"); - di.override(ipcRendererInjectable, () => ({ - on: jest.fn(), - invoke: jest.fn(), // TODO: replace with proper mocking via the IPC bridge - } as never)); di.permitSideEffects(hotbarStoreInjectable); di.permitSideEffects(getConfigurationFileModelInjectable); diff --git a/src/renderer/components/select/select.test.tsx b/src/renderer/components/select/select.test.tsx index 90506c511f..d9bd53190a 100644 --- a/src/renderer/components/select/select.test.tsx +++ b/src/renderer/components/select/select.test.tsx @@ -17,7 +17,6 @@ import { computed } from "mobx"; import type { LensRendererExtension } from "../../../extensions/lens-renderer-extension"; import getConfigurationFileModelInjectable from "../../../common/get-configuration-file-model/get-configuration-file-model.injectable"; import appVersionInjectable from "../../../common/get-configuration-file-model/app-version/app-version.injectable"; -import ipcRendererInjectable from "../../app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable"; jest.mock("electron", () => ({ ipcRenderer: { @@ -38,11 +37,7 @@ describe("