mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Tests table rendering
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
12920c89f9
commit
c8f8e448c1
@ -1,5 +1,230 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<PodDetailsList /> when few pods passed renders table with pods 1`] = `
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="PodDetailsList flex column"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="Table flex column box grow selectable sortable autoSize"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="TableHead sticky"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="TableCell name sorting"
|
||||||
|
>
|
||||||
|
Name
|
||||||
|
<i
|
||||||
|
class="Icon sortIcon material focusable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="arrow_drop_down"
|
||||||
|
>
|
||||||
|
arrow_drop_down
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell warning"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell node sorting"
|
||||||
|
>
|
||||||
|
Node
|
||||||
|
<i
|
||||||
|
class="Icon sortIcon material focusable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="arrow_drop_down"
|
||||||
|
>
|
||||||
|
arrow_drop_down
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell namespace sorting"
|
||||||
|
>
|
||||||
|
Namespace
|
||||||
|
<i
|
||||||
|
class="Icon sortIcon material focusable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="arrow_drop_down"
|
||||||
|
>
|
||||||
|
arrow_drop_down
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell ready"
|
||||||
|
>
|
||||||
|
Ready
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell cpu sorting"
|
||||||
|
>
|
||||||
|
CPU
|
||||||
|
<i
|
||||||
|
class="Icon sortIcon enabled material focusable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="arrow_drop_down"
|
||||||
|
>
|
||||||
|
arrow_drop_down
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell memory sorting"
|
||||||
|
>
|
||||||
|
Memory
|
||||||
|
<i
|
||||||
|
class="Icon sortIcon material focusable"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="icon"
|
||||||
|
data-icon-name="arrow_drop_down"
|
||||||
|
>
|
||||||
|
arrow_drop_down
|
||||||
|
</span>
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell status"
|
||||||
|
>
|
||||||
|
Status
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableRow nowrap"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="TableCell name"
|
||||||
|
>
|
||||||
|
foobar
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell warning"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell node"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell namespace"
|
||||||
|
>
|
||||||
|
default
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell ready"
|
||||||
|
>
|
||||||
|
0 / 0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell cpu"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell memory"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell status running"
|
||||||
|
>
|
||||||
|
Running
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableRow nowrap"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="TableCell name"
|
||||||
|
>
|
||||||
|
foobar-failed
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell warning"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell node"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell namespace"
|
||||||
|
>
|
||||||
|
default
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell ready"
|
||||||
|
>
|
||||||
|
0 / 0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell cpu"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell memory"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell status failed"
|
||||||
|
>
|
||||||
|
Failed
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableRow nowrap"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="TableCell name"
|
||||||
|
>
|
||||||
|
foobar-pending
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell warning"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell node"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="TableCell namespace"
|
||||||
|
>
|
||||||
|
default
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell ready"
|
||||||
|
>
|
||||||
|
0 / 0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell cpu"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell memory"
|
||||||
|
>
|
||||||
|
0
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="TableCell status waiting"
|
||||||
|
>
|
||||||
|
Waiting
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`<PodDetailsList /> when no pods passed and podStore is loaded renders 1`] = `
|
exports[`<PodDetailsList /> when no pods passed and podStore is loaded renders 1`] = `
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
@ -7,3 +232,15 @@ exports[`<PodDetailsList /> when no pods passed and podStore is loaded renders 1
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`<PodDetailsList /> when podStore is still loading renders spinner 1`] = `
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
class="PodDetailsList flex justify-center"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="Spinner singleColor"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|||||||
@ -7,7 +7,9 @@ import type { AsyncFnMock } from "@async-fn/jest";
|
|||||||
import asyncFn from "@async-fn/jest";
|
import asyncFn from "@async-fn/jest";
|
||||||
import type { DiContainer } from "@ogre-tools/injectable";
|
import type { DiContainer } from "@ogre-tools/injectable";
|
||||||
import React from "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";
|
import fetchInjectable, { Fetch } from "../../../../common/fetch/fetch.injectable";
|
||||||
|
import { Pod } from "../../../../common/k8s-api/endpoints";
|
||||||
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../../getDiForUnitTesting";
|
||||||
import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable";
|
import storesAndApisCanBeCreatedInjectable from "../../../stores-apis-can-be-created.injectable";
|
||||||
import { DiRender, renderFor } from "../../test-utils/renderFor";
|
import { DiRender, renderFor } from "../../test-utils/renderFor";
|
||||||
@ -15,6 +17,89 @@ import { PodDetailsList } from "../pod-details-list";
|
|||||||
import type { PodStore } from "../store";
|
import type { PodStore } from "../store";
|
||||||
import podStoreInjectable from "../store.injectable";
|
import podStoreInjectable from "../store.injectable";
|
||||||
|
|
||||||
|
const runningPod = new Pod({
|
||||||
|
apiVersion: "foo",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "foobar",
|
||||||
|
resourceVersion: "foobar",
|
||||||
|
uid: "foobar",
|
||||||
|
ownerReferences: [{
|
||||||
|
uid: "runningReplicaSet",
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "ReplicaSet",
|
||||||
|
name: "running",
|
||||||
|
}],
|
||||||
|
namespace: "default",
|
||||||
|
selfLink: "/apis/apps/v1/replicasets/default/foobar",
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
phase: "Running",
|
||||||
|
conditions: [
|
||||||
|
{
|
||||||
|
type: "Initialized",
|
||||||
|
status: "True",
|
||||||
|
lastProbeTime: 1,
|
||||||
|
lastTransitionTime: "1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "Ready",
|
||||||
|
status: "True",
|
||||||
|
lastProbeTime: 1,
|
||||||
|
lastTransitionTime: "1",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
hostIP: "10.0.0.1",
|
||||||
|
podIP: "10.0.0.1",
|
||||||
|
startTime: "now",
|
||||||
|
containerStatuses: [],
|
||||||
|
initContainerStatuses: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const pendingPod = new Pod({
|
||||||
|
apiVersion: "foo",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "foobar-pending",
|
||||||
|
resourceVersion: "foobar",
|
||||||
|
uid: "foobar-pending",
|
||||||
|
ownerReferences: [{
|
||||||
|
uid: "pendingReplicaSet",
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "ReplicaSet",
|
||||||
|
name: "pending",
|
||||||
|
}],
|
||||||
|
namespace: "default",
|
||||||
|
selfLink: "/apis/apps/v1/replicasets/default/foobar-pending",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const failedPod = new Pod({
|
||||||
|
apiVersion: "foo",
|
||||||
|
kind: "Pod",
|
||||||
|
metadata: {
|
||||||
|
name: "foobar-failed",
|
||||||
|
resourceVersion: "foobar",
|
||||||
|
uid: "foobar-failed",
|
||||||
|
ownerReferences: [{
|
||||||
|
uid: "failedReplicaSet",
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "ReplicaSet",
|
||||||
|
name: "failed",
|
||||||
|
}],
|
||||||
|
namespace: "default",
|
||||||
|
selfLink: "/apis/apps/v1/replicasets/default/foobar-failed",
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
phase: "Failed",
|
||||||
|
conditions: [],
|
||||||
|
hostIP: "10.0.0.1",
|
||||||
|
podIP: "10.0.0.1",
|
||||||
|
startTime: "now",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
describe("<PodDetailsList />", () => {
|
describe("<PodDetailsList />", () => {
|
||||||
let di: DiContainer;
|
let di: DiContainer;
|
||||||
let podStore: PodStore;
|
let podStore: PodStore;
|
||||||
@ -24,6 +109,10 @@ describe("<PodDetailsList />", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
di.override(storesAndApisCanBeCreatedInjectable, () => true);
|
di.override(storesAndApisCanBeCreatedInjectable, () => true);
|
||||||
|
di.override(
|
||||||
|
directoryForLensLocalStorageInjectable,
|
||||||
|
() => "/some-directory-for-lens-local-storage",
|
||||||
|
);
|
||||||
|
|
||||||
fetchMock = asyncFn();
|
fetchMock = asyncFn();
|
||||||
podStore = di.inject(podStoreInjectable);
|
podStore = di.inject(podStoreInjectable);
|
||||||
@ -58,4 +147,36 @@ describe("<PodDetailsList />", () => {
|
|||||||
expect(result.getByText("No items found")).toBeInTheDocument();
|
expect(result.getByText("No items found")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when podStore is still loading", () => {
|
||||||
|
it("renders spinner", () => {
|
||||||
|
const result = render(
|
||||||
|
<PodDetailsList
|
||||||
|
pods={[]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.container).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when few pods passed", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
podStore.isLoaded = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders table with pods", () => {
|
||||||
|
const result = render(
|
||||||
|
<PodDetailsList
|
||||||
|
pods={[
|
||||||
|
runningPod,
|
||||||
|
failedPod,
|
||||||
|
pendingPod,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result.container).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue
Block a user