From d519f775b5f6f66c5d5b023c16649b60584855fb Mon Sep 17 00:00:00 2001 From: acouch Date: Fri, 10 Jan 2025 10:31:17 -0500 Subject: [PATCH] Move LoginModal to LoginModalButton --- .../{LoginModal.tsx => LoginButtonModal.tsx} | 6 +++--- frontend/src/components/user/UserControl.tsx | 4 ++-- frontend/src/i18n/messages/en/index.ts | 2 +- ...{LoginModal.test.tsx => LoginButtonModal.test.tsx} | 11 ++++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) rename frontend/src/components/{LoginModal.tsx => LoginButtonModal.tsx} (94%) rename frontend/tests/components/{LoginModal.test.tsx => LoginButtonModal.test.tsx} (83%) diff --git a/frontend/src/components/LoginModal.tsx b/frontend/src/components/LoginButtonModal.tsx similarity index 94% rename from frontend/src/components/LoginModal.tsx rename to frontend/src/components/LoginButtonModal.tsx index 7d3649575..ae3ef0430 100644 --- a/frontend/src/components/LoginModal.tsx +++ b/frontend/src/components/LoginButtonModal.tsx @@ -11,14 +11,14 @@ import { import { USWDSIcon } from "src/components/USWDSIcon"; -const LOGIN_URL = "/api/auth/login"; +export const LOGIN_URL = "/api/auth/login"; -export const LoginModal = ({ +export const LoginButtonModal = ({ navLoginLinkText, }: { navLoginLinkText: string; }) => { - const t = useTranslations("LoginModal"); + const t = useTranslations("LoginButtonModal"); const modalRef = useRef(null); return ( diff --git a/frontend/src/components/user/UserControl.tsx b/frontend/src/components/user/UserControl.tsx index d26113617..2a8d66a81 100644 --- a/frontend/src/components/user/UserControl.tsx +++ b/frontend/src/components/user/UserControl.tsx @@ -10,7 +10,7 @@ import { NavDropDownButton, } from "@trussworks/react-uswds"; -import { LoginModal } from "src/components/LoginModal"; +import { LoginButtonModal } from "src/components/LoginButtonModal"; import { USWDSIcon } from "src/components/USWDSIcon"; // used in three different places @@ -116,7 +116,7 @@ export const UserControl = () => { return ( <> - {!user?.token && } + {!user?.token && } {!!user?.token && ( ({ }), })); -describe("LoginModal", () => { +describe("LoginButtonModal", () => { it("renders", () => { - render(); + render(); const loginGovLink = screen.getByRole("link", { name: /Sign in with Login.gov/i, }); expect(loginGovLink).toBeInTheDocument(); + expect(loginGovLink).toHaveAttribute( + "href", + LOGIN_URL, + ); + const modalTitle = screen.getByRole("heading", { level: 2 }); expect(modalTitle).toHaveTextContent("Sign in to Simpler.Grants.gov"); });