mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Re-enable communicating from main to cluster frames
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
11 files changed
+211
-54
No files matched your search
+25
@@ -0,0 +1,25 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { onLoadOfApplicationInjectionToken } from "@k8slens/application";
|
||||
import { getMessageChannel, sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
|
||||
export const frameCommunicationAdminChannel = getMessageChannel<undefined>(
|
||||
"frame-communication-admin-channel",
|
||||
);
|
||||
|
||||
const allowCommunicationToIframeInjectable = getInjectable({
|
||||
id: "allow-communication-to-iframe-injectable",
|
||||
|
||||
instantiate: (di) => {
|
||||
const sendMessageToChannel = di.inject(sendMessageToChannelInjectionToken);
|
||||
|
||||
return {
|
||||
run: () => {
|
||||
sendMessageToChannel(frameCommunicationAdminChannel);
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
|
||||
export default allowCommunicationToIframeInjectable;
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
import { createContainer, DiContainer } from "@ogre-tools/injectable";
|
||||
import { registerMobX } from "@ogre-tools/injectable-extension-for-mobx";
|
||||
import { startApplicationInjectionToken } from "@k8slens/application";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { messagingFeatureForRenderer } from "./feature";
|
||||
import { runInAction } from "mobx";
|
||||
import ipcRendererInjectable from "./ipc/ipc-renderer.injectable";
|
||||
import { sendMessageToChannelInjectionToken } from "@k8slens/messaging";
|
||||
import { frameCommunicationAdminChannel } from "./allow-communication-to-iframe.injectable";
|
||||
|
||||
describe("allow communication to iframe", () => {
|
||||
let di: DiContainer;
|
||||
let sendMessageToChannelMock: jest.Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
di = createContainer("irrelevant");
|
||||
|
||||
registerMobX(di);
|
||||
|
||||
runInAction(() => {
|
||||
registerFeature(di, messagingFeatureForRenderer);
|
||||
});
|
||||
|
||||
di.override(ipcRendererInjectable, () => ({ on: () => {} } as unknown));
|
||||
|
||||
sendMessageToChannelMock = jest.fn();
|
||||
di.override(sendMessageToChannelInjectionToken, () => sendMessageToChannelMock);
|
||||
});
|
||||
|
||||
it("when application starts, sends message to communication channel to register the frame ID and process ID for further usage", async () => {
|
||||
await di.inject(startApplicationInjectionToken)();
|
||||
|
||||
expect(sendMessageToChannelMock).toHaveBeenCalledWith(frameCommunicationAdminChannel);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user