From 86109a80086595547da7b86ff8caad6b5acab38e Mon Sep 17 00:00:00 2001 From: Caleb Cox Date: Fri, 6 Sep 2024 12:02:19 -0500 Subject: [PATCH] Remove the settings menu during the setup tour --- .../MultiPageLayout/MultiPageHeader.test.tsx | 87 ++++++++++--------- .../MultiPageLayout/MultiPageHeader.tsx | 4 +- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/components/Shared/MultiPageLayout/MultiPageHeader.test.tsx b/src/components/Shared/MultiPageLayout/MultiPageHeader.test.tsx index 4dac70fa9..ebce11a75 100644 --- a/src/components/Shared/MultiPageLayout/MultiPageHeader.test.tsx +++ b/src/components/Shared/MultiPageLayout/MultiPageHeader.test.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { ThemeProvider } from '@mui/material/styles'; import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; +import { TestSetupProvider } from 'src/components/Setup/SetupProvider'; import theme from 'src/theme'; import { HeaderTypeEnum, MultiPageHeader } from './MultiPageHeader'; @@ -9,19 +10,33 @@ const totalBalance = 'CA111'; const title = 'test title'; const onNavListToggle = jest.fn(); +interface TestComponentProps { + headerType?: HeaderTypeEnum; + noRightExtra?: boolean; + onSetupTour?: boolean; +} + +const TestComponent: React.FC = ({ + headerType = HeaderTypeEnum.Report, + noRightExtra = false, + onSetupTour, +}) => ( + + + + + +); + describe('MultiPageHeader', () => { it('default', async () => { - const { getByRole, getByText } = render( - - - , - ); + const { getByRole, getByText } = render(); expect(getByText(title)).toBeInTheDocument(); expect(getByText('CA111')).toBeInTheDocument(); @@ -32,49 +47,41 @@ describe('MultiPageHeader', () => { }); it('should not render rightExtra if undefined', async () => { - const { queryByText } = render( - - - , + const { queryByText } = render(); + + expect(queryByText('CA111')).not.toBeInTheDocument(); + }); + + it('should render the Reports menu', async () => { + const { getByTestId, getByText } = render( + , ); - expect(queryByText('CA111')).toBeNull(); + expect(getByText('Toggle Navigation Panel')).toBeInTheDocument(); + expect(getByTestId('ReportsFilterIcon')).toBeInTheDocument(); }); it('should render the Settings menu', async () => { const { getByTestId, getByText } = render( - - - , + , ); expect(getByText('Toggle Preferences Menu')).toBeInTheDocument(); expect(getByTestId('SettingsMenuIcon')).toBeInTheDocument(); }); + it('should not render the Settings menu during the setup tour', async () => { + const { queryByTestId, queryByText } = render( + , + ); + + expect(queryByText('Toggle Preferences Menu')).not.toBeInTheDocument(); + expect(queryByTestId('SettingsMenuIcon')).not.toBeInTheDocument(); + }); + it('should render the Tools menu', async () => { const { getByTestId, getByText } = render( - - - , + , ); expect(getByText('Toggle Tools Menu')).toBeInTheDocument(); diff --git a/src/components/Shared/MultiPageLayout/MultiPageHeader.tsx b/src/components/Shared/MultiPageLayout/MultiPageHeader.tsx index c8d0f571d..c677c308e 100644 --- a/src/components/Shared/MultiPageLayout/MultiPageHeader.tsx +++ b/src/components/Shared/MultiPageLayout/MultiPageHeader.tsx @@ -4,6 +4,7 @@ import MenuIcon from '@mui/icons-material/Menu'; import { Box, IconButton, Typography } from '@mui/material'; import { styled } from '@mui/material/styles'; import { useTranslation } from 'react-i18next'; +import { useSetupContext } from 'src/components/Setup/SetupProvider'; import theme from 'src/theme'; export enum HeaderTypeEnum { @@ -65,6 +66,7 @@ export const MultiPageHeader: FC = ({ headerType, }) => { const { t } = useTranslation(); + const { onSetupTour } = useSetupContext(); let titleAccess; if (headerType === HeaderTypeEnum.Report) { @@ -90,7 +92,7 @@ export const MultiPageHeader: FC = ({ data-testid="ReportsFilterIcon" /> )} - {headerType === HeaderTypeEnum.Settings && ( + {!onSetupTour && headerType === HeaderTypeEnum.Settings && (