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

[NOREF] - Fix 2 pager modal link #1419

Merged
merged 4 commits into from
Oct 11, 2024
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 @@ -120,7 +120,7 @@ const SixPagerMeeting = () => {
<SolutionDetailsModal
solution={selectedSolution}
openedFrom={prevPathname}
closeRoute="/help-and-knowledge/about-six-page-concept-papers-and-review-meeting"
closeRoute="/help-and-knowledge/about-6-page-concept-papers-and-review-meeting"
/>
)}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MemoryRouter, Route } from 'react-router-dom';
import { render } from '@testing-library/react';
import { render, waitForElementToBeRemoved } from '@testing-library/react';
import { possibleSolutionsMock } from 'tests/mock/solutions';
import VerboseMockedProvider from 'tests/MockedProvider';

Expand All @@ -9,8 +9,8 @@ import TwoPagerMeeting from './index';
const mocks = [...possibleSolutionsMock];

describe('TwoPagerMeeting', () => {
it('matches the snapshot', () => {
const { asFragment } = render(
it('matches the snapshot', async () => {
const { asFragment, getByTestId } = render(
<MemoryRouter
initialEntries={[
'/help-and-knowledge/about-2-page-concept-papers-and-review-meetings'
Expand All @@ -23,6 +23,9 @@ describe('TwoPagerMeeting', () => {
</Route>
</MemoryRouter>
);

await waitForElementToBeRemoved(() => getByTestId('page-loading'));

expect(asFragment()).toMatchSnapshot();
});
});
37 changes: 22 additions & 15 deletions src/features/HelpAndKnowledge/Articles/TwoPagerMeeting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import React, { useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import {
Grid,
GridContainer,
Expand All @@ -10,16 +11,16 @@ import {
import HelpBreadcrumb from 'features/HelpAndKnowledge/Articles/_components/HelpBreadcrumb';
import HelpCategoryTag from 'features/HelpAndKnowledge/Articles/_components/HelpCategoryTag';
import RelatedArticles from 'features/HelpAndKnowledge/Articles/_components/RelatedArticles';
import { findSolutionByRouteParam } from 'features/HelpAndKnowledge/SolutionsHelp';
import SolutionDetailsModal from 'features/HelpAndKnowledge/SolutionsHelp/SolutionDetails/Modal';
import { OperationalSolutionKey } from 'gql/generated/graphql';

import Alert from 'components/Alert';
import ExternalLink from 'components/ExternalLink';
import UswdsReactLink from 'components/LinkWrapper';
import MainContent from 'components/MainContent';
import PageHeading from 'components/PageHeading';
import PageLoading from 'components/PageLoading';
import ScrollLink from 'components/ScrollLink';
import useHelpSolution from 'hooks/useHelpSolutions';
import useModalSolutionState from 'hooks/useModalSolutionState';
import { getKeys } from 'types/translation';
import { tArray, tObject } from 'utils/translation';
Expand Down Expand Up @@ -48,6 +49,17 @@ type StepThreeListType = {
const TwoPagerMeeting = () => {
const { t: twoPageMeetingT } = useTranslation('twoPageMeeting');

const location = useLocation();

const [initLocation] = useState<string>(location.pathname);

const { prevPathname, selectedSolution, renderModal, loading } =
useModalSolutionState(OperationalSolutionKey.LDG);

const ldgRoute = `${initLocation}${location.search}${
location.search ? '&' : '?'
}solution=learning-and-diffusion-group&section=about`;

const summaryboxListItems: string[] = tArray(
'twoPageMeeting:summaryBox.list'
);
Expand Down Expand Up @@ -92,25 +104,20 @@ const TwoPagerMeeting = () => {
'twoPageMeeting:about.stepThree.list'
);

const { helpSolutions } = useHelpSolution();
const { prevPathname, selectedSolution: solution } =
useModalSolutionState(null);

// Solution to render in modal
const selectedSolution = findSolutionByRouteParam(
solution?.route || null,
helpSolutions
);
if (loading) {
return <PageLoading />;
}

return (
<>
{selectedSolution && (
{renderModal && selectedSolution && (
<SolutionDetailsModal
solution={selectedSolution}
openedFrom={prevPathname}
closeRoute="help-and-knowledge/about-2-page-concept-papers-and-review-meetings"
closeRoute="/help-and-knowledge/about-2-page-concept-papers-and-review-meetings"
/>
)}

<MainContent>
<GridContainer>
<Grid>
Expand Down Expand Up @@ -462,7 +469,7 @@ const TwoPagerMeeting = () => {
ml: (
<UswdsReactLink
className="usa-button usa-button--unstyled"
to="?solution=learning-and-diffusion-group&section=about"
to={ldgRoute}
>
{k}
</UswdsReactLink>
Expand Down
2 changes: 1 addition & 1 deletion src/features/HelpAndKnowledge/Articles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const helpAndKnowledgeArticles: ArticleProps[] = [
},
{
key: HelpArticle.SIX_PAGER_MEETING,
route: '/about-six-page-concept-papers-and-review-meeting',
route: '/about-6-page-concept-papers-and-review-meeting',
translation: 'sixPageMeeting',
type: ArticleCategories.MODEL_CONCEPT_AND_DESIGN
},
Expand Down
2 changes: 1 addition & 1 deletion src/features/HelpAndKnowledge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const HelpAndKnowledge = () => {
</Route>

<Route
path="/help-and-knowledge/about-six-page-concept-papers-and-review-meeting"
path="/help-and-knowledge/about-6-page-concept-papers-and-review-meeting"
exact
>
<SixPagerMeeting />
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en-US/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const routes = {
'Help and knowledge center - High level project plan',
'/about-2-page-concept-papers-and-review-meetings':
'Help and knowledge center - About 2-page concept papers and review meetings',
'/about-six-page-concept-papers-and-review-meeting':
'/about-6-page-concept-papers-and-review-meeting':
'Help and knowledge center - About 6-page concept papers and review meetings',
'/utilizing-solutions': 'Help and knowledge center - Utilizing solutions',
'/model-and-solution-implementation':
Expand Down