diff --git a/packages/app-webdir-ui/src/ProfileCard/index.js b/packages/app-webdir-ui/src/ProfileCard/index.js index 77b30066fc..e4b373d4c7 100644 --- a/packages/app-webdir-ui/src/ProfileCard/index.js +++ b/packages/app-webdir-ui/src/ProfileCard/index.js @@ -90,7 +90,9 @@ const ProfileCard = ({ ...props }) => { )} {!props.profileURL &&

{props.name}

}
-

{title}

+

+ {title} +

{department && {department}}
{props.size !== "micro" && ( diff --git a/packages/app-webdir-ui/src/ProfileCard/index.test.js b/packages/app-webdir-ui/src/ProfileCard/index.test.js new file mode 100644 index 0000000000..a6a3bb4edb --- /dev/null +++ b/packages/app-webdir-ui/src/ProfileCard/index.test.js @@ -0,0 +1,40 @@ +import { render, screen } from "@testing-library/react"; +import React from "react"; + +import { ProfileCard } from "./index"; + +const defaultProps = { + name: "John Smith", + matchedAffiliationTitle: "Regents Professor", + matchedAffiliationDept: "Edplus at ASU", + imgURL: "/test-image.jpg", + profileURL: "https://search.asu.edu/profile/12345", + email: "email@asu.edu", + size: "default", + GASource: "profile card", +}; + +describe("ProfileCard", () => { + it("should render the name and title", () => { + render(); + expect(screen.getByText("John Smith")).toBeInTheDocument(); + expect(screen.getByText("Regents Professor")).toBeInTheDocument(); + }); + + it("should not render the title as a heading", () => { + const { container } = render(); + expect(container.querySelector(".person-profession h4")).toBeNull(); + expect( + screen.queryByRole("heading", { name: "Regents Professor" }) + ).toBeNull(); + }); + + it("should render the title as bold text in a paragraph", () => { + const { container } = render(); + const title = container.querySelector( + ".person-profession p.person-profession-title strong" + ); + expect(title).toBeInTheDocument(); + expect(title).toHaveTextContent("Regents Professor"); + }); +}); diff --git a/packages/unity-bootstrap-theme/src/scss/extends/_person-profile.scss b/packages/unity-bootstrap-theme/src/scss/extends/_person-profile.scss index f9230bc979..78160e0d67 100644 --- a/packages/unity-bootstrap-theme/src/scss/extends/_person-profile.scss +++ b/packages/unity-bootstrap-theme/src/scss/extends/_person-profile.scss @@ -21,7 +21,8 @@ Desktop styles --name-top-margin: 0; .person-profession { - h4:not(:first-child) { + h4:not(:first-child), + .person-profession-title:not(:first-child) { display: none; } } @@ -63,7 +64,10 @@ Desktop styles margin: 0; line-height: 1; margin-bottom: var(--person-profession-bottom-margin); - h4 { + // h4 kept for backward compatibility with consumers + // still rendering the profession title as a heading + h4, + .person-profession-title { margin: 0; font-size: $uds-size-font-medium; overflow: hidden; @@ -73,6 +77,11 @@ Desktop styles line-clamp: 2; -webkit-box-orient: vertical; } + .person-profession-title { + font-weight: $heading-font-weight; + line-height: $heading-four-line-height; + letter-spacing: $heading-four-letter-spacing; + } } .more-link { line-height: 1; diff --git a/packages/unity-bootstrap-theme/stories/molecules/person-profile/person-profile.templates.stories.js b/packages/unity-bootstrap-theme/stories/molecules/person-profile/person-profile.templates.stories.js index d39506d196..cbd3330068 100644 --- a/packages/unity-bootstrap-theme/stories/molecules/person-profile/person-profile.templates.stories.js +++ b/packages/unity-bootstrap-theme/stories/molecules/person-profile/person-profile.templates.stories.js @@ -53,12 +53,12 @@ const PersonProfile = ({ size, fill }) => (

John Smith

-

- Regents Professor -

-

- Edplus at ASU -

+

+ Regents Professor +

+

+ Edplus at ASU +

{size !== "micro" && (
    diff --git a/packages/unity-react-core/src/components/PersonProfile/PersonProfile.test.tsx b/packages/unity-react-core/src/components/PersonProfile/PersonProfile.test.tsx index b837cc06c4..074a2dc83e 100644 --- a/packages/unity-react-core/src/components/PersonProfile/PersonProfile.test.tsx +++ b/packages/unity-react-core/src/components/PersonProfile/PersonProfile.test.tsx @@ -85,15 +85,33 @@ describe("PersonProfile tests", () => { describe("accessibility tests", () => { it("should have proper aria labels for contact links", () => { - expect(screen.getByLabelText(`Email ${component.container.querySelector("a[href*='mailto:']").innerHTML}`)).toBeInTheDocument(); - expect(screen.getByLabelText(`Phone ${component.container.querySelector("a[href*='tel:']").innerHTML.replace(/\-/g, " ").replace(/\(/g, "").replace(/\)/g, "")}`)).toBeInTheDocument(); + expect( + screen.getByLabelText( + `Email ${component.container.querySelector("a[href*='mailto:']").innerHTML}` + ) + ).toBeInTheDocument(); + expect( + screen.getByLabelText( + `Phone ${component.container.querySelector("a[href*='tel:']").innerHTML.replace(/\-/g, " ").replace(/\(/g, "").replace(/\)/g, "")}` + ) + ).toBeInTheDocument(); }); it("should use semantic HTML elements", () => { expect(component.container.querySelector("address")).toBeInTheDocument(); expect(component.container.querySelector("h3")).toBeInTheDocument(); - expect(component.container.querySelector("h4")).toBeInTheDocument(); }); - }); + it("should not render profession as headings", () => { + expect( + component.container.querySelector(".person-profession h4") + ).toBeNull(); + const titles = component.container.querySelectorAll( + ".person-profession p.person-profession-title strong" + ); + expect(titles).toHaveLength(2); + expect(titles[0]).toHaveTextContent("Regents Professor"); + expect(titles[1]).toHaveTextContent("Edplus at ASU"); + }); + }); }); diff --git a/packages/unity-react-core/src/components/PersonProfile/PersonProfile.tsx b/packages/unity-react-core/src/components/PersonProfile/PersonProfile.tsx index b5a5643a3d..8cd64295d6 100644 --- a/packages/unity-react-core/src/components/PersonProfile/PersonProfile.tsx +++ b/packages/unity-react-core/src/components/PersonProfile/PersonProfile.tsx @@ -85,27 +85,31 @@ const PersonProfile: React.FC = ({

    {name}

    -

    - {profession.title} -

    -

    - {profession.department} -

    +

    + {profession.title} +

    +

    + {profession.department} +