Skip to content

Commit

Permalink
VACMS-19386 Cleanup in support of checklist template
Browse files Browse the repository at this point in the history
  • Loading branch information
randimays committed Nov 15, 2024
1 parent b560102 commit 2c6b085
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 174 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ You should set these up before attempting to install the repo.

7. In the `next-build` directory, run `yarn setup` to pull initial built assets from the `vets-website` repo. This will grab a bunch of files from a vets-website S3 bucket and place them into the appropriate `public/` folders.

8. Run `yarn dev`.
8. In your `envs/.env.local` file, uncomment `FEATURE_NEXT_BUILD_CONTENT_ALL=true`.

9. Run `yarn dev`.

You will now have a Next.js development server running at http://localhost:3999, which will refresh with changes to your local environment. (Note: your local port may differ if you changed the value for `PORT` in .env.local).

Expand Down
2 changes: 1 addition & 1 deletion READMEs/tugboat.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See the [va.gov-cms tugboat docs](https://github.com/department-of-veterans-affa
At VA, our lower environments are each built from a Tugboat Base Preview, in some fashion. Our Tugboat configuration is relevant to the discussion:

1. **Project**: [next-build](https://tugboat.vfs.va.gov/64d5537c2d3036648da7c7ff)
1. **Repository**: [next-build Pull Request Environments](https://tugboat.vfs.va.gov/64d5537c2d3036648da7c7ff5fd3b8ee7b4657022b5722d6) — Is used for managing PR Previews, automatically triggered by Pull Requests in next-build repo.
1. **Repository**: [next-build Pull Request Environments](https://tugboat.vfs.va.gov/64d5537c2d3036648da7c7ff) — Is used for managing PR Previews, automatically triggered by Pull Requests in next-build repo.
1. **Base Preview**: Built nightly at 11am UTC (6am EST, 5am EDT). It is built one hour later than the CMS Mirror Base Preview's nightly refresh because it is the default target endpoint for data. This data will then be used for all next-build PR Preview envs until the next time this Base Preview is refreshed.

## CLI Setup
Expand Down
1 change: 1 addition & 0 deletions generator-templates/component/test.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
import { {{pascalCase name}} } from './index'

Expand Down
25 changes: 14 additions & 11 deletions generator-templates/query/test.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
/**
* @jest-environment node
*/

import { {{pascalCase name}} } from '@/types/drupal/node'
import { queries } from '@/data/queries'
import mockData from '@/mocks/{{camelCase name}}.mock.json'

const {{pascalCase name}}Mock: {{pascalCase name}} = mockData

describe('{{pascalCase name}} formatData', () => {
let windowSpy

beforeEach(() => {
windowSpy = jest.spyOn(window, 'window', 'get')
})

afterEach(() => {
windowSpy.mockRestore()
// remove if this component does not have a data fetch
describe('DrupalJsonApiParams configuration', () => {
test('params function sets the correct include fields', () => {
// TODO
})
})

describe('{{pascalCase name}} formatData', () => {
test('outputs formatted data', () => {
windowSpy.mockImplementation(() => undefined)

expect(
queries.formatData('node--{{snakeCase name}}', {{pascalCase name}}Mock)
).toMatchSnapshot()
})

test('handles no answers correctly', () => {
// TODO
})
})
84 changes: 42 additions & 42 deletions src/data/queries/index.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import { createQueries } from 'next-drupal-query'
import * as PressRelease from './pressRelease'
import * as PressReleaseTeaser from './pressReleaseTeaser'
import * as PressReleaseListing from './pressReleaseListing'
import * as NewsStory from './newsStory'
import * as NewsStoryTeaser from './newsStoryTeaser'
import * as StoryListing from './storyListing'
import * as QuestionAnswer from './questionAnswer'
import * as ExpandableText from './expandableText'
import * as LinkTeaser from './linkTeaser'
import * as MediaImage from './mediaImage'
import * as MediaDocument from './mediaDocument'
import * as MediaVideo from './mediaVideo'
import * as Banners from './banners'
import * as PersonProfile from './personProfile'
import * as Button from './button'
import * as AudienceTopics from './audienceTopics'
import * as Accordion from './accordion'
import * as Alert from './alert'
import * as AlertBlock from './alertBlock'
import * as AlertSingle from './alertSingle'
import * as AlertNonReusable from './alertNonReusable'
import * as EmailContact from './emailContact'
import * as PhoneNumber from './phoneNumber'
import * as ContactInfo from './contactInfo'
import * as AlertSingle from './alertSingle'
import * as AudienceTopics from './audienceTopics'
import * as Banners from './banners'
import * as BenefitsHub from './benefitsHubLinks'
import * as Wysiwyg from './wysiwyg'
import * as StaticPathResources from './staticPathResources'
import * as HeaderFooter from './headerFooter'
import * as ProcessList from './processList'
import * as PromoBlock from './promoBlock'
import * as Button from './button'
import * as CollapsiblePanel from './collapsiblePanel'
import * as CollapsiblePanelItem from './collapsiblePanelItem'
import * as ContactInfo from './contactInfo'
import * as EmailContact from './emailContact'
import * as Event from './event'
import * as EventTeaser from './eventTeaser'
import * as EventListing from './eventListing'
import * as VamcEhr from './vamcEhr'
import * as EventTeaser from './eventTeaser'
import * as ExpandableText from './expandableText'
import * as FeaturedContent from './featuredContent'
import * as Accordion from './accordion'
import * as SupportServices from './supportServices'
import * as ResourcesSupport from './resourcesSupport'
import * as CollapsiblePanel from './collapsiblePanel'
import * as CollapsiblePanelItem from './collapsiblePanelItem'
import * as HeaderFooter from './headerFooter'
import * as HealthServices from './healthServices'
import * as LinkTeaser from './linkTeaser'
import * as MediaDocument from './mediaDocument'
import * as MediaImage from './mediaImage'
import * as MediaVideo from './mediaVideo'
import * as NewsStory from './newsStory'
import * as NewsStoryTeaser from './newsStoryTeaser'
import * as NumberCallout from './numberCallout'
import * as Table from './table'
import * as ReactWidget from './reactWidget'
import * as PersonProfile from './personProfile'
import * as PhoneNumber from './phoneNumber'
import * as PressRelease from './pressRelease'
import * as PressReleaseListing from './pressReleaseListing'
import * as PressReleaseTeaser from './pressReleaseTeaser'
import * as ProcessList from './processList'
import * as PromoBlock from './promoBlock'
import * as QaGroup from './qaGroup'
import * as QaParagraph from './qaParagraph'
import * as QaSection from './qaSection'
import * as QaGroup from './qaGroup'
import * as QuestionAnswer from './questionAnswer'
import * as ReactWidget from './reactWidget'
import * as ResourcesSupport from './resourcesSupport'
import * as StaticPathResources from './staticPathResources'
import * as StoryListing from './storyListing'
import * as SupportServices from './supportServices'
import * as Table from './table'
import * as VamcEhr from './vamcEhr'
import * as VetCenter from './vetCenter'
import * as HealthServices from './healthServices'
import * as Wysiwyg from './wysiwyg'
import {
ResourceType,
ParagraphResourceType,
Expand All @@ -57,22 +57,22 @@ import {
export const QUERIES_MAP = {
// Standard Drupal entity data queries
// Nodes
[RESOURCE_TYPES.BENEFITS_HUB]: BenefitsHub, // "Benefits Hub Landing Page"
[RESOURCE_TYPES.EVENT]: Event,
[`${RESOURCE_TYPES.EVENT}--teaser` as const]: EventTeaser,
[RESOURCE_TYPES.EVENT_LISTING]: EventListing,
[RESOURCE_TYPES.HEALTH_SERVICES]: HealthServices,
[RESOURCE_TYPES.STORY]: NewsStory,
[`${RESOURCE_TYPES.STORY}--teaser` as const]: NewsStoryTeaser,
[RESOURCE_TYPES.STORY_LISTING]: StoryListing,
[RESOURCE_TYPES.QA]: QuestionAnswer,
[RESOURCE_TYPES.EVENT]: Event,
[`${RESOURCE_TYPES.EVENT}--teaser` as const]: EventTeaser,
[RESOURCE_TYPES.EVENT_LISTING]: EventListing,
[RESOURCE_TYPES.PERSON_PROFILE]: PersonProfile,
[RESOURCE_TYPES.PRESS_RELEASE]: PressRelease,
[`${RESOURCE_TYPES.PRESS_RELEASE}--teaser` as const]: PressReleaseTeaser,
[RESOURCE_TYPES.PRESS_RELEASE_LISTING]: PressReleaseListing,
[RESOURCE_TYPES.BENEFITS_HUB]: BenefitsHub, // "Benefits Hub Landing Page"
[RESOURCE_TYPES.SUPPORT_SERVICES]: SupportServices,
[RESOURCE_TYPES.RESOURCES_SUPPORT]: ResourcesSupport,
[RESOURCE_TYPES.SUPPORT_SERVICES]: SupportServices,
[RESOURCE_TYPES.VET_CENTER]: VetCenter,
[RESOURCE_TYPES.HEALTH_SERVICES]: HealthServices,

// Paragraphs
[PARAGRAPH_RESOURCE_TYPES.ACCORDION_ITEM]: Accordion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ exports[`node--news_story formatData outputs formatted data 1`] = `
"width": 456,
},
"introText": "When a hospital has a host of great doctors, honoring just two every year is challenging. ",
"lastUpdated": "2019-05-14T15:35:12+00:00",
"lastUpdated": "2020-03-24T20:10:28+00:00",
"listing": "/pittsburgh-health-care/stories",
"metatags": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports[`Person profile returns formatted data outputs formatted data 1`] = `
"id": "fe42bc63-0933-40bb-978a-ef951fa75684",
"introText": null,
"lastName": "Doyle",
"lastUpdated": "2019-08-26T22:03:30+00:00",
"lastUpdated": "2019-08-27T17:49:03+00:00",
"media": {
"alt": "Patrick J. Doyle",
"height": 129,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`node--press_release formatData output formatted data 1`] = `
"fullText": "<p>We invite you to come and read our 2019 Annual Report. </p>",
"id": "6153ed5b-85c2-4ead-9893-3d656ad5d758",
"introText": "We invite you to come and read our 2019 Annual Report. ",
"lastUpdated": "2021-04-12T14:25:27+00:00",
"lastUpdated": "2021-04-12T14:27:39+00:00",
"listing": "/wilmington-health-care/news-releases",
"metatags": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ exports[`Resources Support formatData outputs formatted data 1`] = `
"id": "5b4943dc-764e-454c-a698-dd3f0bc0df32",
"intro": "<p>We offer some life insurance programs to service members and Veterans that are now closed to new enrollees. Learn more about these programs and what to do if you want to convert your policy.</p>
",
"lastUpdated": "2020-12-18T18:21:27+00:00",
"lastUpdated": "2020-12-22T17:31:57+00:00",
"mainContent": [
{
"html": "<h2>United States Government Life Insurance (USGLI)</h2>
Expand Down
3 changes: 2 additions & 1 deletion src/lib/drupal/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const entityBaseFields = (entity: NodeTypes): PublishedEntity => {
title: entity.title,
metatags: entity.metatag,
breadcrumbs: entity.breadcrumbs,
lastUpdated: entity.field_last_saved_by_an_editor || entity.created,
lastUpdated:
entity.field_last_saved_by_an_editor || entity.changed || entity.created,
}
}
52 changes: 28 additions & 24 deletions src/pages/[[...slug]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ import dynamic from 'next/dynamic'
import Script from 'next/script'
import { drupalClient } from '@/lib/drupal/drupalClient'
import { getGlobalElements } from '@/lib/drupal/getGlobalElements'
import { Wrapper } from '@/templates/layouts/wrapper'
import { NewsStory } from '@/templates/layouts/newsStory'
import { PressRelease } from '@/templates/layouts/pressRelease'
import { PressReleaseListing } from '@/templates/layouts/pressReleaseListing'
import { StoryListing } from '@/templates/layouts/storyListing'
import HTMLComment from '@/templates/common/util/HTMLComment'
import { shouldHideHomeBreadcrumb } from '@/lib/utils/breadcrumbs'
import { Event } from '@/templates/layouts/event'
import { EventListing } from '@/templates/layouts/eventListing'
import { getStaticPathsByResourceType } from '@/lib/drupal/staticPaths'
import {
RESOURCE_TYPES,
Expand All @@ -33,19 +25,31 @@ import {
} from '@/lib/drupal/staticProps'
import { StaticPropsResource } from '@/lib/drupal/staticProps'
import { FormattedPageResource } from '@/data/queries'
import { LayoutProps } from '@/templates/layouts/wrapper'

// Types
import { Event as FormattedEvent } from '@/types/formatted/event'
import { EventListing as FormattedEventListing } from '@/types/formatted/eventListing'
import { NewsStory as FormattedNewsStory } from '@/types/formatted/newsStory'
import { PressRelease as FormattedPressRelease } from '@/types/formatted/pressRelease'
import { PressReleaseListing as FormattedPressReleaseListing } from '@/types/formatted/pressReleaseListing'
import { ResourcesSupport as FormattedResourcesSupport } from '@/types/formatted/resourcesSupport'
import { StoryListing as FormattedStoryListing } from '@/types/formatted/storyListing'
import { EventListing as FormattedEventListing } from '@/types/formatted/eventListing'
import { Event as FormattedEvent } from '@/types/formatted/event'
import { VetCenter as FormattedVetCenter } from '@/types/formatted/vetCenter'

// Templates
import HTMLComment from '@/templates/common/util/HTMLComment'
import { Event } from '@/templates/layouts/event'
import { EventListing } from '@/templates/layouts/eventListing'
import { LayoutProps } from '@/templates/layouts/wrapper'
import { Meta } from '@/templates/common/meta'
import { NewsStory } from '@/templates/layouts/newsStory'
import { PressRelease } from '@/templates/layouts/pressRelease'
import { PressReleaseListing } from '@/templates/layouts/pressReleaseListing'
import { PreviewCrumb } from '@/templates/common/preview'
import { ResourcesSupport as FormattedResourcesSupport } from '@/types/formatted/resourcesSupport'
import { ResourcesSupport } from '@/templates/layouts/resourcesSupport'
import { VetCenter as FormattedVetCenter } from '@/types/formatted/vetCenter'
import { StoryListing } from '@/templates/layouts/storyListing'
import { VetCenter } from '@/templates/layouts/vetCenter'
import { Wrapper } from '@/templates/layouts/wrapper'

// IMPORTANT: in order for a content type to build in Next Build, it must have an appropriate
// environment variable set in one of two places:
Expand Down Expand Up @@ -119,32 +123,32 @@ export default function ResourcePage({

<main>
<div id="content" className="interior">
{resource.type === RESOURCE_TYPES.STORY_LISTING && (
<StoryListing {...(resource as FormattedStoryListing)} />
{resource.type === RESOURCE_TYPES.EVENT && (
<Event {...(resource as FormattedEvent)} />
)}
{resource.type === RESOURCE_TYPES.EVENT_LISTING && (
<EventListing {...(resource as FormattedEventListing)} />
)}
{resource.type === RESOURCE_TYPES.STORY && (
<NewsStory {...(resource as FormattedNewsStory)} />
)}
{resource.type === RESOURCE_TYPES.PRESS_RELEASE && (
<PressRelease {...(resource as FormattedPressRelease)} />
)}
{resource.type === RESOURCE_TYPES.PRESS_RELEASE_LISTING && (
<PressReleaseListing
{...(resource as FormattedPressReleaseListing)}
/>
)}
{resource.type === RESOURCE_TYPES.PRESS_RELEASE && (
<PressRelease {...(resource as FormattedPressRelease)} />
)}
{/* {resource.type === RESOURCE_TYPES.QA && (
<QuestionAnswer {...resource} />
)} */}
{resource.type === RESOURCE_TYPES.EVENT_LISTING && (
<EventListing {...(resource as FormattedEventListing)} />
)}
{resource.type === RESOURCE_TYPES.EVENT && (
<Event {...(resource as FormattedEvent)} />
)}
{resource.type === RESOURCE_TYPES.RESOURCES_SUPPORT && (
<ResourcesSupport {...(resource as FormattedResourcesSupport)} />
)}
{resource.type === RESOURCE_TYPES.STORY_LISTING && (
<StoryListing {...(resource as FormattedStoryListing)} />
)}
{resource.type === RESOURCE_TYPES.VET_CENTER && (
<VetCenter {...(resource as FormattedVetCenter)} />
)}
Expand Down
9 changes: 1 addition & 8 deletions src/templates/common/breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ const Breadcrumbs = ({

return (
<div className="vads-u-padding-x--1p5">
<va-breadcrumbs
id="va-breadcrumbs-list"
class="row hydrated"
uswds={true}
wrapping
breadcrumb-list={fcString}
disableAnalytics={disableAnalytics}
/>
<va-breadcrumbs class="row" wrapping breadcrumb-list={fcString} />
</div>
)
}
Expand Down
38 changes: 0 additions & 38 deletions src/templates/common/link/index.test.tsx

This file was deleted.

Loading

0 comments on commit 2c6b085

Please sign in to comment.