Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway/sprint 21 #361

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/features/gateway/api/list/APIList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function APIList() {
<Modal.Body>Are you sure you want to delete this Api ?</Modal.Body>
<Modal.Footer>
<Button
data-testid="delete-input"
data-testid="cancel-input"
variant="secondary"
onClick={handleCancel}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
<BrowserRouter>
<Provider store={store}>
<GlobalLimit isDisabled={true} msg={""} />
</Provider>
</BrowserRouter>
);
});
55 changes: 0 additions & 55 deletions src/pages/features/gateway/key/list/KeyList.test.tsx

This file was deleted.

59 changes: 48 additions & 11 deletions src/pages/features/gateway/policy/create/CreatePolicy.test.tsx
Original file line number Diff line number Diff line change
@@ -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(
<BrowserRouter>
<Provider store={store}>
<CreatePolicy />
</Provider>
</BrowserRouter>
);
expect(screen).toBeDefined();
describe("Create policy component", () => {
it("render without crashing CreatePolicy", () => {
render(
<BrowserRouter>
<Provider store={store}>
<CreatePolicy />
</Provider>
</BrowserRouter>
);
});
it("check all buttons and inputs", () => {
render(
<BrowserRouter>
<Provider store={store}>
<CreatePolicy />
</Provider>
</BrowserRouter>
);
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"
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -25,7 +25,7 @@ const store = mockStore({
State: "active",
KeyExpiresIn: 0,
Tags: [],
APIs: [],
APIs: ["api1", "api2"],
Partitions: {
quota: false,
rate_limit: false,
Expand All @@ -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,
Expand Down