From 53d4f5bc426df7c5165e4035a95dc8c3262d5de2 Mon Sep 17 00:00:00 2001
From: Mirjam Aulbach
Date: Mon, 16 Oct 2023 11:39:58 +0200
Subject: [PATCH] Update copy and tests.
Signed-off-by: Mirjam Aulbach
---
.../schema/TopicDetailsSchema.test.tsx | 8 ++---
.../details/schema/TopicDetailsSchema.tsx | 2 +-
.../components/SchemaPromotionModal.test.tsx | 30 ++++++++++++-------
.../components/SchemaPromotionModal.tsx | 30 ++++++++++++-------
.../TopicSchemaRequest.test.tsx | 15 ++++++++--
.../schema-request/TopicSchemaRequest.tsx | 6 ++--
6 files changed, 59 insertions(+), 32 deletions(-)
diff --git a/coral/src/app/features/topics/details/schema/TopicDetailsSchema.test.tsx b/coral/src/app/features/topics/details/schema/TopicDetailsSchema.test.tsx
index 2c8be96015..0be8ee2aec 100644
--- a/coral/src/app/features/topics/details/schema/TopicDetailsSchema.test.tsx
+++ b/coral/src/app/features/topics/details/schema/TopicDetailsSchema.test.tsx
@@ -970,7 +970,7 @@ describe("TopicDetailsSchema", () => {
});
const checkBoxBefore = screen.queryByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
expect(checkBoxBefore).not.toBeInTheDocument();
@@ -996,7 +996,7 @@ describe("TopicDetailsSchema", () => {
});
const checkboxToForceRegister = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
expect(checkboxToForceRegister).toBeVisible();
@@ -1032,7 +1032,7 @@ describe("TopicDetailsSchema", () => {
await user.click(buttonRequest);
const checkboxToForceRegister = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
await user.click(checkboxToForceRegister);
@@ -1078,7 +1078,7 @@ describe("TopicDetailsSchema", () => {
await user.click(buttonRequest);
const checkboxToForceRegister = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
await user.click(checkboxToForceRegister);
diff --git a/coral/src/app/features/topics/details/schema/TopicDetailsSchema.tsx b/coral/src/app/features/topics/details/schema/TopicDetailsSchema.tsx
index f9d718a10e..59b1381d34 100644
--- a/coral/src/app/features/topics/details/schema/TopicDetailsSchema.tsx
+++ b/coral/src/app/features/topics/details/schema/TopicDetailsSchema.tsx
@@ -49,7 +49,7 @@ function TopicDetailsSchema() {
topicOverview,
} = useTopicDetails();
const [showSchemaPromotionModal, setShowSchemaPromotionModal] =
- useState(false);
+ useState(true);
const [errorMessage, setErrorMessage] = useState("");
const [isValidationError, setIsValidationError] = useState(false);
diff --git a/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.test.tsx b/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.test.tsx
index 144fe0bdab..5f320eb324 100644
--- a/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.test.tsx
+++ b/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.test.tsx
@@ -35,6 +35,14 @@ describe("SchemaPromotionModal", () => {
expect(dialog).toBeVisible();
});
+ it("shows no warning or option to force register", () => {
+ const warning = screen.queryByRole("alert");
+ const checkbox = screen.queryByRole("checkbox");
+
+ expect(warning).not.toBeInTheDocument();
+ expect(checkbox).not.toBeInTheDocument();
+ });
+
it("shows more information to delete the topic", () => {
const dialog = screen.getByRole("dialog");
const headline = within(dialog).getByRole("heading", {
@@ -50,7 +58,7 @@ describe("SchemaPromotionModal", () => {
it("does not show a switch to force register", () => {
const forceRegisterSwitch = screen.queryByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
expect(forceRegisterSwitch).not.toBeInTheDocument();
});
@@ -102,13 +110,6 @@ describe("SchemaPromotionModal", () => {
jest.clearAllMocks();
});
- it("disables Force register switch", () => {
- const forceRegisterSwitch = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
- });
- expect(forceRegisterSwitch).toBeDisabled();
- });
-
it("disables textarea where user can add a comment why they promote the schema", () => {
const dialog = screen.getByRole("dialog");
const textarea = within(dialog).getByRole("textbox", {
@@ -191,6 +192,15 @@ describe("SchemaPromotionModal", () => {
jest.clearAllMocks();
});
+ it("shows a warning about force register", async () => {
+ const warning = screen.getByRole("alert");
+
+ expect(warning).toBeVisible();
+ expect(warning).toHaveTextContent(
+ "Uploaded schema appears invalid. Are you sure you want to force register it?"
+ );
+ });
+
it("triggers a given submit function with correct payload when user does not switch Force register or adds a reason", async () => {
const dialog = screen.getByRole("dialog");
@@ -211,7 +221,7 @@ describe("SchemaPromotionModal", () => {
const dialog = screen.getByRole("dialog");
const forceRegisterSwitch = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
const confirmationButton = within(dialog).getByRole("button", {
@@ -232,7 +242,7 @@ describe("SchemaPromotionModal", () => {
const dialog = screen.getByRole("dialog");
const forceRegisterSwitch = screen.getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
const textarea = within(dialog).getByRole("textbox", {
diff --git a/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.tsx b/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.tsx
index 1194474d5f..cc689b1977 100644
--- a/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.tsx
+++ b/coral/src/app/features/topics/details/schema/components/SchemaPromotionModal.tsx
@@ -1,4 +1,4 @@
-import { Box, Checkbox, Textarea } from "@aivenio/aquarium";
+import { Alert, Box, Checkbox, Textarea } from "@aivenio/aquarium";
import { useState } from "react";
import { Modal } from "src/app/components/Modal";
@@ -52,16 +52,12 @@ const SchemaPromotionModal = ({
{`Promote the Version ${version} of the schema to ${targetEnvironment}?`}
{showForceRegister && (
- setForceRegister(e.target.checked)}
- >
- Force register
-
+
+
+ Uploaded schema appears invalid. Are you sure you want to force
+ register it?
+
+
)}
+ {showForceRegister && (
+ setForceRegister(e.target.checked)}
+ >
+ Force register
+
+ )}
);
diff --git a/coral/src/app/features/topics/schema-request/TopicSchemaRequest.test.tsx b/coral/src/app/features/topics/schema-request/TopicSchemaRequest.test.tsx
index fb14f8fa3d..691be0cdcc 100644
--- a/coral/src/app/features/topics/schema-request/TopicSchemaRequest.test.tsx
+++ b/coral/src/app/features/topics/schema-request/TopicSchemaRequest.test.tsx
@@ -977,9 +977,12 @@ describe("TopicSchemaRequest", () => {
const form = getForm();
const checkBoxBefore = within(form).queryByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
+
+ const warningBefore = screen.queryByText("alertdialog");
expect(checkBoxBefore).not.toBeInTheDocument();
+ expect(warningBefore).not.toBeInTheDocument();
const select = within(form).getByRole("combobox", {
name: /Environment/i,
@@ -999,9 +1002,15 @@ describe("TopicSchemaRequest", () => {
await userEvent.upload(fileInput, testFile);
await userEvent.click(button);
+ const warningForceRegister = screen.getByRole("alert");
const checkboxForceRegister = within(form).getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
+ expect(warningForceRegister).toBeVisible();
+ expect(warningForceRegister).toHaveTextContent(
+ "Uploaded schema appears invalid. Are you sure you want to" +
+ " force register it?"
+ );
expect(checkboxForceRegister).toBeVisible();
expect(console.error).toHaveBeenCalledWith({
@@ -1031,7 +1040,7 @@ describe("TopicSchemaRequest", () => {
await userEvent.click(submitButton);
const checkboxForceRegister = within(form).getByRole("checkbox", {
- name: "Force register Overrides some validation that the schema registry would normally do.",
+ name: "Force register Overrides standard validation processes of the schema registry.",
});
await userEvent.click(checkboxForceRegister);
diff --git a/coral/src/app/features/topics/schema-request/TopicSchemaRequest.tsx b/coral/src/app/features/topics/schema-request/TopicSchemaRequest.tsx
index 14fb32b867..8fe886b0c3 100644
--- a/coral/src/app/features/topics/schema-request/TopicSchemaRequest.tsx
+++ b/coral/src/app/features/topics/schema-request/TopicSchemaRequest.tsx
@@ -175,8 +175,8 @@ function TopicSchemaRequest(props: TopicSchemaRequestProps) {
{isValidationError && (
- The uploaded schema does not appear to be valid. You can force
- register the schema.
+ Uploaded schema appears invalid. Are you sure you want to force
+ register it?
)}
@@ -247,7 +247,7 @@ function TopicSchemaRequest(props: TopicSchemaRequestProps) {
name={"forceRegister"}
caption={
- "Overrides some validation that the schema registry would normally do."
+ "Overrides standard validation processes of the schema registry."
}
>
Force register