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

19386 checklist template #810

Draft
wants to merge 60 commits into
base: Sitewide-integration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b560102
Update Design System dependencies to latest (#812)
randimays Nov 14, 2024
9c897e6
VACMS-19386 Add SecondaryButtonGroup and RelatedLinks common componen…
randimays Nov 21, 2024
f0e34ee
VACMS-19386 Cleanup in support of checklist template (#815)
randimays Nov 21, 2024
7ad14c6
VACMS-19386 Update contact info component (#821)
randimays Nov 25, 2024
227eb06
VACMS-19386 Checklist template migration
randimays Oct 4, 2024
4819198
Adding more types and finishing query for checklist
randimays Oct 7, 2024
99de1a6
Adding imports to get the page to load
randimays Oct 8, 2024
d7fa5b0
Removed unused Link custom component; added secondaryButtonGroup for …
randimays Oct 8, 2024
54606dd
Add optional intro
randimays Oct 9, 2024
75cdadc
Trying to get the nested checklist paragraph to work
randimays Oct 10, 2024
6470ba1
Got checklist data fetching properly
randimays Oct 10, 2024
ce86322
Adding more content for checklist page
randimays Oct 10, 2024
cdf3fae
Adding some Medallia code
randimays Oct 14, 2024
0da2da8
Updating design system, fixing tags issues, still working on web comp…
randimays Oct 15, 2024
0de6967
Adding related information shared component
randimays Oct 15, 2024
bf9b520
Added benefit hubs links
randimays Oct 15, 2024
f34614c
Tweaks to tags for styling. Add next-template data to all things in t…
randimays Oct 16, 2024
b7b8604
A few more updates for data- attributes
randimays Oct 16, 2024
7de55c7
Updating responsive behavior in the contentFooter
randimays Oct 16, 2024
118b454
Adding mock and tests for data query
randimays Oct 16, 2024
e4fe3b9
One more data query test update
randimays Oct 16, 2024
dcef5ba
Adding tests for checklist item and updating plop test template
randimays Oct 16, 2024
bd66f33
Checklist item test adjustment
randimays Oct 16, 2024
a8b83d8
Remove unneeded files
randimays Oct 16, 2024
904c215
Adding and updating unit tests
randimays Oct 17, 2024
732c1a4
Update unit tests
randimays Oct 17, 2024
0a59ffd
More unit test tweaks
randimays Oct 17, 2024
feea986
Adding/updating more unit tests
randimays Oct 17, 2024
3d0acc9
Removing storybook files
randimays Oct 17, 2024
d28c7e5
Fixing type errors
randimays Oct 18, 2024
200d06c
Fixing more type errors
randimays Oct 18, 2024
252457b
Adding playwright test
randimays Oct 18, 2024
1e79388
Adding back props that were removed in NodeAbstractResource
randimays Oct 18, 2024
99927a8
Revert Taxonomy Term to former structure (empty)
randimays Oct 18, 2024
8a43d0d
Trying to revert dependency updates
randimays Oct 18, 2024
78be2fd
Fixing some typescript issues
randimays Oct 22, 2024
5d8a15c
More types fixes
randimays Oct 24, 2024
7fc4213
Updating types
randimays Oct 25, 2024
d5bf913
Fixing types for contact info
randimays Oct 25, 2024
282d44a
Refactor related information component to be shared
randimays Oct 25, 2024
710c500
Consolidated shared related links component, fix more types
randimays Oct 28, 2024
53302ef
Consolidated shared related links component, fix more types
randimays Oct 28, 2024
6f2af66
Fixing more types in the tests
randimays Oct 28, 2024
3b72a48
Fixed all the types
randimays Oct 29, 2024
cf79c64
Fixing some tests and errors
randimays Oct 29, 2024
3faaeac
Reverting API playground
randimays Oct 29, 2024
50d8228
Updating design library dependencies
randimays Oct 29, 2024
928efff
Fixing some tests
randimays Oct 29, 2024
fb94a8c
Prettier formatting
randimays Oct 29, 2024
5007b3f
Updating snapshots
randimays Oct 29, 2024
590ddd2
Fixing test
randimays Oct 29, 2024
8972f97
Remove next component data attributes
randimays Oct 31, 2024
bbc0915
Upgrading design system dependencies again
randimays Nov 13, 2024
ea2e754
Attempting to fix dependencies and web component issues
randimays Nov 14, 2024
42a262e
Revert unnecessary updates for data-templates etc
randimays Nov 14, 2024
43424be
Updating DS dependencies
randimays Nov 15, 2024
3105db8
Trying to fix yarn cache
randimays Nov 15, 2024
621f9f1
Updating dependencies
randimays Nov 21, 2024
72b188f
Updating snapshots
randimays Nov 21, 2024
aa50db8
Reverting contact info back to the original
randimays Nov 25, 2024
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
925 changes: 925 additions & 0 deletions .yarn/releases/yarn-4.5.0.cjs

Large diffs are not rendered by default.

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
17 changes: 11 additions & 6 deletions additional.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,25 @@ declare module '@department-of-veterans-affairs/component-library/Modal'
declare module '@department-of-veterans-affairs/component-library/Pagination'
declare module '@department-of-veterans-affairs/component-library/ProgressButton'
declare module '@department-of-veterans-affairs/component-library/PromoBanner'
declare module '@department-of-veterans-affairs/component-library/VaRadio'
declare module '@department-of-veterans-affairs/component-library/VaRadioOption'
declare module '@department-of-veterans-affairs/component-library/dist/react-bindings'
declare module 'mq-polyfill'
declare module 'debug'

declare namespace JSX {
interface IntrinsicElements {
'va-alert'
'va-link'
'va-icon'
'va-button'
'va-breadcrumbs'
'va-accordion'
'va-accordion-item'
'va-on-this-page'
'va-alert'
'va-back-to-top'
'va-breadcrumbs'
'va-button'
'va-checkbox'
'va-icon'
'va-link'
'va-link-action'
'va-on-this-page'
'va-telephone'
}
}
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
})
})
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@department-of-veterans-affairs/component-library": "^45.0.0",
"@department-of-veterans-affairs/formation": "^11.0.12",
"@department-of-veterans-affairs/web-components": "^11.2.9",
"@department-of-veterans-affairs/component-library": "^48.0.1",
"@department-of-veterans-affairs/formation": "^12.0.0",
"@department-of-veterans-affairs/web-components": "^16.0.1",
"@fortawesome/fontawesome-free": "^5.15.4",
"@octokit/rest": "^21.0.1",
"@storybook/react": "^8.0.5",
Expand Down
25 changes: 25 additions & 0 deletions playwright/tests/checklist.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { test, expect } from '../utils/next-test'

test.describe('Checklist', () => {
test('Checklist page renders', async ({ page }) => {
await page.goto(
'/resources/what-to-bring-to-create-your-online-sign-in-account'
)
await expect(page).toHaveURL(
'/resources/what-to-bring-to-create-your-online-sign-in-account'
)
})

test('Should render without a11y errors', async ({
page,
makeAxeBuilder,
}) => {
await page.goto(
'/resources/what-to-bring-to-create-your-online-sign-in-account'
)

const accessibilityScanResults = await makeAxeBuilder().analyze()

expect(accessibilityScanResults.violations).toEqual([])
})
})
25 changes: 19 additions & 6 deletions src/data/queries/audienceTopics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Define the query params for fetching node--news_story.
import { ParagraphAudienceTopics } from '@/types/drupal/paragraph'
import { QueryFormatter, QueryParams } from 'next-drupal-query'
import { AudienceTopic, AudienceTopics } from '@/types/formatted/audienceTopics'
Expand All @@ -12,6 +11,18 @@ export const params: QueryParams<null> = () => {
])
}

const formatBeneficiariesData = (beneficiaries) => {
if (!beneficiaries || beneficiaries.length === 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was missing logic to handle a single object of beneficiaries rather than an array, so I added a formatter function instead.

return []
}

if (!Array.isArray(beneficiaries)) {
return [beneficiaries]
}

return beneficiaries
}

export const getTagsList = (
entity: ParagraphAudienceTopics
): AudienceTopic[] | null => {
Expand All @@ -23,17 +34,19 @@ export const getTagsList = (
field_non_beneficiares: fieldNonBeneficiares,
} = entity

const audienceBeneficiaries = formatBeneficiariesData(
fieldAudienceBeneficiares
)
const nonBeneficiaries = formatBeneficiariesData(fieldNonBeneficiares)

const topics = fieldTopics.map((topic) => ({
id: topic.id,
href: topic.path?.alias,
name: topic.name,
categoryLabel: 'Topics',
}))

const audiences = [
...(fieldAudienceBeneficiares || []),
...(fieldNonBeneficiares || []),
]
const audiences = [...audienceBeneficiaries, ...nonBeneficiaries]
.filter((tag) => !!tag)
.map((audience) => ({
id: audience.id,
Expand All @@ -44,7 +57,7 @@ export const getTagsList = (

const tagList = [...topics, ...audiences]

return tagList.sort((a, b) => a.categoryLabel.localeCompare(b.categoryLabel))
return tagList.sort((a, b) => a.name.localeCompare(b.name))
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/data/queries/benefitsHubLinks.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { QueryFormatter, QueryParams } from 'next-drupal-query'
import { NodeLandingPage } from '@/types/drupal/node'
import { BenefitsHubLink } from '@/types/formatted/benefitsHub'
import { RelatedLink } from '@/types/formatted/relatedLinks'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'

// Define the query params for fetching node--landing_page.
export const params: QueryParams<null> = () => {
return new DrupalJsonApiParams().addInclude(['field_support_services'])
}

// Format NodeLandingPage (Benefits Hub) into link teasers.
export const formatter: QueryFormatter<NodeLandingPage[], BenefitsHubLink[]> = (
export const formatter: QueryFormatter<NodeLandingPage[], RelatedLink[]> = (
entities: NodeLandingPage[]
) => {
return entities.map((entity) => {
return {
id: entity.id,
path: entity.path?.alias,
title: entity.title,
label: entity.field_home_page_hub_label,
teaserText: entity.field_teaser_text,
uri: entity.path?.alias,
title: entity.field_home_page_hub_label,
summary: entity.field_teaser_text,
}
})
}
92 changes: 92 additions & 0 deletions src/data/queries/checklist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { QueryData, QueryFormatter, QueryParams } from 'next-drupal-query'
import { DrupalJsonApiParams } from 'drupal-jsonapi-params'
import { queries } from '.'
import { formatParagraph } from '@/lib/drupal/paragraphs'
import {
PARAGRAPH_RESOURCE_TYPES,
RESOURCE_TYPES,
} from '@/lib/constants/resourceTypes'
import { ExpandedStaticPropsContext } from '@/lib/drupal/staticProps'
import {
entityBaseFields,
fetchSingleEntityOrPreview,
} from '@/lib/drupal/query'
import { getNestedIncludes } from '@/lib/utils/queries'

// Types
import { AlertSingle } from '@/types/formatted/alert'
import { AudienceTopics } from '@/types/formatted/audienceTopics'
import { Button } from '@/types/formatted/button'
import { Checklist, ChecklistItem } from '@/types/formatted/checklist'
import { ContactInfo } from '@/types/formatted/contactInfo'
import { NodeChecklist } from '@/types/drupal/node'
import { RelatedLink } from '@/types/formatted/relatedLinks'

export const params: QueryParams<null> = () => {
return new DrupalJsonApiParams().addInclude([
...getNestedIncludes(
'field_alert_single',
PARAGRAPH_RESOURCE_TYPES.ALERT_SINGLE
),
'field_buttons',
'field_checklist.field_checklist_sections',
...getNestedIncludes(
'field_contact_information',
PARAGRAPH_RESOURCE_TYPES.CONTACT_INFORMATION
),
'field_related_benefit_hubs',
'field_related_information',
...getNestedIncludes(
'field_tags',
PARAGRAPH_RESOURCE_TYPES.AUDIENCE_TOPICS
),
])
}

export type ChecklistDataOpts = {
id: string
context?: ExpandedStaticPropsContext
}

export const data: QueryData<ChecklistDataOpts, NodeChecklist> = async (
opts
): Promise<NodeChecklist> => {
const entity = (await fetchSingleEntityOrPreview(
opts,
RESOURCE_TYPES.CHECKLIST,
params
)) as NodeChecklist

return entity
}

export const formatter: QueryFormatter<NodeChecklist, Checklist> = (
entity: NodeChecklist
) => {
const formatRelatedLinks = (links): RelatedLink[] =>
links?.map((link) => ({
uri: link?.field_link?.uri,
title: link?.field_link?.title,
summary: link.field_link_summary,
}))

return {
...entityBaseFields(entity),
alert: formatParagraph(entity.field_alert_single) as AlertSingle,
benefitsHubLinks: queries.formatData(
RESOURCE_TYPES.BENEFITS_HUB,
entity.field_related_benefit_hubs
),
buttons: entity.field_buttons.map?.(formatParagraph) as Button[],
checklist: entity.field_checklist.field_checklist_sections?.map((section) =>
queries.formatData(PARAGRAPH_RESOURCE_TYPES.CHECKLIST, section)
) as ChecklistItem[],
contactInformation: formatParagraph(
entity.field_contact_information
) as ContactInfo,
intro: entity.field_intro_text_limited_html.processed,
relatedInformation: formatRelatedLinks(entity.field_related_information),
repeatButtons: entity.field_buttons_repeat,
tags: formatParagraph(entity.field_tags) as AudienceTopics,
}
}
16 changes: 16 additions & 0 deletions src/data/queries/checklistItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { QueryFormatter } from 'next-drupal-query'
import { ParagraphChecklistItem } from '@/types/drupal/paragraph'
import { ChecklistItem } from '@/types/formatted/checklist'

export const formatter: QueryFormatter<
ParagraphChecklistItem,
ChecklistItem
> = (entity: ParagraphChecklistItem) => {
return {
type: entity.type as ChecklistItem['type'],
id: entity.id,
items: entity.field_checklist_items,
header: entity.field_section_header,
intro: entity.field_section_intro,
}
}
Loading
Loading