Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue #2962] modal followup #3482

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<ModalRef>(null);

return (
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/user/UserControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,7 +116,9 @@ export const UserControl = () => {

return (
<>
{!user?.token && <LoginModal navLoginLinkText={t("nav_link_login")} />}
{!user?.token && (
<LoginButtonModal navLoginLinkText={t("nav_link_login")} />
)}
{!!user?.token && (
<UserDropdown
user={user}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/messages/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ export const messages = {
nav_link_logout: "Sign out",
title: "Simpler.Grants.gov",
},
LoginModal: {
LoginButtonModal: {
title: "Sign in to Simpler.Grants.gov",
help: "Simpler.Grants.gov uses Login.gov to verify your identity and manage your account securely. You don't need a separate username or password for this site.",
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import userEvent from "@testing-library/user-event";
import { render, screen } from "tests/react-utils";

import Header from "src/components/Header";
import { LoginModal } from "src/components/LoginModal";
import { LOGIN_URL, LoginButtonModal } from "src/components/LoginButtonModal";

const usePathnameMock = jest.fn().mockReturnValue("/fakepath");

Expand All @@ -16,13 +16,15 @@ jest.mock("src/hooks/useFeatureFlags", () => ({
}),
}));

describe("LoginModal", () => {
describe("LoginButtonModal", () => {
it("renders", () => {
render(<LoginModal navLoginLinkText="Sign in" />);
render(<LoginButtonModal navLoginLinkText="Sign in" />);
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");
});
Expand Down