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

Linter fixes

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2023-01-25 16:15:17 +03:00
parent c4bbc289ad
commit e3fcc99ef1
2 changed files with 45 additions and 162 deletions

View File

@ -81,128 +81,6 @@ exports[`<HpaDetails/> renders 1`] = `
</body> </body>
`; `;
exports[`<HpaDetails/> shows nothing with lack of metric type 1`] = `
<body>
<div>
<div
class="HpaDetails"
>
<div
class="DrawerItem"
>
<span
class="name"
>
Reference
</span>
<span
class="value"
>
Deployment
/
hpav2deployment
</span>
</div>
<div
class="DrawerItem"
>
<span
class="name"
>
Min Pods
</span>
<span
class="value"
>
0
</span>
</div>
<div
class="DrawerItem"
>
<span
class="name"
>
Max Pods
</span>
<span
class="value"
>
10
</span>
</div>
<div
class="DrawerItem"
>
<span
class="name"
>
Replicas
</span>
<span
class="value"
>
0
</span>
</div>
<div
class="DrawerItem status labelsOnly"
>
<span
class="name"
>
Status
</span>
<span
class="value"
/>
</div>
<div
class="DrawerTitle title"
>
Metrics
</div>
<div
class="metrics"
>
<div
class="Table flex column scrollable autoSize"
>
<div
class="TableHead sticky flat"
>
<div
class="TableCell name"
>
Name
</div>
<div
class="TableCell metrics"
>
Current / Target
</div>
</div>
<div
class="TableRow"
>
<div
class="TableCell name"
>
unknown
</div>
<div
class="TableCell metrics"
>
unknown / unknown
</div>
</div>
</div>
</div>
</div>
</div>
</body>
`;
exports[`<HpaDetails/> shows unknown metrics with lack of metric type 1`] = ` exports[`<HpaDetails/> shows unknown metrics with lack of metric type 1`] = `
<body> <body>
<div> <div>

View File

@ -1,8 +1,13 @@
/**
* 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 { RenderResult } from "@testing-library/react";
import React from "react"; import React from "react";
import { HorizontalPodAutoscaler, HpaMetricType } from "../../../common/k8s-api/endpoints"; import { HorizontalPodAutoscaler, HpaMetricType } from "../../../common/k8s-api/endpoints";
import { getDiForUnitTesting } from "../../getDiForUnitTesting"; import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import { DiRender, renderFor } from "../test-utils/renderFor"; import type { DiRender } from "../test-utils/renderFor";
import { renderFor } from "../test-utils/renderFor";
import { HpaDetails } from "./hpa-details"; import { HpaDetails } from "./hpa-details";
jest.mock("react-router-dom", () => ({ jest.mock("react-router-dom", () => ({
@ -43,8 +48,8 @@ describe("<HpaDetails/>", () => {
const hpa = new HorizontalPodAutoscaler(hpaV2); const hpa = new HorizontalPodAutoscaler(hpaV2);
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.baseElement).toMatchSnapshot(); expect(result.baseElement).toMatchSnapshot();
}); });
@ -53,8 +58,8 @@ describe("<HpaDetails/>", () => {
const hpa = new HorizontalPodAutoscaler(hpaV2); const hpa = new HorizontalPodAutoscaler(hpaV2);
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.queryByTestId("hpa-metrics")).toBeNull(); expect(result.queryByTestId("hpa-metrics")).toBeNull();
}); });
@ -82,11 +87,11 @@ describe("<HpaDetails/>", () => {
}); });
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("CPU Utilization percentage")).toBeInTheDocument(); expect(result.getByText("CPU Utilization percentage")).toBeInTheDocument();
}) });
it("shows proper metric name for container resource metrics", () => { it("shows proper metric name for container resource metrics", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -112,11 +117,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("Resource cpu on Pods")).toBeInTheDocument(); expect(result.getByText("Resource cpu on Pods")).toBeInTheDocument();
}) });
it("shows proper metric name for resource metrics", () => { it("shows proper metric name for resource metrics", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -141,11 +146,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("Resource cpu on Pods")).toBeInTheDocument(); expect(result.getByText("Resource cpu on Pods")).toBeInTheDocument();
}) });
it("shows proper metric name for pod metrics for hpa v2", () => { it("shows proper metric name for pod metrics for hpa v2", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -172,11 +177,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("packets-per-second on Pods")).toBeInTheDocument(); expect(result.getByText("packets-per-second on Pods")).toBeInTheDocument();
}) });
it("shows proper metric name for pod metrics for hpa v2beta1", () => { it("shows proper metric name for pod metrics for hpa v2beta1", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -197,11 +202,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("packets-per-second on Pods")).toBeInTheDocument(); expect(result.getByText("packets-per-second on Pods")).toBeInTheDocument();
}) });
it("shows proper metric name for object metrics for hpa v2", () => { it("shows proper metric name for object metrics for hpa v2", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -224,7 +229,7 @@ describe("<HpaDetails/>", () => {
kind: "Service", kind: "Service",
name: "nginx", name: "nginx",
apiVersion: "v1", apiVersion: "v1",
} },
}, },
}, },
], ],
@ -233,11 +238,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText(/requests-per-second/)).toHaveTextContent("requests-per-second onService/nginx"); expect(result.getByText(/requests-per-second/)).toHaveTextContent("requests-per-second onService/nginx");
}) });
it("shows proper metric name for object metrics for hpa v2beta1", () => { it("shows proper metric name for object metrics for hpa v2beta1", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -258,11 +263,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("requests-per-second")).toBeInTheDocument(); expect(result.getByText("requests-per-second")).toBeInTheDocument();
}) });
it("shows proper metric name for external metrics for hpa v2", () => { it("shows proper metric name for external metrics for hpa v2", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -292,11 +297,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("queue_messages_ready on {\"matchLabels\":{\"queue\":\"worker_tasks\"}}")).toBeInTheDocument(); expect(result.getByText("queue_messages_ready on {\"matchLabels\":{\"queue\":\"worker_tasks\"}}")).toBeInTheDocument();
}) });
it("shows proper metric name for external metrics for hpa v2beta1", () => { it("shows proper metric name for external metrics for hpa v2beta1", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -311,7 +316,7 @@ describe("<HpaDetails/>", () => {
metricName: "queue_messages_ready", metricName: "queue_messages_ready",
metricSelector: { metricSelector: {
matchLabels: { queue: "worker_tasks" }, matchLabels: { queue: "worker_tasks" },
} },
}, },
}, },
], ],
@ -320,11 +325,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.getByText("queue_messages_ready on {\"matchLabels\":{\"queue\":\"worker_tasks\"}}")).toBeInTheDocument(); expect(result.getByText("queue_messages_ready on {\"matchLabels\":{\"queue\":\"worker_tasks\"}}")).toBeInTheDocument();
}) });
it("shows unknown metrics with lack of metric type", () => { it("shows unknown metrics with lack of metric type", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -349,11 +354,11 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.baseElement).toMatchSnapshot(); expect(result.baseElement).toMatchSnapshot();
}) });
it("shows unknown metrics with with unusual type", () => { it("shows unknown metrics with with unusual type", () => {
const hpa = new HorizontalPodAutoscaler( const hpa = new HorizontalPodAutoscaler(
@ -379,9 +384,9 @@ describe("<HpaDetails/>", () => {
); );
result = render( result = render(
<HpaDetails object={hpa} /> <HpaDetails object={hpa} />,
) );
expect(result.baseElement).toMatchSnapshot(); expect(result.baseElement).toMatchSnapshot();
}) });
}); });