diff --git a/src/renderer/components/+workloads-pods/__tests__/__snapshots__/pod-details-list.test.tsx.snap b/src/renderer/components/+workloads-pods/__tests__/__snapshots__/pod-details-list.test.tsx.snap index ed36d9c9f3..82c0fca3ba 100644 --- a/src/renderer/components/+workloads-pods/__tests__/__snapshots__/pod-details-list.test.tsx.snap +++ b/src/renderer/components/+workloads-pods/__tests__/__snapshots__/pod-details-list.test.tsx.snap @@ -5,6 +5,11 @@ exports[` when few pods passed renders table with pods 1`] = `
+
+ Pods +
@@ -157,7 +162,7 @@ exports[` when few pods passed renders table with pods 1`] = `
- default + kube-system
when few pods passed renders table with pods 1`] = `
`; +exports[` when few pods passed when metrics max values passed renders table with metric lines 1`] = ` +
+
+
+ Pods +
+
+
+
+ Name + + + arrow_drop_down + + +
+
+
+ Node + + + arrow_drop_down + + +
+
+ Namespace + + + arrow_drop_down + + +
+
+ Ready +
+
+ CPU + + + arrow_drop_down + + +
+
+ Memory + + + arrow_drop_down + + +
+
+ Status +
+
+
+
+ foobar-pending +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 50% +
+ 0.500 +

+
+
+
+
+
+
+
+

+ Memory: 13% +
+ 256.000B +

+
+
+
+ Waiting +
+
+
+
+ foobar-failed +
+
+
+
+ kube-system +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 40% +
+ 0.400 +

+
+
+
+
+
+
+
+

+ Memory: 50% +
+ 1.000KiB +

+
+
+
+ Failed +
+
+
+
+ foobar +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 20% +
+ 0.200 +

+
+
+
+
+
+
+
+

+ Memory: 7% +
+ 128.000B +

+
+
+
+ Running +
+
+
+
+
+`; + +exports[` when few pods passed when metrics max values passed sort table by name 1`] = ` +
+
+
+ Pods +
+
+
+
+ Name + + + arrow_drop_down + + +
+
+
+ Node + + + arrow_drop_down + + +
+
+ Namespace + + + arrow_drop_down + + +
+
+ Ready +
+
+ CPU + + + arrow_drop_down + + +
+
+ Memory + + + arrow_drop_down + + +
+
+ Status +
+
+
+
+ foobar-pending +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 50% +
+ 0.500 +

+
+
+
+
+
+
+
+

+ Memory: 13% +
+ 256.000B +

+
+
+
+ Waiting +
+
+
+
+ foobar-failed +
+
+
+
+ kube-system +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 40% +
+ 0.400 +

+
+
+
+
+
+
+
+

+ Memory: 50% +
+ 1.000KiB +

+
+
+
+ Failed +
+
+
+
+ foobar +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 20% +
+ 0.200 +

+
+
+
+
+
+
+
+

+ Memory: 7% +
+ 128.000B +

+
+
+
+ Running +
+
+
+
+
+`; + +exports[` when few pods passed when metrics max values passed sorts table by cpu 1`] = ` +
+
+
+ Pods +
+
+
+
+ Name + + + arrow_drop_down + + +
+
+
+ Node + + + arrow_drop_down + + +
+
+ Namespace + + + arrow_drop_down + + +
+
+ Ready +
+
+ CPU + + + arrow_drop_down + + +
+
+ Memory + + + arrow_drop_down + + +
+
+ Status +
+
+
+
+ foobar-pending +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 50% +
+ 0.500 +

+
+
+
+
+
+
+
+

+ Memory: 13% +
+ 256.000B +

+
+
+
+ Waiting +
+
+
+
+ foobar-failed +
+
+
+
+ kube-system +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 40% +
+ 0.400 +

+
+
+
+
+
+
+
+

+ Memory: 50% +
+ 1.000KiB +

+
+
+
+ Failed +
+
+
+
+ foobar +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 20% +
+ 0.200 +

+
+
+
+
+
+
+
+

+ Memory: 7% +
+ 128.000B +

+
+
+
+ Running +
+
+
+
+
+`; + +exports[` when few pods passed when metrics max values passed sorts table by memory 1`] = ` +
+
+
+ Pods +
+
+
+
+ Name + + + arrow_drop_down + + +
+
+
+ Node + + + arrow_drop_down + + +
+
+ Namespace + + + arrow_drop_down + + +
+
+ Ready +
+
+ CPU + + + arrow_drop_down + + +
+
+ Memory + + + arrow_drop_down + + +
+
+ Status +
+
+
+
+ foobar-failed +
+
+
+
+ kube-system +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 40% +
+ 0.400 +

+
+
+
+
+
+
+
+

+ Memory: 50% +
+ 1.000KiB +

+
+
+
+ Failed +
+
+
+
+ foobar-pending +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 50% +
+ 0.500 +

+
+
+
+
+
+
+
+

+ Memory: 13% +
+ 256.000B +

+
+
+
+ Waiting +
+
+
+
+ foobar +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 20% +
+ 0.200 +

+
+
+
+
+
+
+
+

+ Memory: 7% +
+ 128.000B +

+
+
+
+ Running +
+
+
+
+
+`; + +exports[` when few pods passed when metrics max values passed sorts table by name 1`] = ` +
+
+
+ Pods +
+
+
+
+ Name + + + arrow_drop_down + + +
+
+
+ Node + + + arrow_drop_down + + +
+
+ Namespace + + + arrow_drop_down + + +
+
+ Ready +
+
+ CPU + + + arrow_drop_down + + +
+
+ Memory + + + arrow_drop_down + + +
+
+ Status +
+
+
+
+ foobar-pending +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 50% +
+ 0.500 +

+
+
+
+
+
+
+
+

+ Memory: 13% +
+ 256.000B +

+
+
+
+ Waiting +
+
+
+
+ foobar-failed +
+
+
+
+ kube-system +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 40% +
+ 0.400 +

+
+
+
+
+
+
+
+

+ Memory: 50% +
+ 1.000KiB +

+
+
+
+ Failed +
+
+
+
+ foobar +
+
+
+
+ default +
+
+ 0 / 0 +
+
+
+
+
+
+

+ CPU: 20% +
+ 0.200 +

+
+
+
+
+
+
+
+

+ Memory: 7% +
+ 128.000B +

+
+
+
+ Running +
+
+
+
+
+`; + exports[` when no pods passed and podStore is loaded renders 1`] = `
diff --git a/src/renderer/components/+workloads-pods/__tests__/pod-details-list.test.tsx b/src/renderer/components/+workloads-pods/__tests__/pod-details-list.test.tsx index a2084637a8..194a88019a 100644 --- a/src/renderer/components/+workloads-pods/__tests__/pod-details-list.test.tsx +++ b/src/renderer/components/+workloads-pods/__tests__/pod-details-list.test.tsx @@ -6,6 +6,7 @@ import type { AsyncFnMock } from "@async-fn/jest"; import asyncFn from "@async-fn/jest"; import type { DiContainer } from "@ogre-tools/injectable"; +import { fireEvent } from "@testing-library/react"; import React from "react"; import directoryForLensLocalStorageInjectable from "../../../../common/directory-for-lens-local-storage/directory-for-lens-local-storage.injectable"; import fetchInjectable, { Fetch } from "../../../../common/fetch/fetch.injectable"; @@ -88,7 +89,7 @@ const failedPod = new Pod({ kind: "ReplicaSet", name: "failed", }], - namespace: "default", + namespace: "kube-system", selfLink: "/apis/apps/v1/replicasets/default/foobar-failed", }, status: { @@ -178,5 +179,108 @@ describe("", () => { expect(result.container).toMatchSnapshot(); }); + + describe("when metrics max values passed", () => { + beforeEach(() => { + podStore.getPodKubeMetrics = (pod: Pod) => { + let cpu = 0.4; + let memory = 1024; + + switch(pod.getId()) { + case "foobar": + cpu = 0.2; + memory = 128; + break; + case "foobar-pending": + cpu = 0.5; + memory = 256; + } + + return { + cpu, + memory + } + }; + }); + + it("renders table with metric lines", () => { + const result = render( + + ); + + expect(result.container).toMatchSnapshot(); + }); + + it("sorts table by name", () => { + const result = render( + + ); + + const column = result.getByText("Name"); + + fireEvent.click(column); + fireEvent.click(column); + + expect(result.container).toMatchSnapshot(); + }); + + it("sorts table by cpu", () => { + const result = render( + + ); + + const column = result.getByText("CPU"); + + fireEvent.click(column); + fireEvent.click(column); + + expect(result.container).toMatchSnapshot(); + }); + + it("sorts table by memory", () => { + const result = render( + + ); + + const column = result.getByText("Memory"); + + fireEvent.click(column); + fireEvent.click(column); + + expect(result.container).toMatchSnapshot(); + }); + }); }); }); \ No newline at end of file