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

Update schema request with kafka env #1846

Merged
merged 19 commits into from
Oct 13, 2023
Merged
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 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
Loading