Skip to content

Commit

Permalink
Use getEnvs endpoint instead of deleted one.
Browse files Browse the repository at this point in the history
Signed-off-by: Mirjam Aulbach <[email protected]>
  • Loading branch information
programmiri committed Oct 5, 2023
1 parent 8ae8bca commit 73c9e50
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@testing-library/react/pure";
import userEvent from "@testing-library/user-event";
import { TopicSchemaRequest } from "src/app/features/topics/schema-request/TopicSchemaRequest";
import { getEnvironmentsForSchemaRequest } 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 { requestSchemaCreation } from "src/domain/schema-request";
Expand All @@ -19,9 +19,9 @@ jest.mock("src/domain/schema-request/schema-request-api.ts");
jest.mock("src/domain/environment/environment-api.ts");
jest.mock("src/domain/topic/topic-api.ts");

const mockGetSchemaRegistryEnvironments =
getEnvironmentsForSchemaRequest as jest.MockedFunction<
typeof getEnvironmentsForSchemaRequest
const mockgetAllEnvironmentsForTopicAndAcl =
getAllEnvironmentsForTopicAndAcl as jest.MockedFunction<
typeof getAllEnvironmentsForTopicAndAcl
>;
const mockCreateSchemaRequest = requestSchemaCreation as jest.MockedFunction<
typeof requestSchemaCreation
Expand Down Expand Up @@ -75,7 +75,7 @@ describe("TopicSchemaRequest", () => {

describe("checks if topicName passed from url is part of topics user can request schemas for", () => {
beforeEach(() => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockImplementation(jest.fn());
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("TopicSchemaRequest", () => {
});

it("does not redirect user if env ID query is part of list of environments", async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue([
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue([
...mockedGetSchemaRegistryEnvironments,
]);

Expand Down Expand Up @@ -184,7 +184,7 @@ describe("TopicSchemaRequest", () => {
});

it("does not redirect user if env name query is part of list of environments", async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue([
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue([
...mockedGetSchemaRegistryEnvironments,
]);

Expand Down Expand Up @@ -223,7 +223,7 @@ describe("TopicSchemaRequest", () => {
});

it("redirects user if env id query does not exist in list of environments", async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue([
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue([
...mockedGetSchemaRegistryEnvironments,
]);

Expand All @@ -244,7 +244,7 @@ describe("TopicSchemaRequest", () => {
});

it("redirects user if env name query does not exist in list of environments", async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue([
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue([
...mockedGetSchemaRegistryEnvironments,
]);

Expand All @@ -270,7 +270,7 @@ describe("TopicSchemaRequest", () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
useQuerySpy.mockReturnValue({ data: [], isLoading: true });
mockGetSchemaRegistryEnvironments.mockResolvedValue([]);
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue([]);
mockCreateSchemaRequest.mockImplementation(jest.fn());
mockGetTopicNames.mockResolvedValue([testTopicName]);

Expand Down Expand Up @@ -308,7 +308,7 @@ describe("TopicSchemaRequest", () => {

describe("renders all necessary elements", () => {
beforeAll(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockImplementation(jest.fn());
Expand Down Expand Up @@ -441,7 +441,7 @@ describe("TopicSchemaRequest", () => {

describe("shows errors when user does not fill out correctly", () => {
beforeEach(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockImplementation(jest.fn());
Expand Down Expand Up @@ -519,7 +519,7 @@ describe("TopicSchemaRequest", () => {

describe("enables user to cancel the form input", () => {
beforeEach(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockImplementation(jest.fn());
Expand Down Expand Up @@ -635,7 +635,7 @@ describe("TopicSchemaRequest", () => {

beforeEach(async () => {
console.error = jest.fn();
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockRejectedValue({
Expand Down Expand Up @@ -740,7 +740,7 @@ describe("TopicSchemaRequest", () => {

describe("enables user to send a schema request", () => {
beforeEach(async () => {
mockGetSchemaRegistryEnvironments.mockResolvedValue(
mockgetAllEnvironmentsForTopicAndAcl.mockResolvedValue(
mockedGetSchemaRegistryEnvironments
);
mockCreateSchemaRequest.mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "src/app/features/topics/schema-request/form-schemas/topic-schema-request-form";
import {
Environment,
getEnvironmentsForSchemaRequest,
getAllEnvironmentsForTopicAndAcl,
} from "src/domain/environment";
import { requestSchemaCreation } from "src/domain/schema-request";
import { TopicNames, getTopicNames } from "src/domain/topic";
Expand Down Expand Up @@ -86,8 +86,8 @@ function TopicSchemaRequest(props: TopicSchemaRequestProps) {
Environment[],
Error
>({
queryKey: ["schemaRegistryEnvironments"],
queryFn: () => getEnvironmentsForSchemaRequest(),
queryKey: ["getEnvs"],
queryFn: () => getAllEnvironmentsForTopicAndAcl(),
onSuccess: (environments) => {
if (presetEnvironment) {
const validEnv = environments.find(
Expand Down
10 changes: 5 additions & 5 deletions coral/src/app/pages/topics/schema-request.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { getQueryClientForTests } from "src/services/test-utils/query-client-tes
import { render } from "@testing-library/react";
import { QueryClientProvider } from "@tanstack/react-query";
import { MemoryRouter, Routes, Route } from "react-router-dom";
import { getEnvironmentsForSchemaRequest } from "src/domain/environment";
import { getAllEnvironmentsForTopicAndAcl } from "src/domain/environment";
import { requestSchemaCreation } from "src/domain/schema-request";
import { getTopicNames } from "src/domain/topic";

jest.mock("src/domain/schema-request/schema-request-api.ts");
jest.mock("src/domain/environment/environment-api.ts");
jest.mock("src/domain/topic/topic-api.ts");

const mockGetSchemaRegistryEnvironments =
getEnvironmentsForSchemaRequest as jest.MockedFunction<
typeof getEnvironmentsForSchemaRequest
const mockGetAllEnvironmentsForTopicAndAcl =
getAllEnvironmentsForTopicAndAcl as jest.MockedFunction<
typeof getAllEnvironmentsForTopicAndAcl
>;
const mockCreateSchemaRequest = requestSchemaCreation as jest.MockedFunction<
typeof requestSchemaCreation
Expand All @@ -29,7 +29,7 @@ describe("SchemaRequest", () => {
const topicName = "my-awesome-topic";

beforeAll(() => {
mockGetSchemaRegistryEnvironments.mockResolvedValue([]);
mockGetAllEnvironmentsForTopicAndAcl.mockResolvedValue([]);
mockCreateSchemaRequest.mockImplementation(jest.fn());
mockGetTopicNames.mockResolvedValue([topicName]);
// @TODO if we decide to go with this kind of dynamic routes,
Expand Down

0 comments on commit 73c9e50

Please sign in to comment.