1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix tests from rebase

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-04-27 11:21:09 -04:00
parent 5d1609e0e4
commit 3def62cd8d
33 changed files with 457 additions and 449 deletions

View File

@ -364,7 +364,6 @@
"flex.box": "^3.4.4",
"fork-ts-checker-webpack-plugin": "^6.5.0",
"gunzip-maybe": "^1.4.2",
"hoist-non-react-statics": "^3.3.2",
"html-webpack-plugin": "^5.5.0",
"identity-obj-proxy": "^3.0.0",
"ignore-loader": "^0.1.2",

View File

@ -9,7 +9,10 @@ import { getApplicationBuilder } from "../../renderer/components/test-utils/get-
import isAutoUpdateEnabledInjectable from "../../main/is-auto-update-enabled.injectable";
// TODO: Make components free of side effects by making them deterministic
jest.mock("../../renderer/components/tooltip");
jest.mock("../../renderer/components/tooltip/tooltip");
jest.mock("../../renderer/components/tooltip/withTooltip", () => ({
withTooltip: (target: any) => target,
}));
jest.mock("../../renderer/components/monaco-editor/monaco-editor");
describe("add-cluster - navigation using application menu", () => {

View File

@ -5,8 +5,6 @@
import React from "react";
import type { RenderResult } from "@testing-library/react";
import { fireEvent } from "@testing-library/react";
import { getRendererExtensionFake } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import { LensRendererExtension } from "../../extensions/lens-renderer-extension";
import directoryForLensLocalStorageInjectable from "../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable";
import routesInjectable from "../../renderer/routes/routes.injectable";
import { matches } from "lodash/fp";
@ -19,6 +17,8 @@ import type { DiContainer } from "@ogre-tools/injectable";
import { navigateToRouteInjectionToken } from "../../common/front-end-routing/navigate-to-route-injection-token";
import assert from "assert";
import { getSidebarItem } from "../utils";
import type { FakeExtensionData } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFakeFor } from "../../renderer/components/test-utils/get-renderer-extension-fake";
describe("cluster - sidebar and tab navigation for extensions", () => {
let applicationBuilder: ApplicationBuilder;
@ -43,6 +43,7 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
describe("given extension with cluster pages and cluster page menus", () => {
beforeEach(async () => {
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
const testExtension = getRendererExtensionFake(extensionStubWithSidebarItems);
await applicationBuilder.addExtensions(testExtension);
@ -383,8 +384,10 @@ describe("cluster - sidebar and tab navigation for extensions", () => {
});
});
const extensionStubWithSidebarItems = new (class extends LensRendererExtension {
clusterPages = [
const extensionStubWithSidebarItems: FakeExtensionData = {
id: "some-extension-id",
name: "some-extension-name",
clusterPages: [
{
components: {
Page: () => {
@ -408,9 +411,8 @@ const extensionStubWithSidebarItems = new (class extends LensRendererExtension {
),
},
},
];
clusterPageMenus = [
],
clusterPageMenus: [
{
id: "some-parent-id",
title: "Parent",
@ -441,16 +443,5 @@ const extensionStubWithSidebarItems = new (class extends LensRendererExtension {
Icon: null as never,
},
},
];
})({
absolutePath: "/some/absolute/path",
id: "some-extension-id",
isBundled: true,
isCompatible: true,
isEnabled: true,
manifest: {
name: "some-extension-name",
version: "1.0.0",
},
manifestPath: "/some/manifest/path",
});
],
};

View File

@ -2,15 +2,13 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFake } from "../renderer/components/test-utils/get-renderer-extension-fake";
import type { FakeExtensionData, TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFakeFor } from "../renderer/components/test-utils/get-renderer-extension-fake";
import React from "react";
import type { RenderResult } from "@testing-library/react";
import currentPathInjectable from "../renderer/routes/current-path.injectable";
import type { LensRendererExtension } from "../extensions/lens-renderer-extension";
import type { ApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
import type { SetRequired } from "type-fest";
describe("extension special characters in page registrations", () => {
let applicationBuilder: ApplicationBuilder;
@ -19,6 +17,7 @@ describe("extension special characters in page registrations", () => {
beforeEach(async () => {
applicationBuilder = getApplicationBuilder();
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
testExtension = getRendererExtensionFake(
extensionWithPagesHavingSpecialCharacters,
@ -50,9 +49,9 @@ describe("extension special characters in page registrations", () => {
});
});
const extensionWithPagesHavingSpecialCharacters: SetRequired<Partial<LensRendererExtension>, "id"> = {
id: "@some-extension-id/",
const extensionWithPagesHavingSpecialCharacters: FakeExtensionData = {
id: "some-extension-id",
name: "@some-extension-name/",
globalPages: [
{
id: "/some-page-id/",

View File

@ -2,8 +2,8 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFake } from "../renderer/components/test-utils/get-renderer-extension-fake";
import type { FakeExtensionData, TestExtension } from "../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFakeFor } from "../renderer/components/test-utils/get-renderer-extension-fake";
import React from "react";
import type { RenderResult } from "@testing-library/react";
import { fireEvent } from "@testing-library/react";
@ -11,9 +11,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 { LensRendererExtension } from "../extensions/lens-renderer-extension";
import { getApplicationBuilder } from "../renderer/components/test-utils/get-application-builder";
import type { SetRequired } from "type-fest";
describe("navigate to extension page", () => {
let rendered: RenderResult;
@ -23,6 +21,7 @@ describe("navigate to extension page", () => {
beforeEach(async () => {
const applicationBuilder = getApplicationBuilder();
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
testExtension = getRendererExtensionFake(
extensionWithPagesHavingParameters,
@ -126,9 +125,9 @@ describe("navigate to extension page", () => {
});
});
const extensionWithPagesHavingParameters: SetRequired<Partial<LensRendererExtension>, "id"> = {
const extensionWithPagesHavingParameters: FakeExtensionData = {
id: "some-extension-id",
name: "some-extension-name",
globalPages: [
{
components: {

View File

@ -117,14 +117,14 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-26-live-region"
id="react-select-6-live-region"
/>
<span
aria-atomic="false"
@ -140,7 +140,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-26-placeholder"
id="react-select-6-placeholder"
>
Select...
</div>
@ -150,7 +150,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<input
aria-autocomplete="list"
aria-describedby="react-select-26-placeholder"
aria-describedby="react-select-6-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -202,14 +202,14 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-27-live-region"
id="react-select-7-live-region"
/>
<span
aria-atomic="false"
@ -225,7 +225,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-27-placeholder"
id="react-select-7-placeholder"
>
Select...
</div>
@ -235,7 +235,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<input
aria-autocomplete="list"
aria-describedby="react-select-27-placeholder"
aria-describedby="react-select-7-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -281,8 +281,8 @@ exports[`preferences - closing-preferences given accessing preferences directly
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -316,7 +316,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -337,14 +337,14 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-28-live-region"
id="react-select-8-live-region"
/>
<span
aria-atomic="false"
@ -360,7 +360,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-28-placeholder"
id="react-select-8-placeholder"
>
Select...
</div>
@ -370,7 +370,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<input
aria-autocomplete="list"
aria-describedby="react-select-28-placeholder"
aria-describedby="react-select-8-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -422,14 +422,14 @@ exports[`preferences - closing-preferences given accessing preferences directly
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-29-live-region"
id="react-select-9-live-region"
/>
<span
aria-atomic="false"
@ -445,7 +445,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-29-placeholder"
id="react-select-9-placeholder"
>
Select...
</div>
@ -455,7 +455,7 @@ exports[`preferences - closing-preferences given accessing preferences directly
>
<input
aria-autocomplete="list"
aria-describedby="react-select-29-placeholder"
aria-describedby="react-select-9-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -815,7 +815,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -900,7 +900,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -979,8 +979,8 @@ exports[`preferences - closing-preferences given already in a page and then navi
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -1014,7 +1014,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -1035,7 +1035,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -1120,7 +1120,7 @@ exports[`preferences - closing-preferences given already in a page and then navi
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"

View File

@ -103,7 +103,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
HTTP Proxy
</div>
<div
class="Input theme round black"
@ -139,7 +139,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Certificate Trust
</div>
<label
class="Switch"
@ -155,9 +155,9 @@ exports[`preferences - navigation to application preferences given in some child
class="hint"
>
This will make Lens to trust ANY certificate authority without any validations.
Needed with some corporate proxies that do certificate re-writing.
Does not affect cluster communications!
</small>
</section>
@ -307,7 +307,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -392,7 +392,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -471,8 +471,8 @@ exports[`preferences - navigation to application preferences given in some child
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -506,7 +506,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -527,7 +527,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -612,7 +612,7 @@ exports[`preferences - navigation to application preferences given in some child
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"

View File

@ -105,7 +105,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -190,7 +190,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -269,8 +269,8 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -304,7 +304,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -325,7 +325,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -410,7 +410,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -630,7 +630,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Minimap
</div>
<section>
<div
@ -663,7 +663,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-14-live-region"
id="react-select-10-live-region"
/>
<span
aria-atomic="false"
@ -679,7 +679,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-14-placeholder"
id="react-select-10-placeholder"
>
Select...
</div>
@ -689,7 +689,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
>
<input
aria-autocomplete="list"
aria-describedby="react-select-14-placeholder"
aria-describedby="react-select-10-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -740,14 +740,14 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Line numbers
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-15-live-region"
id="react-select-11-live-region"
/>
<span
aria-atomic="false"
@ -763,7 +763,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-15-placeholder"
id="react-select-11-placeholder"
>
Select...
</div>
@ -773,7 +773,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
>
<input
aria-autocomplete="list"
aria-describedby="react-select-15-placeholder"
aria-describedby="react-select-11-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -822,7 +822,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Tab size
</div>
<div
class="Input theme round black"
@ -849,7 +849,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Font size
</div>
<div
class="Input theme round black"
@ -876,7 +876,7 @@ exports[`preferences - navigation to editor preferences given in preferences, wh
class="SubTitle"
>
Font family
</div>
<div
class="Input theme round black"

View File

@ -105,7 +105,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -190,7 +190,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -269,8 +269,8 @@ exports[`preferences - navigation to extension specific preferences given in pre
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -304,7 +304,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -325,7 +325,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -410,7 +410,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -645,14 +645,14 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-14-live-region"
id="react-select-6-live-region"
/>
<span
aria-atomic="false"
@ -668,7 +668,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-14-placeholder"
id="react-select-6-placeholder"
>
Select...
</div>
@ -678,7 +678,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<input
aria-autocomplete="list"
aria-describedby="react-select-14-placeholder"
aria-describedby="react-select-6-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -730,14 +730,14 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-15-live-region"
id="react-select-7-live-region"
/>
<span
aria-atomic="false"
@ -753,7 +753,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-15-placeholder"
id="react-select-7-placeholder"
>
Select...
</div>
@ -763,7 +763,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<input
aria-autocomplete="list"
aria-describedby="react-select-15-placeholder"
aria-describedby="react-select-7-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -809,8 +809,8 @@ exports[`preferences - navigation to extension specific preferences given in pre
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -844,7 +844,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -865,14 +865,14 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-16-live-region"
id="react-select-8-live-region"
/>
<span
aria-atomic="false"
@ -888,7 +888,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-16-placeholder"
id="react-select-8-placeholder"
>
Select...
</div>
@ -898,7 +898,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<input
aria-autocomplete="list"
aria-describedby="react-select-16-placeholder"
aria-describedby="react-select-8-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -950,14 +950,14 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-17-live-region"
id="react-select-9-live-region"
/>
<span
aria-atomic="false"
@ -973,7 +973,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-17-placeholder"
id="react-select-9-placeholder"
>
Select...
</div>
@ -983,7 +983,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
>
<input
aria-autocomplete="list"
aria-describedby="react-select-17-placeholder"
aria-describedby="react-select-9-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -1185,7 +1185,7 @@ exports[`preferences - navigation to extension specific preferences given in pre
class="SubTitle"
>
Some preference item
</div>
<div
data-testid="some-preference-item-input"

View File

@ -105,7 +105,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -190,7 +190,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -269,8 +269,8 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -304,7 +304,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -325,7 +325,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -410,7 +410,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -634,7 +634,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Kubectl binary download
</div>
<label
class="Switch"
@ -652,14 +652,14 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Download mirror
</div>
<div
class="Select theme-lens Select--is-disabled css-3iigni-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-14-live-region"
id="react-select-10-live-region"
/>
<span
aria-atomic="false"
@ -675,7 +675,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-14-placeholder"
id="react-select-10-placeholder"
>
Download mirror for kubectl
</div>
@ -685,7 +685,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
>
<input
aria-autocomplete="list"
aria-describedby="react-select-14-placeholder"
aria-describedby="react-select-10-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -735,7 +735,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Directory for binaries
</div>
<div
class="Input theme round black disabled"
@ -767,7 +767,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle"
>
Path to kubectl binary
</div>
<div
class="Input theme round black"
@ -812,7 +812,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
class="SubTitle pt-5"
>
Synced Items
</div>
<div
class="notice mt-3"
@ -840,7 +840,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-15-live-region"
id="react-select-11-live-region"
/>
<span
aria-atomic="false"
@ -856,7 +856,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-15-placeholder"
id="react-select-11-placeholder"
>
Repositories
</div>
@ -866,7 +866,7 @@ exports[`preferences - navigation to kubernetes preferences given in preferences
>
<input
aria-autocomplete="list"
aria-describedby="react-select-15-placeholder"
aria-describedby="react-select-11-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"

View File

@ -105,7 +105,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -190,7 +190,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -269,8 +269,8 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -304,7 +304,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -325,7 +325,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -410,7 +410,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -631,7 +631,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
HTTP Proxy
</div>
<div
class="Input theme round black"
@ -667,7 +667,7 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="SubTitle"
>
Certificate Trust
</div>
<label
class="Switch"
@ -683,9 +683,9 @@ exports[`preferences - navigation to proxy preferences given in preferences, whe
class="hint"
>
This will make Lens to trust ANY certificate authority without any validations.
Needed with some corporate proxies that do certificate re-writing.
Does not affect cluster communications!
</small>
</section>

View File

@ -119,7 +119,7 @@ exports[`preferences - navigation to telemetry preferences given URL for Sentry
class="SubTitle"
>
Automatic Error Reporting
</div>
<label
class="Checkbox flex align-center"
@ -293,7 +293,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -378,7 +378,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -457,8 +457,8 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -492,7 +492,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -513,7 +513,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -598,7 +598,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -833,14 +833,14 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-14-live-region"
id="react-select-6-live-region"
/>
<span
aria-atomic="false"
@ -856,7 +856,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-14-placeholder"
id="react-select-6-placeholder"
>
Select...
</div>
@ -866,7 +866,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<input
aria-autocomplete="list"
aria-describedby="react-select-14-placeholder"
aria-describedby="react-select-6-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -918,14 +918,14 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-15-live-region"
id="react-select-7-live-region"
/>
<span
aria-atomic="false"
@ -941,7 +941,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-15-placeholder"
id="react-select-7-placeholder"
>
Select...
</div>
@ -951,7 +951,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<input
aria-autocomplete="list"
aria-describedby="react-select-15-placeholder"
aria-describedby="react-select-7-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -997,8 +997,8 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -1032,7 +1032,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -1053,14 +1053,14 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-16-live-region"
id="react-select-8-live-region"
/>
<span
aria-atomic="false"
@ -1076,7 +1076,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-16-placeholder"
id="react-select-8-placeholder"
>
Select...
</div>
@ -1086,7 +1086,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<input
aria-autocomplete="list"
aria-describedby="react-select-16-placeholder"
aria-describedby="react-select-8-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -1138,14 +1138,14 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-17-live-region"
id="react-select-9-live-region"
/>
<span
aria-atomic="false"
@ -1161,7 +1161,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-17-placeholder"
id="react-select-9-placeholder"
>
Select...
</div>
@ -1171,7 +1171,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
>
<input
aria-autocomplete="list"
aria-describedby="react-select-17-placeholder"
aria-describedby="react-select-9-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -1375,7 +1375,7 @@ exports[`preferences - navigation to telemetry preferences given in preferences,
class="SubTitle"
>
Some telemetry-preference item
</div>
<div
data-testid="some-preference-item-input"

View File

@ -105,7 +105,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -190,7 +190,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -269,8 +269,8 @@ exports[`preferences - navigation to terminal preferences given in preferences,
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -304,7 +304,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -325,7 +325,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -410,7 +410,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -629,7 +629,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Terminal Shell Path
</div>
<div
class="Input theme round black"
@ -657,7 +657,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Terminal copy & paste
</div>
<label
class="Switch"
@ -677,14 +677,14 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Terminal theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
>
<span
class="css-1f43avz-a11yText-A11yText"
id="react-select-14-live-region"
id="react-select-10-live-region"
/>
<span
aria-atomic="false"
@ -700,7 +700,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
>
<div
class="Select__placeholder css-14el2xx-placeholder"
id="react-select-14-placeholder"
id="react-select-10-placeholder"
>
Select...
</div>
@ -710,7 +710,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
>
<input
aria-autocomplete="list"
aria-describedby="react-select-14-placeholder"
aria-describedby="react-select-10-placeholder"
aria-expanded="false"
aria-haspopup="true"
autocapitalize="none"
@ -759,7 +759,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Font size
</div>
<div
class="Input theme round black"
@ -786,7 +786,7 @@ exports[`preferences - navigation to terminal preferences given in preferences,
class="SubTitle"
>
Font family
</div>
<div
class="Input theme round black"

View File

@ -107,7 +107,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="SubTitle"
>
Theme
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -192,7 +192,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="SubTitle"
>
Extension Install Registry
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -271,8 +271,8 @@ exports[`preferences - navigation using application menu when navigating to pref
<p
class="mt-4 mb-5 leading-relaxed"
>
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
This setting is to change the registry URL for installing extensions by name.
If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your
<b>
.npmrc
</b>
@ -306,7 +306,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="SubTitle"
>
Start-up
</div>
<label
class="Switch"
@ -327,7 +327,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="SubTitle"
>
Update Channel
</div>
<div
class="Select theme-lens css-b62m3t-container"
@ -412,7 +412,7 @@ exports[`preferences - navigation using application menu when navigating to pref
class="SubTitle"
>
Locale Timezone
</div>
<div
class="Select theme-lens css-b62m3t-container"

View File

@ -7,9 +7,9 @@ import type { ApplicationBuilder } from "../../renderer/components/test-utils/ge
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import userStoreInjectable from "../../common/user-store/user-store.injectable";
import type { UserStore } from "../../common/user-store";
import { LensRendererExtension } from "../../extensions/lens-renderer-extension";
import React from "react";
import { getRendererExtensionFake } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import type { FakeExtensionData } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFakeFor } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import ipcRendererInjectable from "../../renderer/app-paths/get-value-from-registered-channel/ipc-renderer/ipc-renderer.injectable";
describe("preferences - navigation to extension specific preferences", () => {
@ -60,6 +60,7 @@ describe("preferences - navigation to extension specific preferences", () => {
describe("when extension with specific preferences is enabled", () => {
beforeEach(() => {
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
const testExtension = getRendererExtensionFake(extensionStubWithExtensionSpecificPreferenceItems);
applicationBuilder.addExtensions(testExtension);
@ -106,8 +107,10 @@ describe("preferences - navigation to extension specific preferences", () => {
});
});
const extensionStubWithExtensionSpecificPreferenceItems = new (class extends LensRendererExtension{
appPreferences = [
const extensionStubWithExtensionSpecificPreferenceItems: FakeExtensionData = {
id: "some-extension-id",
name: "some-extension-name",
appPreferences: [
{
title: "Some preference item",
id: "some-preference-item-id",
@ -128,17 +131,6 @@ const extensionStubWithExtensionSpecificPreferenceItems = new (class extends Len
Input: () => <div />,
},
},
];
})({
absolutePath: "/some/absolute/path",
id: "some-extension-id",
isBundled: true,
isCompatible: true,
isEnabled: true,
manifest: {
name: "some-extension-name",
version: "1.0.0",
},
manifestPath: "/some/manifest/path",
});
],
};

View File

@ -6,7 +6,8 @@ import type { RenderResult } from "@testing-library/react";
import React from "react";
import type { ApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../../renderer/components/test-utils/get-application-builder";
import { getRendererExtensionFake } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import type { FakeExtensionData } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import { getRendererExtensionFakeFor } from "../../renderer/components/test-utils/get-renderer-extension-fake";
import type { UserStore } from "../../common/user-store";
import userStoreInjectable from "../../common/user-store/user-store.injectable";
import navigateToTelemetryPreferencesInjectable from "../../common/front-end-routing/routes/preferences/telemetry/navigate-to-telemetry-preferences.injectable";
@ -61,8 +62,8 @@ describe("preferences - navigation to telemetry preferences", () => {
describe("when extension with telemetry preference items gets enabled", () => {
beforeEach(() => {
const testExtensionWithTelemetryPreferenceItems =
getRendererExtensionFake(extensionStubWithTelemetryPreferenceItems);
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
const testExtensionWithTelemetryPreferenceItems = getRendererExtensionFake(extensionStubWithTelemetryPreferenceItems);
applicationBuilder.addExtensions(
testExtensionWithTelemetryPreferenceItems,
@ -105,18 +106,19 @@ describe("preferences - navigation to telemetry preferences", () => {
});
it("given extensions but no telemetry preference items, does not show link for telemetry preferences", () => {
const testExtensionWithTelemetryPreferenceItems =
getRendererExtensionFake({
id: "some-test-extension-id",
appPreferences: [
{
title: "irrelevant",
id: "irrelevant",
showInPreferencesTab: "not-telemetry",
components: { Hint: () => <div />, Input: () => <div /> },
},
],
});
const getRendererExtensionFake = getRendererExtensionFakeFor(applicationBuilder);
const testExtensionWithTelemetryPreferenceItems = getRendererExtensionFake({
id: "some-test-extension-id",
name: "some-test-extension-name",
appPreferences: [
{
title: "irrelevant",
id: "irrelevant",
showInPreferencesTab: "not-telemetry",
components: { Hint: () => <div />, Input: () => <div /> },
},
],
});
applicationBuilder.addExtensions(
testExtensionWithTelemetryPreferenceItems,
@ -185,8 +187,9 @@ describe("preferences - navigation to telemetry preferences", () => {
});
});
const extensionStubWithTelemetryPreferenceItems = {
const extensionStubWithTelemetryPreferenceItems: FakeExtensionData = {
id: "some-test-extension-id",
name: "some-test-extension-name",
appPreferences: [
{
title: "Some telemetry-preference item",

View File

@ -14,6 +14,7 @@ import type { FetchMock } from "jest-fetch-mock/types";
import { DeploymentApi, Ingress, IngressApi, Pod, PodApi } from "../endpoints";
import { getDiForUnitTesting } from "../../../main/getDiForUnitTesting";
import apiManagerInjectable from "../api-manager/manager.injectable";
import autoRegistrationInjectable from "../api-manager/auto-registration.injectable";
jest.mock("../api-manager");
@ -98,6 +99,7 @@ describe("KubeApi", () => {
apiManager = new ApiManager() as jest.Mocked<ApiManager>;
di.override(apiManagerInjectable, () => apiManager);
di.inject(autoRegistrationInjectable);
});
it("uses url from apiBase if apiBase contains the resource", async () => {
@ -227,7 +229,7 @@ describe("KubeApi", () => {
await (api as any).checkPreferredVersion();
expect(api.apiVersionPreferred).toBe("v1beta1");
expect(apiManager.registerApi).toBeCalledWith("/apis/extensions/v1beta1/ingresses", expect.anything());
expect(apiManager.registerApi).toBeCalledWith(api);
});
it("registers with apiManager if checkPreferredVersion changes apiVersionPreferred with non-grouped apis", async () => {
@ -267,7 +269,7 @@ describe("KubeApi", () => {
await (api as any).checkPreferredVersion();
expect(api.apiVersionPreferred).toBe("v1beta1");
expect(apiManager.registerApi).toBeCalledWith("/api/v1beta1/pods", expect.anything());
expect(apiManager.registerApi).toBeCalledWith(api);
});
});

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { reduce } from "../iter";
import { join, nth, reduce } from "../iter";
describe("iter", () => {
describe("reduce", () => {
@ -15,4 +15,28 @@ describe("iter", () => {
expect(reduce([], (acc: number[], current: number) => [acc[0] + current], [])).toEqual([]);
});
});
describe("join", () => {
it("should not prefix the output by the seperator", () => {
expect(join(["a", "b", "c"].values(), " ")).toBe("a b c");
});
it("should return empty string if iterator is empty", () => {
expect(join([].values(), " ")).toBe("");
});
it("should return just first entry if iterator is of size 1", () => {
expect(join(["d"].values(), " ")).toBe("d");
});
});
describe("nth", () => {
it("should return undefined past the end of the iterator", () => {
expect(nth(["a"], 123)).toBeUndefined();
});
it("should by 0-indexing the index", () => {
expect(nth(["a", "b"], 0)).toBe("a");
});
});
});

View File

@ -5,64 +5,24 @@
export type Falsey = false | 0 | "" | null | undefined;
export function pipeline<T>(src: Iterable<T>) {
return Iterator[createPipeline](src);
interface Iterator<T> {
filter(fn: (val: T) => unknown): Iterator<T>;
filterMap<U>(fn: (val: T) => Falsey | U): Iterator<U>;
find(fn: (val: T) => unknown): T | undefined;
collect<U>(fn: (values: Iterable<T>) => U): U;
map<U>(fn: (val: T) => U): Iterator<U>;
join(sep?: string): string;
}
const createPipeline = Symbol("create-pipeline");
export class Iterator<T> {
#inner: Iterable<any>;
static [createPipeline]<T>(inner: Iterable<T>) {
return new Iterator(inner);
}
private constructor(inner: Iterable<T>) {
this.#inner = inner;
}
/**
* Wrap the interior iterator with an filter
*/
public filter(fn: (val: T) => any): Iterator<T> {
this.#inner = filter(this.#inner, fn);
return this;
}
/**
* Wrap the interior iterator with an filterMap
*/
public filterMap<U>(fn: (val: T) => Falsey | U): Iterator<U> {
this.#inner = filterMap(this.#inner, fn);
return this as never;
}
/**
* Consume the interior iterator until an element matches the callback and return that
*/
public find(fn: (val: T) => any): T | undefined {
return find(this.#inner, fn);
}
/**
* Consume the interior iterator and produce a new type
*/
public collect<U>(fn: (values: Iterable<T>) => U): U {
return fn(this.#inner);
}
public map<U>(fn: (val: T) => U): Iterator<U> {
this.#inner = map(this.#inner, fn);
return this as never;
}
public join(sep?: string): string {
return join(this.#inner, sep);
}
export function pipeline<T>(src: IterableIterator<T>): Iterator<T> {
return {
filter: (fn) => pipeline(filter(src, fn)),
filterMap: (fn) => pipeline(filterMap(src, fn)),
map: (fn) => pipeline(map(src, fn)),
find: (fn) => find(src, fn),
join: (sep) => join(src, sep),
collect: (fn) => fn(src),
};
}
/**
@ -224,8 +184,15 @@ export function reduce<T, R = T>(src: Iterable<T>, reducer: (acc: R, cur: T) =>
* @param connector The string value to intersperse between the yielded values
* @returns The concatenated entries of `src` interspersed with copies of `connector`
*/
export function join(src: Iterable<unknown>, connector = ","): string {
return reduce(src, (acc, cur) => `${acc}${connector}${cur}`, "");
export function join(src: IterableIterator<unknown>, connector = ","): string {
const iterSrc = src[Symbol.iterator]();
const first = iterSrc.next();
if (first.done === true) {
return "";
}
return reduce(iterSrc, (acc, cur) => `${acc}${connector}${cur}`, `${first.value}`);
}
/**

View File

@ -22,7 +22,8 @@ export interface LensExtensionManifest extends PackageJson {
renderer?: string; // path to %ext/dist/renderer.js
}
export const Disposers = Symbol();
export const lensExtensionDependencies = Symbol("lens-extension-dependencies");
export const Disposers = Symbol("disposers");
export class LensExtension<Dependencies extends LensExtensionDependencies = LensExtensionDependencies> {
readonly id: LensExtensionId;
@ -64,7 +65,7 @@ export class LensExtension<Dependencies extends LensExtensionDependencies = Lens
return this.manifest.description;
}
protected readonly dependencies!: Dependencies;
readonly [lensExtensionDependencies]!: Dependencies;
/**
* getExtensionFileFolder returns the path to an already created folder. This
@ -74,7 +75,7 @@ export class LensExtension<Dependencies extends LensExtensionDependencies = Lens
* folder name.
*/
async getExtensionFileFolder(): Promise<string> {
return this.dependencies.fileSystemProvisionerStore.requestDirectory(this.id);
return this[lensExtensionDependencies].fileSystemProvisionerStore.requestDirectory(this.id);
}
@action

View File

@ -3,7 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { LensExtension } from "./lens-extension";
import { LensExtension, lensExtensionDependencies } from "./lens-extension";
import { WindowManager } from "../main/window-manager";
import type { CatalogEntity } from "../common/catalog";
import type { IObservableArray } from "mobx";
@ -36,10 +36,10 @@ export class LensMainExtension extends LensExtension<LensMainExtensionDependenci
}
addCatalogSource(id: string, source: IObservableArray<CatalogEntity>) {
this.dependencies.entityRegistry.addObservableSource(`${this.name}:${id}`, source);
this[lensExtensionDependencies].entityRegistry.addObservableSource(`${this.name}:${id}`, source);
}
removeCatalogSource(id: string) {
this.dependencies.entityRegistry.removeSource(`${this.name}:${id}`);
this[lensExtensionDependencies].entityRegistry.removeSource(`${this.name}:${id}`);
}
}

View File

@ -4,7 +4,7 @@
*/
import type * as registries from "./registries";
import { Disposers, LensExtension } from "./lens-extension";
import { Disposers, LensExtension, lensExtensionDependencies } from "./lens-extension";
import type { CatalogEntity } from "../common/catalog";
import type { Disposer } from "../common/utils";
import type { EntityFilter } from "../renderer/api/catalog/entity/registry";
@ -46,7 +46,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
customCategoryViews: CustomCategoryViewRegistration[] = [];
async navigate(pageId?: string, params: object = {}) {
const routes = this.dependencies.routes.get();
const routes = this[lensExtensionDependencies].routes.get();
const targetRegistration = [...this.globalPages, ...this.clusterPages]
.find(registration => registration.id === (pageId || undefined));
@ -61,7 +61,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
return;
}
const normalizedParams = this.dependencies.getExtensionPageParameters({
const normalizedParams = this[lensExtensionDependencies].getExtensionPageParameters({
extension: this,
registration: targetRegistration,
});
@ -75,7 +75,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
fromPairs,
);
this.dependencies.navigateToRoute(targetRoute, {
this[lensExtensionDependencies].navigateToRoute(targetRoute, {
query,
});
}
@ -96,7 +96,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
* @returns A function to clean up the filter
*/
addCatalogFilter(fn: EntityFilter): Disposer {
const dispose = this.dependencies.entityRegistry.addCatalogFilter(fn);
const dispose = this[lensExtensionDependencies].entityRegistry.addCatalogFilter(fn);
this[Disposers].push(dispose);
@ -109,7 +109,7 @@ export class LensRendererExtension extends LensExtension<LensRendererExtensionDe
* @returns A function to clean up the filter
*/
addCatalogCategoryFilter(fn: CategoryFilter): Disposer {
const dispose = this.dependencies.categoryRegistry.addCatalogCategoryFilter(fn);
const dispose = this[lensExtensionDependencies].categoryRegistry.addCatalogCategoryFilter(fn);
this[Disposers].push(dispose);

View File

@ -8,16 +8,18 @@ import * as uuid from "uuid";
import { broadcastMessage } from "../../../common/ipc";
import { ProtocolHandlerExtension, ProtocolHandlerInternal } from "../../../common/protocol-handler";
import { delay, noop } from "../../../common/utils";
import { LensExtension } from "../../../extensions/main-api";
import { ExtensionsStore } from "../../../extensions/extensions-store/extensions-store";
import type { LensProtocolRouterMain } from "../lens-protocol-router-main/lens-protocol-router-main";
import mockFs from "mock-fs";
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import extensionLoaderInjectable from "../../../extensions/extension-loader/extension-loader.injectable";
import lensProtocolRouterMainInjectable from "../lens-protocol-router-main/lens-protocol-router-main.injectable";
import extensionsStoreInjectable from "../../../extensions/extensions-store/extensions-store.injectable";
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 { LensExtension } from "../../../extensions/lens-extension";
import type { LensExtensionId } from "../../../extensions/lens-extension";
import type { ObservableMap } from "mobx";
import extensionInstancesInjectable from "../../../extensions/extension-loader/extension-instances.injectable";
jest.mock("../../../common/ipc");
@ -28,9 +30,7 @@ function throwIfDefined(val: any): void {
}
describe("protocol router tests", () => {
// TODO: This test suite is using any to access protected property.
// Unit tests are allowed to only public interfaces.
let extensionLoader: any;
let extensionInstances: ObservableMap<LensExtensionId, LensExtension>;
let lpr: LensProtocolRouterMain;
let extensionsStore: ExtensionsStore;
@ -48,10 +48,8 @@ describe("protocol router tests", () => {
await di.runSetups();
extensionLoader = di.inject(extensionLoaderInjectable);
extensionInstances = di.inject(extensionInstancesInjectable);
extensionsStore = di.inject(extensionsStoreInjectable);
lpr = di.inject(lensProtocolRouterMainInjectable);
lpr.rendererLoaded = true;
@ -99,7 +97,7 @@ describe("protocol router tests", () => {
handler: noop,
});
extensionLoader.instances.set(extId, ext);
extensionInstances.set(extId, ext);
extensionsStore.mergeState([[extId, { enabled: true, name: "@mirantis/minikube" }]]);
lpr.addInternalHandler("/", noop);
@ -178,7 +176,7 @@ describe("protocol router tests", () => {
handler: params => { called = params.pathname.id; },
});
extensionLoader.instances.set(extId, ext);
extensionInstances.set(extId, ext);
extensionsStore.mergeState([[extId, { enabled: true, name: "@foobar/icecream" }]]);
try {
@ -216,7 +214,7 @@ describe("protocol router tests", () => {
handler: params => { called = params.pathname.id; },
});
extensionLoader.instances.set(extId, ext);
extensionInstances.set(extId, ext);
extensionsStore.mergeState([[extId, { enabled: true, name: "@foobar/icecream" }]]);
}
@ -241,7 +239,7 @@ describe("protocol router tests", () => {
handler: () => { called = 1; },
});
extensionLoader.instances.set(extId, ext);
extensionInstances.set(extId, ext);
extensionsStore.mergeState([[extId, { enabled: true, name: "icecream" }]]);
}

View File

@ -86,7 +86,7 @@ export class AddSecretDialog extends React.Component<AddSecretDialogProps> {
};
private getDataFromFields = (fields: SecretTemplateField[] = [], processValue: (val: string) => string = (val => val)) => {
return iter.pipeline(fields)
return iter.pipeline(fields.values())
.filterMap(({ key, value }) => (
value
? [key, processValue(value)] as const

View File

@ -137,10 +137,8 @@ class NonInjectedDeploymentDetails extends React.Component<DeploymentDetailsProp
labelsOnly
>
{
deployment.getConditions().map(condition => {
const { type, message, lastTransitionTime, status } = condition;
return (
deployment.getConditions()
.map(({ type, message, lastTransitionTime, status }) => (
<Badge
key={type}
label={type}
@ -153,10 +151,8 @@ class NonInjectedDeploymentDetails extends React.Component<DeploymentDetailsProp
{`Last transition time: ${lastTransitionTime}`}
</p>
</>
)}
/>
);
})
)} />
))
}
</DrawerItem>
<PodDetailsTolerations workload={deployment}/>

View File

@ -30,104 +30,108 @@ export interface IconProps extends React.HTMLAttributes<any> {
disabled?: boolean;
}
export const Icon = Object.assign(
withTooltip((props: IconProps) => {
const ref = createRef<HTMLAnchorElement>();
export function isSvg(content: string): boolean {
// data-url for raw svg-icon
return String(content).includes("svg+xml");
}
const {
// skip passing props to icon's html element
className, href, link, material, svg, size, smallest, small, big,
disabled, sticker, active, focusable, children,
interactive, onClick, onKeyDown,
...elemProps
} = props;
const isInteractive = interactive ?? !!(onClick || href || link);
const RawIcon = withTooltip((props: IconProps) => {
const ref = createRef<HTMLAnchorElement>();
const boundOnClick = (event: React.MouseEvent) => {
if (!disabled) {
onClick?.(event);
const {
// skip passing props to icon's html element
className, href, link, material, svg, size, smallest, small, big,
disabled, sticker, active,
focusable = true,
children,
interactive, onClick, onKeyDown,
...elemProps
} = props;
const isInteractive = interactive ?? !!(onClick || href || link);
const boundOnClick = (event: React.MouseEvent) => {
if (!disabled) {
onClick?.(event);
}
};
const boundOnKeyDown = (event: React.KeyboardEvent<any>) => {
switch (event.nativeEvent.code) {
case "Space":
// fallthrough
case "Enter": {
ref.current?.click();
event.preventDefault();
break;
}
};
const boundOnKeyDown = (event: React.KeyboardEvent<any>) => {
switch (event.nativeEvent.code) {
case "Space":
// fallthrough
case "Enter": {
ref.current?.click();
event.preventDefault();
break;
}
}
onKeyDown?.(event);
};
let iconContent: ReactNode;
const iconProps: Partial<IconProps> = {
className: cssNames("Icon", className,
{ svg, material, interactive: isInteractive, disabled, sticker, active, focusable },
!size ? { smallest, small, big } : {},
),
onClick: isInteractive ? boundOnClick : undefined,
onKeyDown: isInteractive ? boundOnKeyDown : undefined,
tabIndex: isInteractive && focusable && !disabled ? 0 : undefined,
style: size ? { "--size": size + (isNumber(size) ? "px" : "") } as React.CSSProperties : undefined,
...elemProps,
};
// render as inline svg-icon
if (typeof svg === "string") {
const dataUrlPrefix = "data:image/svg+xml;base64,";
const svgIconDataUrl = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`);
const svgIconText = typeof svgIconDataUrl == "string" // decode xml from data-url
? decode(svgIconDataUrl.replace(dataUrlPrefix, "")) : "";
iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }} />;
}
// render as material-icon
if (typeof material === "string") {
iconContent = <span className="icon" data-icon-name={material}>{material}</span>;
}
onKeyDown?.(event);
};
// wrap icon's content passed from decorator
iconProps.children = (
<>
{iconContent}
let iconContent: ReactNode;
const iconProps: Partial<IconProps> = {
className: cssNames("Icon", className,
{ svg, material, interactive: isInteractive, disabled, sticker, active, focusable },
!size ? { smallest, small, big } : {},
),
onClick: isInteractive ? boundOnClick : undefined,
onKeyDown: isInteractive ? boundOnKeyDown : undefined,
tabIndex: isInteractive && focusable && !disabled ? 0 : undefined,
style: size ? { "--size": size + (isNumber(size) ? "px" : "") } as React.CSSProperties : undefined,
...elemProps,
};
// render as inline svg-icon
if (typeof svg === "string") {
const dataUrlPrefix = "data:image/svg+xml;base64,";
const svgIconDataUrl = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`);
const svgIconText = typeof svgIconDataUrl == "string" // decode xml from data-url
? decode(svgIconDataUrl.replace(dataUrlPrefix, ""))
: "";
iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }} />;
}
// render as material-icon
if (typeof material === "string") {
iconContent = <span className="icon" data-icon-name={material}>{material}</span>;
}
// wrap icon's content passed from decorator
iconProps.children = (
<>
{iconContent}
{children}
</>
);
// render icon type
if (link) {
const { className, children } = iconProps;
return (
<NavLink
className={className}
to={link}
ref={ref}
>
{children}
</>
</NavLink>
);
}
// render icon type
if (link) {
const { className, children } = iconProps;
if (href) {
return (
<a
{...iconProps}
href={href}
ref={ref}
/>
);
}
return (
<NavLink
className={className}
to={link}
ref={ref}
>
{children}
</NavLink>
);
}
return <i {...iconProps} ref={ref} />;
});
if (href) {
return (
<a
{...iconProps}
href={href}
ref={ref}
/>
);
}
return <i {...iconProps} ref={ref} />;
}),
{
// data-url for raw svg-icon
isSvg: (content: string) => String(content).includes("svg+xml"),
},
);
export const Icon = Object.assign(RawIcon, { isSvg });

View File

@ -28,7 +28,10 @@ import createEditResourceTabInjectable from "../dock/edit-resource/edit-resource
import hideDetailsInjectable from "../kube-detail-params/hide-details.injectable";
// TODO: Make tooltips free of side effects by making it deterministic
jest.mock("../tooltip");
jest.mock("../tooltip/tooltip");
jest.mock("../tooltip/withTooltip", () => ({
withTooltip: (target: any) => target,
}));
class SomeTestExtension extends LensRendererExtension {
constructor(

View File

@ -104,18 +104,14 @@ const NonInjectedKubeObjectMeta = observer(({
{ownerRefs?.length > 0 && (
<DrawerItem name="Controlled By" hidden={isHidden("ownerReferences")}>
{
ownerRefs.map(ref => {
const { name, kind } = ref;
const ownerDetailsUrl = getDetailsUrl(apiManager.lookupApiLink(ref, object));
return (
<p key={name}>
{kind}
{" "}
<Link to={ownerDetailsUrl}>{name}</Link>
</p>
);
})
ownerRefs.map(ref => (
<p key={ref.name}>
{`${ref.kind} `}
<Link to={getDetailsUrl(apiManager.lookupApiLink(ref, object))}>
{ref.name}
</Link>
</p>
))
}
</DrawerItem>
)}

View File

@ -164,6 +164,7 @@ class NonInjectedSelect<
value = null,
options,
isMulti,
id: inputId,
onChange,
...props
} = this.props;
@ -192,6 +193,7 @@ class NonInjectedSelect<
}),
...styles,
}}
inputId={inputId}
filterOption={defaultFilter} // This is done because the default filter crashes on symbols
isMulti={isMulti}
options={convertedOptions}

View File

@ -9,11 +9,12 @@ import React from "react";
import { cssNames } from "../../utils";
import { withTooltip } from "../tooltip";
export interface StatusBrickProps extends React.HTMLAttributes<any> {
export interface StatusBrickProps extends React.HTMLAttributes<HTMLDivElement> {
}
export const StatusBrick = withTooltip(({ className, ...elemProps }: StatusBrickProps) => (
<div
className={cssNames("StatusBrick", className)}
{...elemProps} />
{...elemProps}
/>
));

View File

@ -2,23 +2,48 @@
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import type { SetRequired } from "type-fest";
import type { Mutable, SetRequired } from "type-fest";
import catalogCategoryRegistryInjectable from "../../../common/catalog/category-registry.injectable";
import fileSystemProvisionerStoreInjectable from "../../../extensions/extension-loader/file-system-provisioner-store/file-system-provisioner-store.injectable";
import { lensExtensionDependencies } from "../../../extensions/lens-extension";
import { LensRendererExtension } from "../../../extensions/lens-renderer-extension";
import catalogEntityRegistryInjectable from "../../api/catalog/entity/registry.injectable";
import getExtensionPageParametersInjectable from "../../routes/get-extension-page-parameters.injectable";
import navigateToRouteInjectable from "../../routes/navigate-to-route.injectable";
import routesInjectable from "../../routes/routes.injectable";
import type { ApplicationBuilder } from "./get-application-builder";
export class TestExtension extends LensRendererExtension {}
export const getRendererExtensionFake = ({ id, ...rest }: SetRequired<Partial<LensRendererExtension>, "id">) => {
const instance = new TestExtension({
id,
absolutePath: "irrelevant",
isBundled: false,
isCompatible: false,
isEnabled: false,
manifest: { name: id, version: "some-version" },
manifestPath: "irrelevant",
});
export type FakeExtensionData = SetRequired<Partial<LensRendererExtension>, "id" | "name">;
Object.assign(instance, rest);
export const getRendererExtensionFakeFor = (builder: ApplicationBuilder) => (
function getRendererExtensionFake({ id, name, ...rest }: FakeExtensionData) {
const instance = new TestExtension({
id,
absolutePath: "irrelevant",
isBundled: false,
isCompatible: false,
isEnabled: false,
manifest: {
name,
version: "1.0.0",
},
manifestPath: "irrelevant",
});
Object.assign(instance, rest);
(instance as Mutable<LensRendererExtension>)[lensExtensionDependencies] = {
categoryRegistry: builder.dis.rendererDi.inject(catalogCategoryRegistryInjectable),
entityRegistry: builder.dis.rendererDi.inject(catalogEntityRegistryInjectable),
fileSystemProvisionerStore: builder.dis.rendererDi.inject(fileSystemProvisionerStoreInjectable),
getExtensionPageParameters: builder.dis.rendererDi.inject(getExtensionPageParametersInjectable),
navigateToRoute: builder.dis.rendererDi.inject(navigateToRouteInjectable),
routes: builder.dis.rendererDi.inject(routesInjectable),
};
return instance;
}
);
return instance;
};

View File

@ -7,7 +7,6 @@
import type { ReactNode } from "react";
import React, { useState } from "react";
import hoistNonReactStatics from "hoist-non-react-statics";
import type { TooltipProps } from "./tooltip";
import { Tooltip } from "./tooltip";
import { isReactNode } from "../../utils/isReactNode";
@ -21,11 +20,15 @@ export interface TooltipDecoratorProps {
* useful for displaying tooltips even when the target is "disabled"
*/
tooltipOverrideDisabled?: boolean;
id?: string | undefined;
id?: string;
children?: SingleOrMany<React.ReactNode>;
}
export function withTooltip<TargetProps extends Pick<TooltipDecoratorProps, "id" | "children">>(Target: React.FunctionComponent<TargetProps>): React.FunctionComponent<TargetProps & TooltipDecoratorProps> {
export function withTooltip<TargetProps>(
Target: TargetProps extends Pick<TooltipDecoratorProps, "id" | "children">
? React.FunctionComponent<TargetProps>
: never,
): React.FunctionComponent<TargetProps & TooltipDecoratorProps> {
const DecoratedComponent = (props: TargetProps & TooltipDecoratorProps) => {
// TODO: Remove side-effect to allow deterministic unit testing
const [defaultTooltipId] = useState(uniqueId("tooltip_target_"));
@ -62,7 +65,7 @@ export function withTooltip<TargetProps extends Pick<TooltipDecoratorProps, "id"
}
return (
<Target id={targetId} {...targetProps as TargetProps}>
<Target id={targetId} {...targetProps as any}>
{targetChildren}
</Target>
);
@ -70,5 +73,5 @@ export function withTooltip<TargetProps extends Pick<TooltipDecoratorProps, "id"
DecoratedComponent.displayName = `withTooltip(${Target.displayName || Target.name})`;
return hoistNonReactStatics(DecoratedComponent, Target);
return DecoratedComponent;
}

View File

@ -27,8 +27,8 @@ export function cssNames(...classNames: IClassName[]): string {
}
}
return iter.pipeline(classNamesEnabled)
return iter.pipeline(classNamesEnabled.entries())
.filter(([, isActive]) => !!isActive)
.map(([className]) => className.trim())
.filterMap(([className]) => className.trim())
.join(" ");
}