mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Support Events on CustomResourece details panel Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove unnecessary check Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove legacy KubeObjectMeta use from non-metrics details Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change orderNumber of default KubeMetaDetails Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove last use of legacy global getActiveClusterEntity Signed-off-by: Sebastian Malton <sebastian@malton.name> * Refactor ResourceMetrics to use IAsyncComputed - Introduce first use for namespace metrics Signed-off-by: Sebastian Malton <sebastian@malton.name> * Introduce metrics details item for Ingress Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove legacyStore for nodes Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove legacyStore for ingresses Signed-off-by: Sebastian Malton <sebastian@malton.name> * Replace NodeMetrics in details with injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change namespace metrics details to use more injectables Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change ingress metrics details to use more injectables Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change PersistentVolumeClaim metrics to be injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change DaemonSet metrics to be injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change Deployment metrics to be injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Change Job metrics to be injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Convert Pod metrics to be injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Make ReplicaSet metrics details injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Make StatefulSet metrics component injectable Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Introduce fix for metrics components visible on all details Signed-off-by: Sebastian Malton <sebastian@malton.name> * Use the new and correct enabled check Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove legacy global for daemonSetStore Signed-off-by: Sebastian Malton <sebastian@malton.name> * Switch components to be static to help with React performance Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove legacy store of CronJobs Signed-off-by: Sebastian Malton <sebastian@malton.name> * Make DeploymentReplicaSets injectable to fix build error Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix up remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Allow use of ResourceMetrics without IAsyncComputed Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix metrics not updating correctly Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update snapshots because moving KubeObjectMeta out of CustomResourceDetails Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix tests Signed-off-by: Sebastian Malton <sebastian@malton.name> * Update more snapshots Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix test failures due to newer dep versions Signed-off-by: Sebastian Malton <sebastian@malton.name> * Fix type errors from new asyncComputed Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
134 lines
4.2 KiB
TypeScript
134 lines
4.2 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import type { RenderResult } from "@testing-library/react";
|
|
import type { ApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
|
import { getApplicationBuilder } from "../../../../renderer/components/test-utils/get-application-builder";
|
|
import { getInjectable } from "@ogre-tools/injectable";
|
|
import { frontEndRouteInjectionToken } from "../../../../common/front-end-routing/front-end-route-injection-token";
|
|
import type { IObservableValue } from "mobx";
|
|
import { runInAction, computed, observable } from "mobx";
|
|
import React from "react";
|
|
import { navigateToRouteInjectionToken } from "../../../../common/front-end-routing/navigate-to-route-injection-token";
|
|
import { routeSpecificComponentInjectionToken } from "../../../../renderer/routes/route-specific-component-injection-token";
|
|
import { KubeObject } from "../../../../common/k8s-api/kube-object";
|
|
import apiManagerInjectable from "../../../../common/k8s-api/api-manager/manager.injectable";
|
|
import { KubeObjectDetails } from "../../../../renderer/components/kube-object-details";
|
|
import type { ApiManager } from "../../../../common/k8s-api/api-manager";
|
|
import type { KubeObjectStore } from "../../../../common/k8s-api/kube-object.store";
|
|
|
|
describe("reactively hide kube object detail item", () => {
|
|
let builder: ApplicationBuilder;
|
|
let rendered: RenderResult;
|
|
let someObservable: IObservableValue<boolean>;
|
|
|
|
beforeEach(async () => {
|
|
builder = getApplicationBuilder();
|
|
|
|
builder.setEnvironmentToClusterFrame();
|
|
|
|
builder.beforeWindowStart((windowDi) => {
|
|
windowDi.override(apiManagerInjectable, () => ({
|
|
getStore: () => ({
|
|
loadFromPath: async () => getKubeObjectStub("some-kind", "some-api-version"),
|
|
}) as Partial<KubeObjectStore> as KubeObjectStore,
|
|
}) as Partial<ApiManager> as ApiManager);
|
|
|
|
runInAction(() => {
|
|
windowDi.register(testRouteInjectable, testRouteComponentInjectable);
|
|
});
|
|
});
|
|
|
|
someObservable = observable.box(false);
|
|
|
|
const testExtension = {
|
|
id: "test-extension-id",
|
|
name: "test-extension",
|
|
|
|
rendererOptions: {
|
|
kubeObjectDetailItems: [
|
|
{
|
|
kind: "some-kind",
|
|
apiVersions: ["some-api-version"],
|
|
|
|
components: {
|
|
Details: () => (
|
|
<div data-testid="some-kube-object-detail-item">
|
|
Some detail
|
|
</div>
|
|
),
|
|
},
|
|
|
|
visible: computed(() => someObservable.get()),
|
|
},
|
|
],
|
|
},
|
|
};
|
|
|
|
rendered = await builder.render();
|
|
|
|
const windowDi = builder.applicationWindow.only.di;
|
|
|
|
const navigateToRoute = windowDi.inject(navigateToRouteInjectionToken);
|
|
const testRoute = windowDi.inject(testRouteInjectable);
|
|
|
|
navigateToRoute(testRoute);
|
|
|
|
builder.extensions.enable(testExtension);
|
|
});
|
|
|
|
it("does not show the kube object detail item", () => {
|
|
const actual = rendered.queryByTestId("some-kube-object-detail-item");
|
|
|
|
expect(actual).not.toBeInTheDocument();
|
|
});
|
|
|
|
it("given item should be shown, shows the kube object detail item", () => {
|
|
runInAction(() => {
|
|
someObservable.set(true);
|
|
});
|
|
|
|
const actual = rendered.queryByTestId("some-kube-object-detail-item");
|
|
|
|
expect(actual).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
const testRouteInjectable = getInjectable({
|
|
id: "test-route",
|
|
|
|
instantiate: () => ({
|
|
path: "/test-route",
|
|
clusterFrame: true,
|
|
isEnabled: computed(() => true),
|
|
}),
|
|
|
|
injectionToken: frontEndRouteInjectionToken,
|
|
});
|
|
|
|
const testRouteComponentInjectable = getInjectable({
|
|
id: "test-route-component",
|
|
|
|
instantiate: (di) => ({
|
|
route: di.inject(testRouteInjectable),
|
|
|
|
Component: () => <KubeObjectDetails />,
|
|
}),
|
|
|
|
injectionToken: routeSpecificComponentInjectionToken,
|
|
});
|
|
|
|
const getKubeObjectStub = (kind: string, apiVersion: string) =>
|
|
KubeObject.create({
|
|
apiVersion,
|
|
kind,
|
|
metadata: {
|
|
uid: "some-uid",
|
|
name: "some-name",
|
|
resourceVersion: "some-resource-version",
|
|
namespace: "some-namespace",
|
|
selfLink: "",
|
|
},
|
|
});
|