mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding validatingwebhookconfigs tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
5694439440
commit
56795e0798
@ -0,0 +1,82 @@
|
||||
/**
|
||||
* 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 React from "react";
|
||||
import {
|
||||
MutatingWebhookConfiguration,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
import { MutatingWebhookDetails } from "./mutating-webhook-configurations-details";
|
||||
|
||||
const mutatingWebhookConfig = {
|
||||
apiVersion: "admissionregistration.k8s.io/v1",
|
||||
kind: "MutatingWebhookConfiguration",
|
||||
metadata: {
|
||||
name: "pod-policy.example.com",
|
||||
resourceVersion: "1",
|
||||
uid: "pod-policy.example.com",
|
||||
namespace: "default",
|
||||
selfLink: "/apis/admissionregistration.k8s.io/v1/pod-policy.example.com",
|
||||
},
|
||||
webhooks: [
|
||||
{
|
||||
name: "pod-policy.example.com",
|
||||
rules: [
|
||||
{
|
||||
apiGroups: ["", "apps", "extensions"],
|
||||
apiVersions: ["v1", "v1beta1"],
|
||||
operations: ["CREATE", "UPDATE"],
|
||||
resources: ["pods", "deployments"],
|
||||
},
|
||||
],
|
||||
failurePolicy: "Fail",
|
||||
admissionReviewVersions: ["v1", "v1beta1"],
|
||||
sideEffects: "None",
|
||||
clientConfig: {
|
||||
service: {
|
||||
namespace: "service-namespace",
|
||||
name: "service-name",
|
||||
},
|
||||
caBundle: "Cg==",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("MutatingWebhookConfigsDetails", () => {
|
||||
let result: RenderResult;
|
||||
let render: DiRender;
|
||||
|
||||
beforeEach(async () => {
|
||||
const di = getDiForUnitTesting();
|
||||
|
||||
render = renderFor(di);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
const webhookConfig = new MutatingWebhookConfiguration(mutatingWebhookConfig);
|
||||
|
||||
result = render(
|
||||
<MutatingWebhookDetails object={webhookConfig} />,
|
||||
);
|
||||
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders with no webhooks", () => {
|
||||
const webhookConfig = new MutatingWebhookConfiguration({
|
||||
...mutatingWebhookConfig,
|
||||
webhooks: [],
|
||||
});
|
||||
|
||||
result = render(
|
||||
<MutatingWebhookDetails object={webhookConfig} />,
|
||||
);
|
||||
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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 React from "react";
|
||||
import {
|
||||
ValidatingWebhookConfiguration,
|
||||
} from "../../../common/k8s-api/endpoints";
|
||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||
import type { DiRender } from "../test-utils/renderFor";
|
||||
import { renderFor } from "../test-utils/renderFor";
|
||||
import { ValidatingWebhookDetails } from "./validating-webhook-configurations-details";
|
||||
|
||||
const validatingWebhookConfig = {
|
||||
apiVersion: "admissionregistration.k8s.io/v1",
|
||||
kind: "ValidatingWebhookConfiguration",
|
||||
metadata: {
|
||||
name: "pod-policy.example.com",
|
||||
resourceVersion: "1",
|
||||
uid: "pod-policy.example.com",
|
||||
namespace: "default",
|
||||
selfLink: "/apis/admissionregistration.k8s.io/v1/pod-policy.example.com",
|
||||
},
|
||||
webhooks: [
|
||||
{
|
||||
name: "pod-policy.example.com",
|
||||
rules: [
|
||||
{
|
||||
apiGroups: ["", "apps", "extensions"],
|
||||
apiVersions: ["v1", "v1beta1"],
|
||||
operations: ["CREATE", "UPDATE"],
|
||||
resources: ["pods", "deployments"],
|
||||
},
|
||||
],
|
||||
failurePolicy: "Fail",
|
||||
admissionReviewVersions: ["v1", "v1beta1"],
|
||||
sideEffects: "None",
|
||||
timeoutSeconds: 5,
|
||||
clientConfig: {
|
||||
service: {
|
||||
namespace: "service-namespace",
|
||||
name: "service-name",
|
||||
},
|
||||
caBundle: "Cg==",
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("ValidatingWebhookConfigsDetails", () => {
|
||||
let result: RenderResult;
|
||||
let render: DiRender;
|
||||
|
||||
beforeEach(async () => {
|
||||
const di = getDiForUnitTesting();
|
||||
|
||||
render = renderFor(di);
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
const webhookConfig = new ValidatingWebhookConfiguration(validatingWebhookConfig);
|
||||
|
||||
result = render(
|
||||
<ValidatingWebhookDetails object={webhookConfig} />,
|
||||
);
|
||||
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders with no webhooks", () => {
|
||||
const webhookConfig = new ValidatingWebhookConfiguration({
|
||||
...validatingWebhookConfig,
|
||||
webhooks: [],
|
||||
});
|
||||
|
||||
result = render(
|
||||
<ValidatingWebhookDetails object={webhookConfig} />,
|
||||
);
|
||||
|
||||
expect(result.baseElement).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@ -366,6 +366,18 @@ const scenarios = [
|
||||
parentSidebarItemTestId: null,
|
||||
sidebarItemTestId: "sidebar-item-link-for-custom-resources",
|
||||
},
|
||||
|
||||
{
|
||||
expectedSelector: "h5.title",
|
||||
parentSidebarItemTestId: "sidebar-item-link-for-config",
|
||||
sidebarItemTestId: "sidebar-item-link-for-validating-webhook-configurations",
|
||||
},
|
||||
|
||||
{
|
||||
expectedSelector: "h5.title",
|
||||
parentSidebarItemTestId: "sidebar-item-link-for-config",
|
||||
sidebarItemTestId: "sidebar-item-link-for-mutating-webhook-configurations",
|
||||
},
|
||||
];
|
||||
|
||||
const navigateToPods = async (frame: Frame) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user