From 040aabf236ccbd468ba827bc0ff5c0004149a526 Mon Sep 17 00:00:00 2001 From: Emma Mansell <73774046+7emansell@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:59:55 -0500 Subject: [PATCH] Updating banner messages and adding tests for it --- .../MyAccount/Settings/StatusBanner.test.tsx | 37 +++++++++++++++++++ .../MyAccount/Settings/UsernameForm.tsx | 6 +-- 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/components/MyAccount/Settings/StatusBanner.test.tsx diff --git a/src/components/MyAccount/Settings/StatusBanner.test.tsx b/src/components/MyAccount/Settings/StatusBanner.test.tsx new file mode 100644 index 00000000..37048236 --- /dev/null +++ b/src/components/MyAccount/Settings/StatusBanner.test.tsx @@ -0,0 +1,37 @@ +import { render, screen } from "@testing-library/react" +import { StatusBanner } from "./StatusBanner" + +describe("Status banner", () => { + it("displays specific failure message", () => { + render() + expect( + screen.getByText(/Specific failure Please try again/) + ).toBeInTheDocument() + expect(screen.getByRole("link")).toHaveAttribute( + "href", + "https://www.nypl.org/get-help/contact-us" + ) + expect(screen.getByRole("complementary")).toHaveAttribute( + "data-type", + "negative" + ) + }) + + it("displays general failure message", () => { + render() + expect(screen.getByText(/Your changes were not saved/)).toBeInTheDocument() + expect(screen.getByRole("complementary")).toHaveAttribute( + "data-type", + "negative" + ) + }) + + it("displays success message", () => { + render() + expect(screen.getByText(/Your changes were saved/)).toBeInTheDocument() + expect(screen.getByRole("complementary")).toHaveAttribute( + "data-type", + "positive" + ) + }) +}) diff --git a/src/components/MyAccount/Settings/UsernameForm.tsx b/src/components/MyAccount/Settings/UsernameForm.tsx index f6548c5c..5fc141c5 100644 --- a/src/components/MyAccount/Settings/UsernameForm.tsx +++ b/src/components/MyAccount/Settings/UsernameForm.tsx @@ -17,10 +17,8 @@ import AddButton from "./AddButton" import { BASE_URL } from "../../../config/constants" export const usernameStatusMessages = { - USERNAME_FAILURE: - "This username already exists. Please try a different username or contact us for assistance.", - FAILURE: - "Your changes could not be saved. Please try again or contact us for assistance. ", + USERNAME_FAILURE: "This username already exists.", + FAILURE: "Your changes could not be saved.", SUCCESS: "Your changes were saved.", }