diff --git a/assets/src/components/nav/navMenu.tsx b/assets/src/components/nav/navMenu.tsx index 5e5226f87..c0f91f461 100644 --- a/assets/src/components/nav/navMenu.tsx +++ b/assets/src/components/nav/navMenu.tsx @@ -7,7 +7,6 @@ import * as BsIcon from "../../helpers/bsIcons" import { joinClasses } from "../../helpers/dom" import { reload } from "../../models/browser" import { LoggedInAs } from "../loggedInAs" -import inTestGroup, { TestGroups } from "../../userInTestGroup" import getEmailAddress from "../../userEmailAddress" interface Props { @@ -16,7 +15,6 @@ interface Props { } const NavMenu: React.FC = ({ mobileMenuIsOpen, toggleMobileMenu }) => { - const keycloakEnabled = inTestGroup(TestGroups.KeycloakSso) const email = getEmailAddress() return ( @@ -49,7 +47,7 @@ const NavMenu: React.FC = ({ mobileMenuIsOpen, toggleMobileMenu }) => {
- {keycloakEnabled && email && ( + {email && ( <>
@@ -96,22 +94,18 @@ const NavMenu: React.FC = ({ mobileMenuIsOpen, toggleMobileMenu }) => { Settings - {keycloakEnabled && ( - <> - -
-
- - - Logout - - - - )} + +
+
+ + + Logout + +
diff --git a/assets/src/components/nav/topNav.tsx b/assets/src/components/nav/topNav.tsx index 989e8654c..b145a6c92 100644 --- a/assets/src/components/nav/topNav.tsx +++ b/assets/src/components/nav/topNav.tsx @@ -8,13 +8,11 @@ import { LoggedInAs } from "../loggedInAs" import getEmailAddress from "../../userEmailAddress" import { CircleButton } from "../circleButton" import { UserAvatar } from "../userAvatar" -import inTestGroup, { TestGroups } from "../../userInTestGroup" const TopNav = (): JSX.Element => { const email = getEmailAddress() const [showUserPopover, setShowUserPopover] = useState(false) const userButtonRef = useRef(null) - const showLoggedInUser = inTestGroup(TestGroups.KeycloakSso) return (
@@ -31,46 +29,41 @@ const TopNav = (): JSX.Element => { - {showLoggedInUser && ( -
  • -
    - { - setShowUserPopover(!showUserPopover) - }} - title="User Info" - > - - -
    - +
    + { + setShowUserPopover(!showUserPopover) + }} + title="User Info" > - - - + +
    + + + + + + + + + - - - - - - Log out - - - - - -
  • - )} + Log out + + + + + +
    ) diff --git a/assets/src/userInTestGroup.ts b/assets/src/userInTestGroup.ts index abd393401..eeab87498 100644 --- a/assets/src/userInTestGroup.ts +++ b/assets/src/userInTestGroup.ts @@ -5,7 +5,6 @@ export enum TestGroups { DemoMode = "demo-mode", DetoursList = "detours-list", DetoursPilot = "detours-pilot", - KeycloakSso = "keycloak-sso", MinimalLadderPage = "minimal-ladder-page", LateView = "late-view", } diff --git a/assets/tests/components/app.test.tsx b/assets/tests/components/app.test.tsx index acb8a487e..00b1c3964 100644 --- a/assets/tests/components/app.test.tsx +++ b/assets/tests/components/app.test.tsx @@ -26,8 +26,6 @@ import { OpenView, PagePath } from "../../src/state/pagePanelState" import { viewFactory } from "../factories/pagePanelStateFactory" import userEvent from "@testing-library/user-event" import { mockUsePanelState } from "../testHelpers/usePanelStateMocks" -import getTestGroups from "../../src/userTestGroups" -import { TestGroups } from "../../src/userInTestGroup" jest.mock("../../src/hooks/useDataStatus", () => ({ __esModule: true, @@ -52,7 +50,6 @@ beforeEach(() => { describe("App", () => { test("renders", () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) const result = render() expect(result.asFragment()).toMatchSnapshot() }) diff --git a/assets/tests/components/appStateWrapper.test.tsx b/assets/tests/components/appStateWrapper.test.tsx index 45fede0ee..8138e03a8 100644 --- a/assets/tests/components/appStateWrapper.test.tsx +++ b/assets/tests/components/appStateWrapper.test.tsx @@ -2,8 +2,6 @@ import { test, expect, jest } from "@jest/globals" import React from "react" import { render } from "@testing-library/react" import AppStateWrapper from "../../src/components/appStateWrapper" -import getTestGroups from "../../src/userTestGroups" -import { TestGroups } from "../../src/userInTestGroup" jest.mock("userTestGroups", () => ({ __esModule: true, @@ -11,7 +9,6 @@ jest.mock("userTestGroups", () => ({ })) test("renders", () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) const result = render() expect(result.asFragment()).toMatchSnapshot() }) diff --git a/assets/tests/components/nav/navMenu.test.tsx b/assets/tests/components/nav/navMenu.test.tsx index c0cd5be67..16c401425 100644 --- a/assets/tests/components/nav/navMenu.test.tsx +++ b/assets/tests/components/nav/navMenu.test.tsx @@ -7,8 +7,6 @@ import * as browser from "../../../src/models/browser" import { openDrift } from "../../../src/helpers/drift" import NavMenu from "../../../src/components/nav/navMenu" import { BrowserRouter } from "react-router-dom" -import getTestGroups from "../../../src/userTestGroups" -import { TestGroups } from "../../../src/userInTestGroup" import getEmailAddress from "../../../src/userEmailAddress" jest.mock("../../../src/helpers/drift", () => ({ @@ -81,7 +79,6 @@ describe("NavMenu", () => { }) test("shows who is logged in", async () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) jest.mocked(getEmailAddress).mockReturnValue("test@example.localhost") render( @@ -93,20 +90,7 @@ describe("NavMenu", () => { expect(await screen.findByText("Logged in as")).toBeVisible() }) - test("does not show who is logged in if the user isn't in the Keycloak test group", () => { - jest.mocked(getTestGroups).mockReturnValue([]) - - render( - - - - ) - - expect(screen.queryByText("Logged in as")).not.toBeInTheDocument() - }) - test("shows logout button", async () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) jest.mocked(getEmailAddress).mockReturnValue("test@example.localhost") render( @@ -118,20 +102,6 @@ describe("NavMenu", () => { expect(screen.getByRole("link", { name: "Logout" })).toBeVisible() }) - test("doesn't show logout button if the user isn't in the Keycloak test group", async () => { - jest.mocked(getTestGroups).mockReturnValue([]) - - render( - - - - ) - - expect( - screen.queryByRole("link", { name: "Logout" }) - ).not.toBeInTheDocument() - }) - test("refresh button reloads the page", async () => { const reloadSpy = jest .spyOn(browser, "reload") diff --git a/assets/tests/components/nav/topNav.test.tsx b/assets/tests/components/nav/topNav.test.tsx index d30d701a6..1ee031229 100644 --- a/assets/tests/components/nav/topNav.test.tsx +++ b/assets/tests/components/nav/topNav.test.tsx @@ -8,13 +8,6 @@ import { initialState } from "../../../src/state" import { BrowserRouter } from "react-router-dom" import "@testing-library/jest-dom/jest-globals" import * as browser from "../../../src/models/browser" -import getTestGroups from "../../../src/userTestGroups" -import { TestGroups } from "../../../src/userInTestGroup" - -jest.mock("userTestGroups", () => ({ - __esModule: true, - default: jest.fn(() => []), -})) describe("TopNav", () => { test("refresh button reloads the page", async () => { @@ -38,26 +31,7 @@ describe("TopNav", () => { }) describe("User info", () => { - test("does not have a 'User Info' button if the user isn't in the right test group", () => { - jest.mocked(getTestGroups).mockReturnValue([]) - - const dispatch = jest.fn() - render( - - - - - - ) - - expect( - screen.queryByRole("button", { name: "User Info" }) - ).not.toBeInTheDocument() - }) - test("has a 'User Info' button", () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) - const dispatch = jest.fn() render( @@ -73,8 +47,6 @@ describe("TopNav", () => { }) test("brings up an element with 'logged in as' text and a logout link when clicked", async () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) - const dispatch = jest.fn() const user = userEvent.setup() render( @@ -99,8 +71,6 @@ describe("TopNav", () => { }) test("clicking the 'User Info' button again makes the 'Logged in as' popover disappear", async () => { - jest.mocked(getTestGroups).mockReturnValue([TestGroups.KeycloakSso]) - const dispatch = jest.fn() const user = userEvent.setup() render(