From ad31b732644a39af8652ebed8ff5db3cb1eaa562 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 2 Dec 2022 04:53:00 -0800 Subject: [PATCH] Fix not being able to add custom helm repos (#6692) * Add missing safety checks in unit tests for structured clone issues Signed-off-by: Sebastian Malton * Fix not being able to add custom helm repos Signed-off-by: Sebastian Malton Signed-off-by: Sebastian Malton --- .../adding-of-custom-helm-repository-dialog-content.tsx | 3 ++- .../override-messaging-from-window-to-main.ts | 7 +++++++ .../override-requesting-from-window-to-main.ts | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/features/helm-charts/child-features/preferences/renderer/adding-of-custom-helm-repository/adding-of-custom-helm-repository-dialog-content.tsx b/src/features/helm-charts/child-features/preferences/renderer/adding-of-custom-helm-repository/adding-of-custom-helm-repository-dialog-content.tsx index 005dcace98..f0595bbbc7 100644 --- a/src/features/helm-charts/child-features/preferences/renderer/adding-of-custom-helm-repository/adding-of-custom-helm-repository-dialog-content.tsx +++ b/src/features/helm-charts/child-features/preferences/renderer/adding-of-custom-helm-repository/adding-of-custom-helm-repository-dialog-content.tsx @@ -23,6 +23,7 @@ import maximalCustomHelmRepoOptionsAreShownInjectable from "./maximal-custom-hel import { SubTitle } from "../../../../../../renderer/components/layout/sub-title"; import { Checkbox } from "../../../../../../renderer/components/checkbox"; import { HelmFileInput } from "./helm-file-input/helm-file-input"; +import { toJS } from "../../../../../../common/utils"; interface Dependencies { helmRepo: HelmRepo; @@ -36,7 +37,7 @@ const NonInjectedActivationOfCustomHelmRepositoryDialogContent = observer(({ hel submitCustomRepository(helmRepo)} + next={() => submitCustomRepository(toJS(helmRepo))} testIdForNext="custom-helm-repository-submit-button" testIdForPrev="custom-helm-repository-cancel-button" > diff --git a/src/test-utils/channel-fakes/override-messaging-from-window-to-main.ts b/src/test-utils/channel-fakes/override-messaging-from-window-to-main.ts index f00f4e626c..c39731ac8e 100644 --- a/src/test-utils/channel-fakes/override-messaging-from-window-to-main.ts +++ b/src/test-utils/channel-fakes/override-messaging-from-window-to-main.ts @@ -3,6 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { DiContainer } from "@ogre-tools/injectable"; +import { deserialize, serialize } from "v8"; import type { MessageChannel, MessageChannelListener } from "../../common/utils/channel/message-channel-listener-injection-token"; import enlistMessageChannelListenerInjectableInMain from "../../main/utils/channel/channel-listeners/enlist-message-channel-listener.injectable"; import { getOrInsertSet } from "../../renderer/utils"; @@ -40,6 +41,12 @@ export const overrideMessagingFromWindowToMain = (mainDi: DiContainer) => { ); } + try { + message = deserialize(serialize(message)); + } catch (error) { + throw new Error(`Tried to send a message to channel "${channelId}" that is not compatible with StructuredClone: ${error}`); + } + listeners.forEach((listener) => listener.handler(message)); }); }; diff --git a/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts b/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts index ddf758f5b6..70526bd84c 100644 --- a/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts +++ b/src/test-utils/channel-fakes/override-requesting-from-window-to-main.ts @@ -3,6 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { DiContainer } from "@ogre-tools/injectable"; +import { deserialize, serialize } from "v8"; import type { RequestChannel } from "../../common/utils/channel/request-channel-listener-injection-token"; import type { RequestFromChannel } from "../../common/utils/channel/request-from-channel-injection-token"; import enlistRequestChannelListenerInjectableInMain from "../../main/utils/channel/channel-listeners/enlist-request-channel-listener.injectable"; @@ -46,6 +47,12 @@ export const overrideRequestingFromWindowToMain = (mainDi: DiContainer) => { ); } + try { + request = deserialize(serialize(request)); + } catch (error) { + throw new Error(`Tried to request from channel "${channel.id}" with data that is not compatible with StructuredClone: ${error}`); + } + return requestListener.handler(request); }) as RequestFromChannel, );