Skip to content

Commit

Permalink
Update schema request with kafka env (#1846)
Browse files Browse the repository at this point in the history
* Update schema request with kafka env

Signed-off-by: muralibasani <[email protected]>

* Remove unused component

Signed-off-by: Mirjam Aulbach <[email protected]>

* Remove deleted endpoint.

Signed-off-by: Mirjam Aulbach <[email protected]>

* Use getEnvs endpoint instead of deleted one.

Signed-off-by: Mirjam Aulbach <[email protected]>

* Filter getEnvs response for schema request

Signed-off-by: Mirjam Aulbach <[email protected]>

* Remove api call from environment-api

Signed-off-by: Mirjam Aulbach <[email protected]>

* Update EnvironmentFilter and components using it.

Signed-off-by: Mirjam Aulbach <[email protected]>

* Update schema request with kafka env

Signed-off-by: muralibasani <[email protected]>

* Remove unused component

Signed-off-by: Mirjam Aulbach <[email protected]>

* Remove deleted endpoint.

Signed-off-by: Mirjam Aulbach <[email protected]>

* Use getEnvs endpoint instead of deleted one.

Signed-off-by: Mirjam Aulbach <[email protected]>

* Filter getEnvs response for schema request

Signed-off-by: Mirjam Aulbach <[email protected]>

* Remove api call from environment-api

Signed-off-by: Mirjam Aulbach <[email protected]>

* Update EnvironmentFilter and components using it.

Signed-off-by: Mirjam Aulbach <[email protected]>

---------

Signed-off-by: muralibasani <[email protected]>
Signed-off-by: Mirjam Aulbach <[email protected]>
Co-authored-by: muralibasani <[email protected]>
Co-authored-by: Mirjam Aulbach <[email protected]>
Co-authored-by: aindriu-aiven <[email protected]>
  • Loading branch information
4 people authored Oct 13, 2023
1 parent c5407b7 commit ba75970
Show file tree
Hide file tree
Showing 35 changed files with 388 additions and 467 deletions.
2 changes: 1 addition & 1 deletion coral/src/app/features/approvals/acls/AclApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function AclApprovals() {
filters={[
<EnvironmentFilter
key={"environment"}
environmentEndpoint={"getAllEnvironmentsForTopicAndAcl"}
environmentsFor={"TOPIC_AND_ACL"}
/>,
<StatusFilter key={"status"} />,
<RequestTypeFilter key={"requestType"} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ function ConnectorApprovals() {
filters={[
<EnvironmentFilter
key={"environment"}
environmentEndpoint={"getAllEnvironmentsForConnector"}
environmentsFor={"CONNECTOR"}
/>,
<StatusFilter key={"status"} />,
<RequestTypeFilter key={"requestType"} />,
Expand Down
43 changes: 25 additions & 18 deletions coral/src/app/features/approvals/schemas/SchemaApprovals.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { cleanup, screen, waitFor, within } from "@testing-library/react";
import { waitForElementToBeRemoved } from "@testing-library/react/pure";
import userEvent from "@testing-library/user-event";
import SchemaApprovals from "src/app/features/approvals/schemas/SchemaApprovals";
import { getAllEnvironmentsForSchema } from "src/domain/environment";
import { getAllEnvironmentsForTopicAndAcl } from "src/domain/environment";
import { createMockEnvironmentDTO } from "src/domain/environment/environment-test-helper";
import { transformEnvironmentApiResponse } from "src/domain/environment/environment-transformer";
import {
Expand All @@ -19,9 +19,9 @@ import { customRender } from "src/services/test-utils/render-with-wrappers";
jest.mock("src/domain/schema-request/schema-request-api.ts");
jest.mock("src/domain/environment/environment-api.ts");

const mockGetSchemaRegistryEnvironments =
getAllEnvironmentsForSchema as jest.MockedFunction<
typeof getAllEnvironmentsForSchema
const mockGetAllEnvironmentsForTopicAndAcl =
getAllEnvironmentsForTopicAndAcl as jest.MockedFunction<
typeof getAllEnvironmentsForTopicAndAcl
>;

const mockGetSchemaRequestsForApprover =
Expand All @@ -37,8 +37,9 @@ const mockApproveSchemaRequest = approveSchemaRequest as jest.MockedFunction<
>;

const mockedEnvironments = [
{ name: "DEV", id: "1" },
{ name: "TST", id: "2" },
{ name: "DEV", id: "1", associatedEnv: { name: "DEV_SCH", id: "111" } },
{ name: "TST", id: "2", associatedEnv: { name: "TST_SCH", id: "222" } },
{ name: "RANDOM", id: "3" },
];

const mockedEnvironmentResponse = transformEnvironmentApiResponse([
Expand Down Expand Up @@ -133,7 +134,7 @@ describe("SchemaApprovals", () => {
totalPages: 1,
currentPage: 1,
});
mockGetSchemaRegistryEnvironments.mockResolvedValue([]);
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue([]);
});

afterEach(() => {
Expand Down Expand Up @@ -177,7 +178,7 @@ describe("SchemaApprovals", () => {

describe("renders all necessary elements", () => {
beforeAll(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down Expand Up @@ -239,7 +240,7 @@ describe("SchemaApprovals", () => {
totalPages: 1,
currentPage: 1,
});
mockGetSchemaRegistryEnvironments.mockResolvedValue([]);
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue([]);
});

afterEach(() => {
Expand Down Expand Up @@ -345,7 +346,7 @@ describe("SchemaApprovals", () => {
entries: [],
});

mockGetSchemaRegistryEnvironments.mockResolvedValue([]);
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue([]);

customRender(<SchemaApprovals />, {
queryClient: true,
Expand Down Expand Up @@ -386,7 +387,7 @@ describe("SchemaApprovals", () => {

describe("shows a detail modal for schema request", () => {
beforeEach(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down Expand Up @@ -506,7 +507,7 @@ describe("SchemaApprovals", () => {

describe("handles filtering entries in the table", () => {
beforeEach(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue({
Expand Down Expand Up @@ -577,13 +578,19 @@ describe("SchemaApprovals", () => {
name: "Filter by Environment",
});
const environmentOption = screen.getByRole("option", {
name: mockedEnvironments[0].name,
// we're defining the test data, so it is not undefined
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
name: mockedEnvironments[0].associatedEnv.name,
});
await userEvent.selectOptions(environmentFilter, environmentOption);

expect(mockGetSchemaRequestsForApprover).toHaveBeenNthCalledWith(2, {
...defaultApiParams,
env: mockedEnvironments[0].id,
// we're defining the test data, so it is not undefined
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
env: mockedEnvironments[0].associatedEnv.id,
});
});

Expand Down Expand Up @@ -614,7 +621,7 @@ describe("SchemaApprovals", () => {
console.error = jest.fn();

console.error = jest.fn();
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down Expand Up @@ -712,7 +719,7 @@ describe("SchemaApprovals", () => {
console.error = jest.fn();

console.error = jest.fn();
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down Expand Up @@ -837,7 +844,7 @@ describe("SchemaApprovals", () => {
console.error = jest.fn();

console.error = jest.fn();
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down Expand Up @@ -1007,7 +1014,7 @@ describe("SchemaApprovals", () => {
console.error = jest.fn();

console.error = jest.fn();
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedEnvironmentResponse
);
mockGetSchemaRequestsForApprover.mockResolvedValue(
Expand Down
5 changes: 1 addition & 4 deletions coral/src/app/features/approvals/schemas/SchemaApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ function SchemaApprovals() {
{errorQuickActions && <Alert type="error">{errorQuickActions}</Alert>}
<TableLayout
filters={[
<EnvironmentFilter
key={"environment"}
environmentEndpoint={"getAllEnvironmentsForSchema"}
/>,
<EnvironmentFilter key={"environment"} environmentsFor={"SCHEMA"} />,
<StatusFilter key={"status"} />,
<RequestTypeFilter key={"requestType"} />,
<SearchTopicFilter key={"topic"} />,
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion coral/src/app/features/approvals/topics/TopicApprovals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function TopicApprovals() {
filters={[
<EnvironmentFilter
key={"environment"}
environmentEndpoint={"getAllEnvironmentsForTopicAndAcl"}
environmentsFor={"TOPIC_AND_ACL"}
/>,
<StatusFilter key={"status"} />,
<RequestTypeFilter key={"requestType"} />,
Expand Down
Loading

0 comments on commit ba75970

Please sign in to comment.