diff --git a/src/pages/features/gateway/api/list/APIList.tsx b/src/pages/features/gateway/api/list/APIList.tsx
index 4e63ef66..1d6f30a6 100644
--- a/src/pages/features/gateway/api/list/APIList.tsx
+++ b/src/pages/features/gateway/api/list/APIList.tsx
@@ -115,7 +115,7 @@ export default function APIList() {
Are you sure you want to delete this Api ?
diff --git a/src/pages/features/gateway/common-settings/global-limit/GlobalLimit.test.tsx b/src/pages/features/gateway/common-settings/global-limit/GlobalLimit.test.tsx
new file mode 100644
index 00000000..06576223
--- /dev/null
+++ b/src/pages/features/gateway/common-settings/global-limit/GlobalLimit.test.tsx
@@ -0,0 +1,17 @@
+import { render } from "@testing-library/react";
+import React from "react";
+import "@testing-library/jest-dom/extend-expect";
+import { Provider } from "react-redux";
+import { BrowserRouter } from "react-router-dom";
+import store from "../../../../../store";
+import GlobalLimit from "./GlobalLimit";
+
+it("render without crashing GlobalLimit", () => {
+ render(
+
+
+
+
+
+ );
+});
diff --git a/src/pages/features/gateway/key/list/KeyList.test.tsx b/src/pages/features/gateway/key/list/KeyList.test.tsx
deleted file mode 100644
index a31afc17..00000000
--- a/src/pages/features/gateway/key/list/KeyList.test.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { render } from "@testing-library/react";
-import axios from "axios";
-import MockAdapter from "axios-mock-adapter";
-import React from "react";
-import "@testing-library/jest-dom/extend-expect";
-import { Provider } from "react-redux";
-import { BrowserRouter } from "react-router-dom";
-import store from "../../../../../store/index";
-import KeyList from "./KeyList";
-
-const mockApi = new MockAdapter(axios);
-
-it("render without crashing Tenant list", () => {
- mockApi.onGet("/api/tenants?isDeleted=false&page=1").reply(200, {
- data: [
- {
- Id: "9dd100136a6a4e00af04bcece0eb1c8a",
- KeyName: "key1",
- IsActive: true,
- Expires: 0,
- Policies: [],
- CreatedDate: "2022-07-07T14:09:40.405677+00:00",
- },
- ],
- count: 1,
- });
- render(
-
-
-
-
-
- );
-});
-
-// {
-// "TotalCount": 1,
-// "Page": 0,
-// "PageSize": 0,
-// "Succeeded": true,
-// "Message": null,
-// "Errors": null,
-// "Data": {
-// "Keys": [
-// {
-// "Id": "9dd100136a6a4e00af04bcece0eb1c8a",
-// "KeyName": "key1",
-// "IsActive": true,
-// "Expires": null,
-// "Policies": [],
-// "CreatedDate": "2022-07-07T14:09:40.405677+00:00"
-// }
-// ]
-// }
-// }
diff --git a/src/pages/features/gateway/policy/create/CreatePolicy.test.tsx b/src/pages/features/gateway/policy/create/CreatePolicy.test.tsx
index 1f7f938b..dae34c2c 100644
--- a/src/pages/features/gateway/policy/create/CreatePolicy.test.tsx
+++ b/src/pages/features/gateway/policy/create/CreatePolicy.test.tsx
@@ -1,18 +1,55 @@
-import { render, screen } from "@testing-library/react";
+import { fireEvent, render, screen } from "@testing-library/react";
import React from "react";
import "@testing-library/jest-dom/extend-expect";
import { Provider } from "react-redux";
import { BrowserRouter } from "react-router-dom";
-import store from "../../../../../store";
import CreatePolicy from "./CreatePolicy";
+import { store } from "./access-rights/api-access-rights/AccessList.test";
-it("render without crashing CreatePolicy", async () => {
- await render(
-
-
-
-
-
- );
- expect(screen).toBeDefined();
+describe("Create policy component", () => {
+ it("render without crashing CreatePolicy", () => {
+ render(
+
+
+
+
+
+ );
+ });
+ it("check all buttons and inputs", () => {
+ render(
+
+
+
+
+
+ );
+ const createPolicyHeading = screen.getByText("CREATE POLICY");
+ expect(createPolicyHeading).toBeInTheDocument();
+
+ const cancelBtn = screen.getByText("Cancel");
+ expect(cancelBtn).toBeInTheDocument();
+ fireEvent.click(cancelBtn);
+
+ const formInput = screen.getByTestId("form-input");
+ expect(formInput).toBeInTheDocument();
+ fireEvent.submit(formInput);
+
+ const accessRightsTab = screen.getByRole("tab", { name: "Access Rights" });
+ fireEvent.click(accessRightsTab);
+ expect(screen.getByRole("tab", { selected: true })).toHaveTextContent(
+ "Access Rights"
+ );
+
+ const globalRateLimitHeading = screen.getByText("GlobalRateLimit");
+ expect(globalRateLimitHeading).toBeInTheDocument();
+
+ const ConfigurationsTab = screen.getByRole("tab", {
+ name: "Configurations",
+ });
+ fireEvent.click(ConfigurationsTab);
+ expect(screen.getByRole("tab", { selected: true })).toHaveTextContent(
+ "Configurations"
+ );
+ });
});
diff --git a/src/pages/features/gateway/policy/create/access-rights/api-access-rights/AccessList.test.tsx b/src/pages/features/gateway/policy/create/access-rights/api-access-rights/AccessList.test.tsx
index c503f6ef..30a0f1cd 100644
--- a/src/pages/features/gateway/policy/create/access-rights/api-access-rights/AccessList.test.tsx
+++ b/src/pages/features/gateway/policy/create/access-rights/api-access-rights/AccessList.test.tsx
@@ -8,7 +8,7 @@ import thunk from "redux-thunk";
import AccessList from "./AccessList";
const mockStore = configureStore([thunk]);
-const store = mockStore({
+export const store = mockStore({
createPolicyState: {
loading: false,
data: {
@@ -25,7 +25,7 @@ const store = mockStore({
State: "active",
KeyExpiresIn: 0,
Tags: [],
- APIs: [],
+ APIs: ["api1", "api2"],
Partitions: {
quota: false,
rate_limit: false,
@@ -34,7 +34,24 @@ const store = mockStore({
per_api: true,
},
},
+ errors: {
+ Name: "",
+ Policies: "",
+ GlobalLimit: {
+ ApiId: "",
+ ApiName: "",
+ Per: "",
+ Rate: "",
+ Quota: "",
+ Expires: "",
+ QuotaRenewalRate: "",
+ ThrottleInterval: "",
+ ThrottleRetries: "",
+ },
+ PerApiLimit: [],
+ },
},
+ error: undefined,
},
apiListState: {
loading: false,