From b9f5e694816bc39a138e16f07be88f8e885153a1 Mon Sep 17 00:00:00 2001 From: Johanna <103958711+johanna-skylight@users.noreply.github.com> Date: Mon, 3 Jul 2023 08:56:16 -0400 Subject: [PATCH] Johanna/support admin landing page (#6050) * Modified landing page * added flag to the beta block * Removed implicit import * Created a resuable wrapper component * Added unit testing * Fixed spec 01 --- cypress/e2e/01-organization_sign_up.cy.js | 2 +- .../app/supportAdmin/SupportAdmin.test.tsx | 25 ++ .../src/app/supportAdmin/SupportAdmin.tsx | 85 ++++--- .../__snapshots__/SupportAdmin.test.tsx.snap | 234 ++++++++++++++++++ 4 files changed, 314 insertions(+), 32 deletions(-) create mode 100644 frontend/src/app/supportAdmin/SupportAdmin.test.tsx create mode 100644 frontend/src/app/supportAdmin/__snapshots__/SupportAdmin.test.tsx.snap diff --git a/cypress/e2e/01-organization_sign_up.cy.js b/cypress/e2e/01-organization_sign_up.cy.js index 1ebe4915d4..0055642253 100644 --- a/cypress/e2e/01-organization_sign_up.cy.js +++ b/cypress/e2e/01-organization_sign_up.cy.js @@ -55,7 +55,7 @@ describe("Organization sign up",() => { cy.injectSRAxe(); cy.checkA11y(); - cy.contains("Organizations pending identify verification").click(); + cy.contains("Identify verification").click(); cy.get("[data-cy=pending-orgs-title]").should("be.visible"); cy.contains("td", `${organization.name}`); diff --git a/frontend/src/app/supportAdmin/SupportAdmin.test.tsx b/frontend/src/app/supportAdmin/SupportAdmin.test.tsx new file mode 100644 index 0000000000..9007810e65 --- /dev/null +++ b/frontend/src/app/supportAdmin/SupportAdmin.test.tsx @@ -0,0 +1,25 @@ +import { render } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; +import * as flaggedMock from "flagged"; + +import SupportAdmin from "./SupportAdmin"; + +describe("SupportAdming", () => { + const renderWithRouter = () => + render( + + + + ); + + it("loads menu categories", () => { + const { container } = renderWithRouter(); + expect(container).toMatchSnapshot(); + }); + + it("loads menu categories including Beta", () => { + jest.spyOn(flaggedMock, "useFeature").mockReturnValueOnce(true); + const { container } = renderWithRouter(); + expect(container).toMatchSnapshot(); + }); +}); diff --git a/frontend/src/app/supportAdmin/SupportAdmin.tsx b/frontend/src/app/supportAdmin/SupportAdmin.tsx index 542f352fac..22e1803951 100644 --- a/frontend/src/app/supportAdmin/SupportAdmin.tsx +++ b/frontend/src/app/supportAdmin/SupportAdmin.tsx @@ -3,6 +3,21 @@ import { useFeature } from "flagged"; import { LinkWithQuery } from "../commonComponents/LinkWithQuery"; import { useDocumentTitle } from "../utils/hooks"; +type CategoryMenuProps = { + heading: string; + children: React.ReactNode; +}; + +const CategoryMenu: React.FC = ({ + heading, + children, +}: CategoryMenuProps) => ( +
+

{heading}

+ +
+); + const SupportAdmin = () => { useDocumentTitle("Support admin"); const hivEnabled = useFeature("hivEnabled") as boolean; @@ -20,38 +35,46 @@ const SupportAdmin = () => {
-
- - Organizations pending identify verification - -
-
- - Add organization admin - -
-
- - Add a new testing device - -
-
- - Edit existing testing device - -
-
- - Organization data - +
+ +
  • + + Identify verification + +
  • +
  • + + Add organization admin + +
  • +
  • + + Organization data + +
  • +
    + +
  • + + Add a new testing device + +
  • +
  • + + Edit existing testing device + +
  • +
    + {hivEnabled && ( + +
  • + + Beta - HIV CSV Upload + +
  • +
    + )}
    - {hivEnabled && ( -
    - - Beta - HIV CSV Upload - -
    - )}
    diff --git a/frontend/src/app/supportAdmin/__snapshots__/SupportAdmin.test.tsx.snap b/frontend/src/app/supportAdmin/__snapshots__/SupportAdmin.test.tsx.snap new file mode 100644 index 0000000000..d3c1d419d7 --- /dev/null +++ b/frontend/src/app/supportAdmin/__snapshots__/SupportAdmin.test.tsx.snap @@ -0,0 +1,234 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SupportAdming loads menu categories 1`] = ` +
    +
    +
    +
    +
    +
    +
    +

    + Support admin +

    +
    +
    + +
    +
    +
    +
    +
    +`; + +exports[`SupportAdming loads menu categories including Beta 1`] = ` +
    +
    +
    +
    +
    +
    +
    +

    + Support admin +

    +
    +
    + +
    +
    +
    +
    +
    +`;