From ef320d93ec54826eacb52ee9e5b23548738b6b4b Mon Sep 17 00:00:00 2001 From: lorumic Date: Thu, 4 Apr 2024 17:20:34 +0200 Subject: [PATCH] fix(field): remove bold prefix for error/caution/success validation --- src/components/Field/Field.test.tsx | 12 ++++++------ src/components/Field/Field.tsx | 4 +--- src/components/FormikField/FormikField.test.tsx | 4 +--- src/components/Input/Input.test.tsx | 12 +++--------- .../PasswordToggle/PasswordToggle.test.tsx | 2 +- src/components/Select/Select.test.tsx | 4 +--- src/components/Slider/Slider.test.tsx | 4 +--- src/components/Textarea/Textarea.test.tsx | 4 +--- 8 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/components/Field/Field.test.tsx b/src/components/Field/Field.test.tsx index f0e7e81d6..b7550b373 100644 --- a/src/components/Field/Field.test.tsx +++ b/src/components/Field/Field.test.tsx @@ -27,7 +27,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Caution: Are you sure?" + "Are you sure?" ); expect(screen.getByTestId("field")).toHaveClass("is-caution"); }); @@ -43,7 +43,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Caution: Are you sure?" + "Are you sure?" ); expect(screen.getByTestId("field")).toHaveClass("is-caution"); }); @@ -55,7 +55,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Error: You can't do that" + "You can't do that" ); expect(screen.getByTestId("field")).toHaveClass("is-error"); }); @@ -71,7 +71,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Error: You can't do that" + "You can't do that" ); expect(screen.getByTestId("field")).toHaveClass("is-error"); }); @@ -83,7 +83,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleDescription( - "Success: You did it!" + "You did it!" ); expect(screen.getByTestId("field")).toHaveClass("is-success"); }); @@ -99,7 +99,7 @@ describe("Field ", () => { ); expect(screen.getByRole("textbox")).toHaveAccessibleDescription( - "Success: You did it!" + "You did it!" ); expect(screen.getByTestId("field")).toHaveClass("is-success"); }); diff --git a/src/components/Field/Field.tsx b/src/components/Field/Field.tsx index e983eba10..21a9d7bb3 100644 --- a/src/components/Field/Field.tsx +++ b/src/components/Field/Field.tsx @@ -107,11 +107,9 @@ const generateError = ( if (!error && !caution && !success) { return null; } - const messageType = - (error && "Error") || (caution && "Caution") || (success && "Success"); return (

- {messageType}: {error || caution || success} + {error || caution || success}

); }; diff --git a/src/components/FormikField/FormikField.test.tsx b/src/components/FormikField/FormikField.test.tsx index 9b4ab1ad1..75da14fc0 100644 --- a/src/components/FormikField/FormikField.test.tsx +++ b/src/components/FormikField/FormikField.test.tsx @@ -29,9 +29,7 @@ describe("FormikField", () => { ); - expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Error: Uh oh!" - ); + expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage("Uh oh!"); }); it("can hide the errors", () => { diff --git a/src/components/Input/Input.test.tsx b/src/components/Input/Input.test.tsx index 9ba21d0d8..11ea7b910 100644 --- a/src/components/Input/Input.test.tsx +++ b/src/components/Input/Input.test.tsx @@ -103,23 +103,17 @@ describe("Input", () => { it("can display an error for a text input", async () => { render(); - expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage( - "Error: Uh oh!" - ); + expect(screen.getByRole("textbox")).toHaveAccessibleErrorMessage("Uh oh!"); }); it("can display an error for a radiobutton", async () => { render(); - expect(screen.getByRole("radio")).toHaveAccessibleErrorMessage( - "Error: Uh oh!" - ); + expect(screen.getByRole("radio")).toHaveAccessibleErrorMessage("Uh oh!"); }); it("can display an error for a checkbox", async () => { render(); - expect(screen.getByRole("checkbox")).toHaveAccessibleErrorMessage( - "Error: Uh oh!" - ); + expect(screen.getByRole("checkbox")).toHaveAccessibleErrorMessage("Uh oh!"); }); it("can display help for a text input", async () => { diff --git a/src/components/PasswordToggle/PasswordToggle.test.tsx b/src/components/PasswordToggle/PasswordToggle.test.tsx index 88fda3560..0df83024e 100644 --- a/src/components/PasswordToggle/PasswordToggle.test.tsx +++ b/src/components/PasswordToggle/PasswordToggle.test.tsx @@ -50,7 +50,7 @@ describe("PasswordToggle", () => { it("can display an error", async () => { render(); expect(screen.getByLabelText("password")).toHaveAccessibleErrorMessage( - "Error: Uh oh!" + "Uh oh!" ); }); diff --git a/src/components/Select/Select.test.tsx b/src/components/Select/Select.test.tsx index f5ea891b7..0d11cee02 100644 --- a/src/components/Select/Select.test.tsx +++ b/src/components/Select/Select.test.tsx @@ -55,9 +55,7 @@ describe("Select", () => { it("can display an error", async () => { render(