diff --git a/package.json b/package.json index 8a4d81867f..ae9cba1f1c 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,7 @@ "/packages" ], "setupFiles": [ - "/src/jest.setup.ts", - "jest-canvas-mock" + "/src/jest.setup.ts" ], "globalSetup": "/src/jest.timezone.ts", "setupFilesAfterEnv": [ @@ -265,7 +264,7 @@ "immer": "^9.0.17", "joi": "^17.7.0", "js-yaml": "^4.1.0", - "jsdom": "^16.7.0", + "jsdom": "^20.0.1", "lodash": "^4.17.15", "marked": "^4.2.5", "md5-file": "^5.0.0", @@ -335,6 +334,7 @@ "@types/html-webpack-plugin": "^3.2.6", "@types/http-proxy": "^1.17.9", "@types/jest": "^28.1.6", + "@types/jest-image-snapshot": "^5.1.0", "@types/js-yaml": "^4.0.5", "@types/jsdom": "^16.2.14", "@types/lodash": "^4.14.191", @@ -375,6 +375,7 @@ "adr": "^1.4.3", "ansi_up": "^5.1.0", "chalk": "^4.1.2", + "canvas": "^2.10.1", "chart.js": "^2.9.4", "circular-dependency-plugin": "^5.2.2", "cli-progress": "^3.11.2", @@ -403,8 +404,8 @@ "ignore-loader": "^0.1.2", "include-media": "^1.4.9", "jest": "^28.1.3", - "jest-canvas-mock": "^2.3.1", "jest-environment-jsdom": "^28.1.3", + "jest-image-snapshot": "^5.2.0", "jest-mock-extended": "^2.0.9", "make-plural": "^6.2.2", "memfs": "^3.4.12", diff --git a/src/common/app-paths/app-paths-channel.ts b/src/common/app-paths/app-paths-channel.ts index 4502569d3b..6dda5d6f4f 100644 --- a/src/common/app-paths/app-paths-channel.ts +++ b/src/common/app-paths/app-paths-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { AppPaths } from "./app-path-injection-token"; -import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../utils/channel/request-channel"; export type AppPathsChannel = RequestChannel; diff --git a/src/common/helm/add-helm-repository-channel.ts b/src/common/helm/add-helm-repository-channel.ts index bf5aa19367..48ad22b22b 100644 --- a/src/common/helm/add-helm-repository-channel.ts +++ b/src/common/helm/add-helm-repository-channel.ts @@ -4,7 +4,7 @@ */ import type { HelmRepo } from "./helm-repo"; import type { AsyncResult } from "../utils/async-result"; -import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../utils/channel/request-channel"; export type AddHelmRepositoryChannel = RequestChannel>; diff --git a/src/common/helm/get-active-helm-repositories-channel.ts b/src/common/helm/get-active-helm-repositories-channel.ts index 26720e9a5f..a0ce7c7b06 100644 --- a/src/common/helm/get-active-helm-repositories-channel.ts +++ b/src/common/helm/get-active-helm-repositories-channel.ts @@ -4,7 +4,7 @@ */ import type { HelmRepo } from "./helm-repo"; import type { AsyncResult } from "../utils/async-result"; -import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../utils/channel/request-channel"; export type GetActiveHelmRepositoriesChannel = RequestChannel>; diff --git a/src/common/helm/remove-helm-repository-channel.ts b/src/common/helm/remove-helm-repository-channel.ts index 4d479d088c..1b9c670371 100644 --- a/src/common/helm/remove-helm-repository-channel.ts +++ b/src/common/helm/remove-helm-repository-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { AsyncResult } from "../utils/async-result"; -import type { RequestChannel } from "../utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../utils/channel/request-channel"; import type { HelmRepo } from "./helm-repo"; export type RemoveHelmRepositoryChannel = RequestChannel>; diff --git a/src/common/logger.ts b/src/common/logger.ts index ad81271bfa..f18fb4c025 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -5,9 +5,9 @@ export interface Logger { - info: (message: string, ...args: any) => void; - error: (message: string, ...args: any) => void; - debug: (message: string, ...args: any) => void; - warn: (message: string, ...args: any) => void; - silly: (message: string, ...args: any) => void; + info: (message: string, ...args: any[]) => void; + error: (message: string, ...args: any[]) => void; + debug: (message: string, ...args: any[]) => void; + warn: (message: string, ...args: any[]) => void; + silly: (message: string, ...args: any[]) => void; } diff --git a/src/common/utils/channel/channel.test.ts b/src/common/utils/channel/channel.test.ts index 9a361b6770..7f2eb69787 100644 --- a/src/common/utils/channel/channel.test.ts +++ b/src/common/utils/channel/channel.test.ts @@ -11,15 +11,15 @@ import { getApplicationBuilder } from "../../../renderer/components/test-utils/g import type { LensWindow } from "../../../main/start-main-application/lens-window/application-window/create-lens-window.injectable"; import type { MessageChannel } from "./message-channel-listener-injection-token"; import { messageChannelListenerInjectionToken } from "./message-channel-listener-injection-token"; -import type { RequestFromChannel } from "./request-from-channel-injection-token"; -import { requestFromChannelInjectionToken } from "./request-from-channel-injection-token"; -import type { RequestChannel } from "./request-channel-listener-injection-token"; +import type { RequestChannel } from "./request-channel"; import type { AsyncFnMock } from "@async-fn/jest"; import asyncFn from "@async-fn/jest"; import { getPromiseStatus } from "../../test-utils/get-promise-status"; import { runInAction } from "mobx"; import type { RequestChannelHandler } from "../../../main/utils/channel/channel-listeners/listener-tokens"; import { getRequestChannelListenerInjectable } from "../../../main/utils/channel/channel-listeners/listener-tokens"; +import type { RequestFromChannel } from "../../../renderer/utils/channel/request-from-channel.injectable"; +import requestFromChannelInjectable from "../../../renderer/utils/channel/request-from-channel.injectable"; type TestMessageChannel = MessageChannel; type TestRequestChannel = RequestChannel; @@ -164,9 +164,7 @@ describe("channel", () => { const windowDi = applicationBuilder.applicationWindow.only.di; - requestFromChannel = windowDi.inject( - requestFromChannelInjectionToken, - ); + requestFromChannel = windowDi.inject(requestFromChannelInjectable); }); describe("when requesting from channel", () => { diff --git a/src/common/utils/channel/request-channel-listener-injection-token.ts b/src/common/utils/channel/request-channel.ts similarity index 61% rename from src/common/utils/channel/request-channel-listener-injection-token.ts rename to src/common/utils/channel/request-channel.ts index 2f0b84a3cc..ec78f046eb 100644 --- a/src/common/utils/channel/request-channel-listener-injection-token.ts +++ b/src/common/utils/channel/request-channel.ts @@ -8,3 +8,11 @@ export interface RequestChannel { _requestSignature?: Request; // used only to mark `Request` as "used" _responseSignature?: Response; // used only to mark `Response` as "used" } + +export type ChannelRequest = Channel extends RequestChannel + ? Request + : never; + +export type ChannelResponse = Channel extends RequestChannel + ? Response + : never; diff --git a/src/common/utils/channel/request-from-channel-injection-token.ts b/src/common/utils/channel/request-from-channel-injection-token.ts deleted file mode 100644 index 14e925f190..0000000000 --- a/src/common/utils/channel/request-from-channel-injection-token.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) OpenLens Authors. All rights reserved. - * Licensed under MIT License. See LICENSE in root directory for more information. - */ -import { getInjectionToken } from "@ogre-tools/injectable"; -import type { RequestChannel } from "./request-channel-listener-injection-token"; - -export interface RequestFromChannel { - (channel: RequestChannel, request: Request): Promise; - (channel: RequestChannel): Promise; -} - -export const requestFromChannelInjectionToken = getInjectionToken({ - id: "request-from-request-channel", -}); diff --git a/src/common/utils/resolve-system-proxy/resolve-system-proxy-channel.ts b/src/common/utils/resolve-system-proxy/resolve-system-proxy-channel.ts index c823a8a8f9..08e1ab1be7 100644 --- a/src/common/utils/resolve-system-proxy/resolve-system-proxy-channel.ts +++ b/src/common/utils/resolve-system-proxy/resolve-system-proxy-channel.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 type { RequestChannel } from "../channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../channel/request-channel"; export type ResolveSystemProxyChannel = RequestChannel; diff --git a/src/common/utils/sync-box/channels.ts b/src/common/utils/sync-box/channels.ts index 4df0462dc3..2bf1c3a7f9 100644 --- a/src/common/utils/sync-box/channels.ts +++ b/src/common/utils/sync-box/channels.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { MessageChannel } from "../channel/message-channel-listener-injection-token"; -import type { RequestChannel } from "../channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../channel/request-channel"; export type SyncBoxChannel = MessageChannel<{ id: string; value: any }>; diff --git a/src/features/cluster/delete-dialog/common/clear-as-deleting-channel.ts b/src/features/cluster/delete-dialog/common/clear-as-deleting-channel.ts index bf33a23165..f5ebe63606 100644 --- a/src/features/cluster/delete-dialog/common/clear-as-deleting-channel.ts +++ b/src/features/cluster/delete-dialog/common/clear-as-deleting-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { ClusterId } from "../../../../common/cluster-types"; -import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../../../../common/utils/channel/request-channel"; export type ClearClusterAsDeletingChannel = RequestChannel; diff --git a/src/features/cluster/delete-dialog/common/delete-channel.ts b/src/features/cluster/delete-dialog/common/delete-channel.ts index 0e9142fcd3..ed5faa77a4 100644 --- a/src/features/cluster/delete-dialog/common/delete-channel.ts +++ b/src/features/cluster/delete-dialog/common/delete-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { ClusterId } from "../../../../common/cluster-types"; -import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../../../../common/utils/channel/request-channel"; export type DeleteClusterChannel = RequestChannel; diff --git a/src/features/cluster/delete-dialog/common/set-as-deleting-channel.ts b/src/features/cluster/delete-dialog/common/set-as-deleting-channel.ts index 57ef2e3a8d..906c1155d1 100644 --- a/src/features/cluster/delete-dialog/common/set-as-deleting-channel.ts +++ b/src/features/cluster/delete-dialog/common/set-as-deleting-channel.ts @@ -3,7 +3,7 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import type { ClusterId } from "../../../../common/cluster-types"; -import type { RequestChannel } from "../../../../common/utils/channel/request-channel-listener-injection-token"; +import type { RequestChannel } from "../../../../common/utils/channel/request-channel"; export type SetClusterAsDeletingChannel = RequestChannel; diff --git a/src/features/helm-charts/child-features/preferences/renderer/active-helm-repositories.injectable.ts b/src/features/helm-charts/child-features/preferences/renderer/active-helm-repositories.injectable.ts index 7a0d5e6b47..ca87c49bd7 100644 --- a/src/features/helm-charts/child-features/preferences/renderer/active-helm-repositories.injectable.ts +++ b/src/features/helm-charts/child-features/preferences/renderer/active-helm-repositories.injectable.ts @@ -5,16 +5,16 @@ import { getInjectable } from "@ogre-tools/injectable"; import { asyncComputed } from "@ogre-tools/injectable-react"; import { getActiveHelmRepositoriesChannel } from "../../../../../common/helm/get-active-helm-repositories-channel"; -import { requestFromChannelInjectionToken } from "../../../../../common/utils/channel/request-from-channel-injection-token"; import showErrorNotificationInjectable from "../../../../../renderer/components/notifications/show-error-notification.injectable"; import helmRepositoriesErrorStateInjectable from "./helm-repositories-error-state.injectable"; import { runInAction } from "mobx"; +import requestFromChannelInjectable from "../../../../../renderer/utils/channel/request-from-channel.injectable"; const activeHelmRepositoriesInjectable = getInjectable({ id: "active-helm-repositories", instantiate: (di) => { - const requestFromChannel = di.inject(requestFromChannelInjectionToken); + const requestFromChannel = di.inject(requestFromChannelInjectable); const showErrorNotification = di.inject(showErrorNotificationInjectable); const helmRepositoriesErrorState = di.inject( helmRepositoriesErrorStateInjectable, diff --git a/src/features/helm-charts/child-features/preferences/renderer/adding-of-public-helm-repository/select-helm-repository/add-helm-repository.injectable.ts b/src/features/helm-charts/child-features/preferences/renderer/adding-of-public-helm-repository/select-helm-repository/add-helm-repository.injectable.ts index 6b39d8dddf..b2cb8ab52f 100644 --- a/src/features/helm-charts/child-features/preferences/renderer/adding-of-public-helm-repository/select-helm-repository/add-helm-repository.injectable.ts +++ b/src/features/helm-charts/child-features/preferences/renderer/adding-of-public-helm-repository/select-helm-repository/add-helm-repository.injectable.ts @@ -4,17 +4,17 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import type { HelmRepo } from "../../../../../../../common/helm/helm-repo"; -import { requestFromChannelInjectionToken } from "../../../../../../../common/utils/channel/request-from-channel-injection-token"; import activeHelmRepositoriesInjectable from "../../active-helm-repositories.injectable"; import showErrorNotificationInjectable from "../../../../../../../renderer/components/notifications/show-error-notification.injectable"; import showSuccessNotificationInjectable from "../../../../../../../renderer/components/notifications/show-success-notification.injectable"; import { addHelmRepositoryChannel } from "../../../../../../../common/helm/add-helm-repository-channel"; +import requestFromChannelInjectable from "../../../../../../utils/channel/request-from-channel.injectable"; const addHelmRepositoryInjectable = getInjectable({ id: "add-public-helm-repository", instantiate: (di) => { - const requestFromChannel = di.inject(requestFromChannelInjectionToken); + const requestFromChannel = di.inject(requestFromChannelInjectable); const activeHelmRepositories = di.inject(activeHelmRepositoriesInjectable); const showErrorNotification = di.inject(showErrorNotificationInjectable); const showSuccessNotification = di.inject(showSuccessNotificationInjectable); diff --git a/src/features/helm-charts/child-features/preferences/renderer/remove-helm-repository.injectable.ts b/src/features/helm-charts/child-features/preferences/renderer/remove-helm-repository.injectable.ts index 3aa56a4b04..823ef1495e 100644 --- a/src/features/helm-charts/child-features/preferences/renderer/remove-helm-repository.injectable.ts +++ b/src/features/helm-charts/child-features/preferences/renderer/remove-helm-repository.injectable.ts @@ -4,15 +4,15 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import type { HelmRepo } from "../../../../../common/helm/helm-repo"; -import { requestFromChannelInjectionToken } from "../../../../../common/utils/channel/request-from-channel-injection-token"; import activeHelmRepositoriesInjectable from "./active-helm-repositories.injectable"; import { removeHelmRepositoryChannel } from "../../../../../common/helm/remove-helm-repository-channel"; +import requestFromChannelInjectable from "../../../../utils/channel/request-from-channel.injectable"; const removePublicHelmRepositoryInjectable = getInjectable({ id: "remove-public-helm-repository", instantiate: (di) => { - const requestFromChannel = di.inject(requestFromChannelInjectionToken); + const requestFromChannel = di.inject(requestFromChannelInjectable); const activeHelmRepositories = di.inject(activeHelmRepositoriesInjectable); return async (repository: HelmRepo) => { diff --git a/src/features/terminal/__image_snapshots__/opening-terminal-tab-test-tsx-test-for-opening-terminal-tab-within-cluster-frame-when-new-terminal-tab-is-opened-shows-connecting-message-1-snap.png b/src/features/terminal/__image_snapshots__/opening-terminal-tab-test-tsx-test-for-opening-terminal-tab-within-cluster-frame-when-new-terminal-tab-is-opened-shows-connecting-message-1-snap.png new file mode 100644 index 0000000000..9d263a76b6 Binary files /dev/null and b/src/features/terminal/__image_snapshots__/opening-terminal-tab-test-tsx-test-for-opening-terminal-tab-within-cluster-frame-when-new-terminal-tab-is-opened-shows-connecting-message-1-snap.png differ diff --git a/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap b/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap new file mode 100644 index 0000000000..99b888bc11 --- /dev/null +++ b/src/features/terminal/__snapshots__/opening-terminal-tab.test.tsx.snap @@ -0,0 +1,584 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`test for opening terminal tab within cluster frame when new terminal tab is opened renders 1`] = ` + +
+
+
+
+