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

@ -12,14 +12,11 @@
*
*/
const endpoints = [
'en/',
'en/cejst',
'en/methodology',
'en/contact',
'en/404',
'en/public-engagement',
];
import {PAGES_ENDPOINTS} from './constants';
const rawEndpoints = Object.values(PAGES_ENDPOINTS);
const endpoints = rawEndpoints.map((endpoint) => `en${endpoint}`);
// The violation callback will post the violations into the terminal
// eslint-disable-next-line require-jsdoc

View file

@ -1,13 +1,9 @@
// / <reference types="Cypress" />
import {PAGES_ENDPOINTS} from '../LegacyTests/constants';
describe('Do all the English pages have all links with a defined href attribute?', () => {
const pages = [
'/',
'cejst',
'methodology',
'contact',
'public-engagement',
];
const pages = Object.values(PAGES_ENDPOINTS);
pages.forEach((page) => {
it(`test all href attr on ${page} page`, () => {

View file

@ -1,8 +1,10 @@
export const ENDPOINTS = {
EXPLORE_THE_TOOL: 'en/',
ABOUT: '/en/about',
METHODOLOGY: '/en/methodology',
CONTACT: 'en/contact',
PUBLIC: 'en/public-engagement',
DOWNLOAD: 'en/downloads',
export const PAGES_ENDPOINTS = {
EXPLORE: '/',
METHODOLOGY: '/methodology',
DOWNLOADS: '/downloads',
TSD: '/technical-support-document',
ABOUT: '/about',
FAQS: '/faqs',
PUBLIC_ENG: '/public-engagement',
CONTACT: '/contact',
};

View file

@ -1,11 +1,14 @@
// / <reference types="Cypress" />
describe('Translation Test', () => {
it('Sets default language to /en and redirects', () => {
cy.visit('http://localhost:8000');
cy.url().should('include', '/en/');
// cy.get('[data-cy=about-page-heading]').contains('About');
});
import {PAGES_ENDPOINTS} from './constants';
describe('Navigate to each endpoint', () => {
Object.values(PAGES_ENDPOINTS).map((endpoint) =>
it(`for the ${endpoint} page, it adds /en and redirects`, () => {
cy.visit(endpoint);
cy.url().should('include', '/en/');
}),
);
// Todo VS: Understand how to create es content
// it('Sets page content to spanish when visiting Spanish URL', () => {

View file

@ -4,7 +4,7 @@
A risk with this test is that if the feature/area that is currently being selected become non-prioritized, then this
test will fail. However it would be a major win for that area!
*/
import {ENDPOINTS} from './constants';
import {PAGES_ENDPOINTS} from './constants';
const devices = [
[1024, 720],
@ -15,7 +15,7 @@ const devices = [
describe('tests that the map side panel renders MapIntroduction component', () => {
devices.forEach((device) => {
it(`should render MapIntroduction component on ${device[0]} x ${device[1]}`, () => {
cy.visit(ENDPOINTS.EXPLORE_THE_TOOL);
cy.visit(PAGES_ENDPOINTS.EXPLORE);
cy.viewport(device[0], device[1]);
cy.get('aside').should('be.visible');
});

View file

@ -1,8 +1,9 @@
// / <reference types="Cypress" />
import {PAGES_ENDPOINTS} from '../LegacyTests/constants';
describe('Does the map zoom and adjust to lat/long correctly?', () => {
it('should start at zoom level 3', () => {
cy.visit('http://localhost:8000/en/cejst');
cy.visit(PAGES_ENDPOINTS.EXPLORE);
cy.url().should('include', '#3');
});
it('should change to level 4 when you hit the zoom button', () => {
@ -10,7 +11,7 @@ describe('Does the map zoom and adjust to lat/long correctly?', () => {
cy.url().should('include', '#4');
});
// Intermittent failure still exist
// Intermittent failure still exist ticket #886
// it('should show the correct lat/lng coordinates in the URL',
// {
// retries: {
@ -47,6 +48,7 @@ describe('Does the map zoom and adjust to lat/long correctly?', () => {
// },
// () => {
// const [expectedZoom, expectedLat, expectedLng] = [12.05, 41.40965, -75.65978];
// //This could be where the issue is:
// const expectedURL = `http://localhost:8000/en/cejst/#${expectedZoom}/${expectedLat}/${expectedLng}`;
// cy.visit(expectedURL);
// cy.getMap().then((map) => {

View file

@ -1,5 +1,7 @@
// / <reference types="Cypress" />
import {PAGES_ENDPOINTS} from './constants';
describe('Will it zoom into territories correctly?',
{
retries: {
@ -16,7 +18,7 @@ describe('Will it zoom into territories correctly?',
() => {
beforeEach(() => {
cy.viewport('macbook-13');
cy.visit('http://localhost:8000/en/cejst');
cy.visit(PAGES_ENDPOINTS.EXPLORE);
});
// The below values all assume a 13-inch MB as set in viewport above.