Skip to content

Commit

Permalink
fix(coral): Make default value for protocoal PLAINTEXT
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Anderson <mathieu.anderson@aiven.io>
  • Loading branch information
Mathieu Anderson committed Feb 16, 2024
1 parent 29f5cf4 commit 043ca14
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("<AddNewClusterForm />", () => {
expect(clusterTypeOptions).toHaveLength(3);
expect(clusterNameInput).toBeEnabled();
expect(protocolSelect).toBeEnabled();
expect(protocolSelectOptions).toHaveLength(8);
expect(protocolSelectOptions).toHaveLength(7);
expect(kafkaFlavorSelect).toBeEnabled();
expect(kafkaFlavorSelectOptions).toHaveLength(6);
expect(bootstrapServersInput).toBeEnabled();
Expand Down Expand Up @@ -139,13 +139,25 @@ describe("<AddNewClusterForm />", () => {
await userEvent.type(clusterNameInput, "MyCluster");
await userEvent.type(bootstrapServersInput, "sever:9090");
await userEvent.selectOptions(kafkaFlavorSelect, "AIVEN_FOR_APACHE_KAFKA");

const projectNameInput = screen.getByRole("textbox", {
name: "Project name *",
});
const serviceNameInput = screen.getByRole("textbox", {
name: "Service name *",
});

await userEvent.type(projectNameInput, "MyProject");
await userEvent.click(submitButton);
const serviceNameErrorMessage = screen.getByText("Required");

const projectNameErrorMessage = await screen.findByText("Required");
const serviceNameErrorMessage = await screen.findByText("Required");
expect(serviceNameErrorMessage).toBeVisible();

await userEvent.clear(projectNameInput);
await userEvent.type(serviceNameInput, "MyService");
const projectNameErrorMessage = screen.getByText("Required");

expect(projectNameErrorMessage).toBeVisible();
expect(serviceNameErrorMessage).toBeVisible();
});

it("updates Protocol options when Kafka connect or Schema registry cluster type is selected", async () => {
Expand All @@ -163,13 +175,13 @@ describe("<AddNewClusterForm />", () => {

const kafkaConnectProtocolSelectOptions =
within(protocolSelect).getAllByRole("option");
expect(kafkaConnectProtocolSelectOptions).toHaveLength(3);
expect(kafkaConnectProtocolSelectOptions).toHaveLength(2);

await userEvent.click(schemaRegistryOption);

const schemaRegistryProtocolSelectOptions =
within(protocolSelect).getAllByRole("option");
expect(schemaRegistryProtocolSelectOptions).toHaveLength(3);
expect(schemaRegistryProtocolSelectOptions).toHaveLength(2);
});

it("shows an error when boostrap server is incorrect", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const AddNewClusterForm = () => {
schema: addNewClusterFormSchema,
defaultValues: {
clusterType: "KAFKA",
protocol: "PLAINTEXT",
},
});
const { clusterType, kafkaFlavor, clusterName } = form.watch();
Expand Down Expand Up @@ -107,7 +108,6 @@ const AddNewClusterForm = () => {
<NativeSelect<AddNewClusterFormSchema>
name="protocol"
labelText="Protocol"
placeholder="Select protocol"
required
>
<Option value="PLAINTEXT">PLAINTEXT</Option>
Expand Down

0 comments on commit 043ca14

Please sign in to comment.