From 043ca14f6490c796da4300b574b144b0ab74976c Mon Sep 17 00:00:00 2001 From: Mathieu Anderson Date: Fri, 16 Feb 2024 14:12:23 +0100 Subject: [PATCH] fix(coral): Make default value for protocoal PLAINTEXT Signed-off-by: Mathieu Anderson --- .../clusters/AddNewClusterForm.test.tsx | 24 ++++++++++++++----- .../clusters/AddNewClusterForm.tsx | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/coral/src/app/features/configuration/clusters/AddNewClusterForm.test.tsx b/coral/src/app/features/configuration/clusters/AddNewClusterForm.test.tsx index 61835039d6..7f8ccff3a3 100644 --- a/coral/src/app/features/configuration/clusters/AddNewClusterForm.test.tsx +++ b/coral/src/app/features/configuration/clusters/AddNewClusterForm.test.tsx @@ -72,7 +72,7 @@ describe("", () => { 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(); @@ -139,13 +139,25 @@ describe("", () => { 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 () => { @@ -163,13 +175,13 @@ describe("", () => { 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 () => { diff --git a/coral/src/app/features/configuration/clusters/AddNewClusterForm.tsx b/coral/src/app/features/configuration/clusters/AddNewClusterForm.tsx index d611e7a717..a1657c4dc1 100644 --- a/coral/src/app/features/configuration/clusters/AddNewClusterForm.tsx +++ b/coral/src/app/features/configuration/clusters/AddNewClusterForm.tsx @@ -32,6 +32,7 @@ const AddNewClusterForm = () => { schema: addNewClusterFormSchema, defaultValues: { clusterType: "KAFKA", + protocol: "PLAINTEXT", }, }); const { clusterType, kafkaFlavor, clusterName } = form.watch(); @@ -107,7 +108,6 @@ const AddNewClusterForm = () => { name="protocol" labelText="Protocol" - placeholder="Select protocol" required >