Make all page endpoints constants

- fix all cypress tests
- refactor all test to use LegacyTests/constants/PAGES_ENDPOINTS
- gatsby-config to use PAGES_ENDPOINTS
- remove ScoreStepList component
- update J40Header to use constants.PAGES_ENDPOINTS
- update snapshots
- there are 3 locations to update PAGES_ENDPOINTS, namely

1. LegacyTests/constants.tsx
2. constants.tsx
3. gatsby-config
This commit is contained in:
Vim USDS 2022-04-04 20:47:17 -07:00
commit abf49a9cbc
27 changed files with 93 additions and 163 deletions

View file

@ -8,6 +8,7 @@ import {hyphenizeString} from '../../../cypress/integration/common/helpers';
import * as styles from './dsContainer.module.scss';
import * as METHODOLOGY_COPY from '../../data/copy/methodology';
import {PAGES_ENDPOINTS} from '../../data/constants';
const DatasetContainer = () => {
@ -43,7 +44,7 @@ const DatasetContainer = () => {
</Grid>
<div className={styles.returnToTop}>
<Link to={`/methodology`}>
<Link to={PAGES_ENDPOINTS.METHODOLOGY}>
{METHODOLOGY_COPY.RETURN_TO_TOP.LINK}
</Link>
</div>

View file

@ -18,6 +18,7 @@ import Language from '../Language';
import siteLogo from '../../images/j40-logo-v2.png';
import * as styles from './J40Header.module.scss';
import * as COMMON_COPY from '../../data/copy/common';
import {PAGES_ENDPOINTS} from '../../data/constants';
const isAlertValid = new Date < COMMON_COPY.ALERTS.EXPIRATION_DATE;
@ -52,21 +53,21 @@ const J40Header = () => {
const methPageSubNavLinks = [
<Link
to={'/methodology'}
to={PAGES_ENDPOINTS.METHODOLOGY}
key={'methodology'}
activeClassName="usa-current"
data-cy={'nav-link-methodology'}>
{intl.formatMessage(COMMON_COPY.HEADER.METHODOLOGY)}
</Link>,
<Link
to={'/downloads'}
to={PAGES_ENDPOINTS.DOWNLOADS}
key={'downloads'}
activeClassName="usa-current"
data-cy={'nav-link-downloads'}>
{intl.formatMessage(COMMON_COPY.HEADER.DOWNLOADS)}
</Link>,
<Link
to={'/technical-support-docs'}
to={PAGES_ENDPOINTS.TSD}
key={'tsd'}
activeClassName="usa-current"
data-cy={'nav-link-technical-support-docs'}>
@ -76,21 +77,21 @@ const J40Header = () => {
const aboutSubNavLinks = [
<Link
to={'/about'}
to={PAGES_ENDPOINTS.ABOUT}
key={'about'}
activeClassName="usa-current"
data-cy={'nav-link-about'}>
{intl.formatMessage(COMMON_COPY.HEADER.ABOUT)}
</Link>,
<Link
to={'/faqs'}
to={PAGES_ENDPOINTS.FAQS}
key={'faqs'}
activeClassName="usa-current"
data-cy={'nav-link-faqs'}>
{intl.formatMessage(COMMON_COPY.HEADER.FAQs)}
</Link>,
<Link
to={'/public-engagement'}
to={PAGES_ENDPOINTS.PUBLIC_ENG}
key={'publicEng'}
activeClassName="usa-current"
data-cy={'nav-link-public-engagement'}>
@ -100,7 +101,7 @@ const J40Header = () => {
const navLinks = [
<Link
to={'/'}
to={PAGES_ENDPOINTS.EXPLORE}
key={'explore-tool'}
activeClassName="usa-current"
data-cy={'nav-link-explore-the-tool'}>
@ -143,7 +144,7 @@ const J40Header = () => {
</Menu>
</>,
<Link
to={'/contact'}
to={PAGES_ENDPOINTS.CONTACT}
key={'contact'}
activeClassName="usa-current"
data-cy={'nav-link-contact'}>

View file

@ -273,7 +273,7 @@ exports[`rendering of the J40Header checks if component renders 1`] = `
>
<a
data-cy="nav-link-technical-support-docs"
href="/en/technical-support-docs"
href="/en/technical-support-document"
>
Technical Support Document
</a>

View file

@ -2,6 +2,7 @@ import * as React from 'react';
import {render} from '@testing-library/react';
import LinkTypeWrapper from './index';
import {LocalizedComponent} from '../../test/testHelpers';
import {PAGES_ENDPOINTS} from '../../data/constants';
describe('testing all link types', () => {
it('tests internal links', () => {
@ -10,7 +11,7 @@ describe('testing all link types', () => {
<LinkTypeWrapper
linkText={'test link text'}
internal={true}
url={'/methodology'}
url={PAGES_ENDPOINTS.METHODOLOGY}
openUrlNewTab={false}
/>
</LocalizedComponent>,

View file

@ -1,91 +0,0 @@
import React from 'react';
import {
ProcessList,
ProcessListItem,
ProcessListHeading,
Grid,
} from '@trussworks/react-uswds';
import {useIntl} from 'gatsby-plugin-intl';
import * as METHODOLOGY_COPY from '../data/copy/methodology';
const ScoreStepsList = () => {
const intl = useIntl();
return (
<>
<h2>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.HEADING)}
</h2>
<Grid row>
<Grid col={7}>
<p>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.DESCRIPTION_1)}
</p>
<p>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.DESCRIPTION_2)}
</p>
</Grid>
</Grid>
<ProcessList>
{/* Step 1 */}
<ProcessListItem>
<ProcessListHeading type="h3">
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_HEADING)}
</ProcessListHeading>
<p>{' '}</p>
<p className={'flush'}>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_INFO)}
</p>
{/* Step 1 A */}
<h4>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_A_HEADING)}
</h4>
<p className={'flush'}>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_A_INFO_1)}
</p>
<p>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_A_INFO_2)}
</p>
{/* Step 1 B */}
<h4>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_B_HEADING)}
</h4>
{METHODOLOGY_COPY.COMPLEX_METH_STEPS.STEP_2_B_INFO}
{/* Step 1 C */}
<h4>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_C_HEADING)}
</h4>
<p className={'flush'}>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_1_C_INFO)}
</p>
</ProcessListItem>
{/* Step 2 */}
<ProcessListItem>
<ProcessListHeading type="h3">
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_2_HEADING)}
</ProcessListHeading>
<p>{' '}</p>
<p className={'flush'}>
{intl.formatMessage(METHODOLOGY_COPY.METHODOLOGY_STEPS.STEP_2_INFO)}
</p>
{METHODOLOGY_COPY.COMPLEX_METH_STEPS.FORMULA}
</ProcessListItem>
</ProcessList>
</>
);
};
export default ScoreStepsList;