From 5781c7a6a9bbd3aa53008c700ddbedcbfacac413 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Tue, 4 Mar 2025 10:02:50 -0800 Subject: [PATCH 1/9] added phone numbers properly to query --- src/data/queries/pressRelease.ts | 11 ++++++++++- src/data/queries/tests/pressRelease.test.tsx | 2 +- src/types/formatted/contactInfo.ts | 12 +++++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/data/queries/pressRelease.ts b/src/data/queries/pressRelease.ts index 3e51e8b51..b98268cf5 100644 --- a/src/data/queries/pressRelease.ts +++ b/src/data/queries/pressRelease.ts @@ -19,6 +19,7 @@ export const params: QueryParams = () => { 'media--document', ]), 'field_press_release_contact', + 'field_press_release_contact.field_telephone', 'field_listing', 'field_administration', ...getNestedIncludes('field_pdf_version', 'media--document'), @@ -75,6 +76,7 @@ export const formatter: QueryFormatter = ( } }) : [] + // Setting phone numbers to an array even though there is only one in case multiple are added in the future. const formattedContacts = entity.field_press_release_contact ? entity.field_press_release_contact.map((contact) => { return { @@ -82,7 +84,14 @@ export const formatter: QueryFormatter = ( description: contact?.field_description || null, name: contact?.title || null, email: contact?.field_email_address || null, - phone: contact?.field_phone_number || null, + numbers: [contact?.field_telephone].map((number) => { + return { + id: number?.id || null, + type: number?.field_phone_number_type || null, + number: number?.field_phone_number || null, + ext: number?.field_phone_extension || null, + } + }), } }) : [] diff --git a/src/data/queries/tests/pressRelease.test.tsx b/src/data/queries/tests/pressRelease.test.tsx index 676829666..951b3f382 100644 --- a/src/data/queries/tests/pressRelease.test.tsx +++ b/src/data/queries/tests/pressRelease.test.tsx @@ -50,7 +50,7 @@ describe('DrupalJsonApiParams configuration for pressRelease', () => { const paramsInstance = params() const queryString = decodeURIComponent(paramsInstance.getQueryString()) expect(queryString).toMatch( - /include=field_press_release_downloads,field_press_release_downloads.image,field_press_release_downloads.field_document,field_press_release_contact,field_listing,field_administration,field_pdf_version,field_pdf_version.field_document/ + /include=field_press_release_downloads,field_press_release_downloads.image,field_press_release_downloads.field_document,field_press_release_contact,field_press_release_contact.field_telephone,field_listing,field_administration,field_pdf_version,field_pdf_version.field_document/ ) }) }) diff --git a/src/types/formatted/contactInfo.ts b/src/types/formatted/contactInfo.ts index aac860735..b541519d6 100644 --- a/src/types/formatted/contactInfo.ts +++ b/src/types/formatted/contactInfo.ts @@ -59,10 +59,20 @@ export type EmailContact = PublishedParagraph & { export type AdditionalContact = PhoneContact | EmailContact +// TODO: Is this being used? benefitHubContacts is typed as Contact[] not BenefitHubcontact[] +export type BenefitHubContact = { + services: Contact[] +} +export type Phone = { + id: string + type: string + number: string + ext: string +} export type PressContact = { id: string name: string description: string - phone: string + numbers: Phone[] email: string } From c63c25f89854f86d9523b89a70a46825d01f2ba1 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Tue, 4 Mar 2025 10:04:18 -0800 Subject: [PATCH 2/9] update press release to render phone number and types. --- .../layouts/pressRelease/index.test.tsx | 67 ++++++++++++++++++- src/templates/layouts/pressRelease/index.tsx | 19 +++++- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/templates/layouts/pressRelease/index.test.tsx b/src/templates/layouts/pressRelease/index.test.tsx index 738ecdb10..304975964 100644 --- a/src/templates/layouts/pressRelease/index.test.tsx +++ b/src/templates/layouts/pressRelease/index.test.tsx @@ -2,13 +2,39 @@ import { render, screen } from '@testing-library/react' import { PressRelease } from './index' import { getByText } from '@testing-library/react' import { fireEvent } from '@testing-library/react' +import { getByTestId } from '@testing-library/dom' const contacts = [ { id: '96668498-d442-4b55-8b14-7ec90410f418', name: 'Vance Janes', description: 'Public Affairs Officer', - phone: '828-298-7911, ext. 4446', + numbers: [ + { + id: 'a93d21bb-3ee0-4ffe-9996-91f7c6e6bdc3', + type: 'phone', + number: '617-435-7809', + ext: null, + }, + { + id: 'a93d21bb-3ee0-4ffe-9996-91f7c6e6bdc4', + type: 'sms', + number: '617-435-7810', + ext: null, + }, + { + id: 'a93d21bb-3ee0-4ffe-9996-91f7c6e6bdc5', + type: 'tty', + number: '617-435-7811', + ext: null, + }, + { + id: 'a93d21bb-3ee0-4ffe-9996-91f7c6e6bdc6', + type: 'phone', + number: '617-435-7812', + ext: '111', + }, + ], email: 'vance.janes@va.gov', }, ] @@ -109,13 +135,48 @@ describe(' with valid data', () => { expect( screen.getByText(`${contact.name}, ${contact.description}`) ).toBeInTheDocument() - expect(screen.getByText(contact.phone)).toBeInTheDocument() - const emailLink = screen.getByTestId('press-email') + const emailLink = screen.getByText(contact.email) expect(emailLink).toBeInTheDocument() expect(emailLink).toHaveAttribute('href', `mailto:${contact.email}`) + expect(screen.getByTestId('phone-0')).toBeInTheDocument() }) }) + test('renders contact phone', () => { + render() + const voice = screen.getByTestId('phone-0') + const sms = screen.getByTestId('phone-1') + const tty = screen.getByTestId('phone-2') + const ext = screen.getByTestId('phone-3') + expect(voice).toBeInTheDocument() + expect(voice).toHaveAttribute('contact', data.contacts[0].numbers[0].number) + expect(voice).not.toHaveAttribute('sms') + expect(voice).not.toHaveAttribute('tty') + expect(voice).not.toHaveAttribute('extension') + expect(sms).toBeInTheDocument() + expect(sms).toHaveAttribute('contact', data.contacts[0].numbers[1].number) + expect(sms).toHaveAttribute('sms') + expect(sms).not.toHaveAttribute('tty') + expect(sms).not.toHaveAttribute('extension') + expect(tty).toBeInTheDocument() + expect(tty).toHaveAttribute('contact', data.contacts[0].numbers[2].number) + expect(tty).not.toHaveAttribute('sms') + expect(tty).toHaveAttribute('tty') + expect(tty).not.toHaveAttribute('extension') + expect(ext).toBeInTheDocument() + expect(ext).toHaveAttribute('contact', data.contacts[0].numbers[3].number) + expect(ext).not.toHaveAttribute('sms') + expect(ext).not.toHaveAttribute('tty') + expect(ext).toHaveAttribute('extension', data.contacts[0].numbers[3].ext) + }) + + test('does not render numbers if null', () => { + const nullNumbers = { ...data } + nullNumbers.contacts[0].numbers = null + render() + expect(screen.queryByTestId('phone-0')).not.toBeInTheDocument() + }) + test('renders contacts when null', () => { data.contacts = [null] render() diff --git a/src/templates/layouts/pressRelease/index.tsx b/src/templates/layouts/pressRelease/index.tsx index b0e3822ac..0f6b2f3aa 100644 --- a/src/templates/layouts/pressRelease/index.tsx +++ b/src/templates/layouts/pressRelease/index.tsx @@ -77,9 +77,22 @@ export const PressRelease = ({

{`${contact?.name}${contact?.description ? `, ${contact?.description}` : ''}`}

-

- {contact?.phone} -

+ {contact?.numbers?.map((phone, index) => { + return ( +

+ +

+ ) + })} {contact?.email && (

Date: Tue, 4 Mar 2025 11:04:48 -0800 Subject: [PATCH 3/9] added label and Fax type. --- .../layouts/pressRelease/index.test.tsx | 22 +++++++++++++++++++ src/templates/layouts/pressRelease/index.tsx | 9 ++++++++ 2 files changed, 31 insertions(+) diff --git a/src/templates/layouts/pressRelease/index.test.tsx b/src/templates/layouts/pressRelease/index.test.tsx index 304975964..c68ae0ed2 100644 --- a/src/templates/layouts/pressRelease/index.test.tsx +++ b/src/templates/layouts/pressRelease/index.test.tsx @@ -34,6 +34,12 @@ const contacts = [ number: '617-435-7812', ext: '111', }, + { + id: 'a93d21bb-3ee0-4ffe-9996-91f7c6e6bdc6', + type: 'fax', + number: '617-435-7813', + ext: null, + }, ], email: 'vance.janes@va.gov', }, @@ -148,26 +154,42 @@ describe(' with valid data', () => { const sms = screen.getByTestId('phone-1') const tty = screen.getByTestId('phone-2') const ext = screen.getByTestId('phone-3') + const fax = screen.getByTestId('phone-4') expect(voice).toBeInTheDocument() expect(voice).toHaveAttribute('contact', data.contacts[0].numbers[0].number) expect(voice).not.toHaveAttribute('sms') expect(voice).not.toHaveAttribute('tty') expect(voice).not.toHaveAttribute('extension') + expect(voice).toHaveAttribute('message-aria-describedby', 'Phone') + expect(screen.getByTestId('phone-label-0')).toHaveTextContent('Phone:') expect(sms).toBeInTheDocument() expect(sms).toHaveAttribute('contact', data.contacts[0].numbers[1].number) expect(sms).toHaveAttribute('sms') expect(sms).not.toHaveAttribute('tty') expect(sms).not.toHaveAttribute('extension') + expect(sms).toHaveAttribute('message-aria-describedby', 'Phone') + expect(screen.getByTestId('phone-label-1')).toHaveTextContent('Phone:') expect(tty).toBeInTheDocument() expect(tty).toHaveAttribute('contact', data.contacts[0].numbers[2].number) expect(tty).not.toHaveAttribute('sms') expect(tty).toHaveAttribute('tty') expect(tty).not.toHaveAttribute('extension') + expect(tty).toHaveAttribute('message-aria-describedby', 'Phone') + expect(screen.getByTestId('phone-label-2')).toHaveTextContent('Phone:') expect(ext).toBeInTheDocument() expect(ext).toHaveAttribute('contact', data.contacts[0].numbers[3].number) expect(ext).not.toHaveAttribute('sms') expect(ext).not.toHaveAttribute('tty') expect(ext).toHaveAttribute('extension', data.contacts[0].numbers[3].ext) + expect(ext).toHaveAttribute('message-aria-describedby', 'Phone') + expect(screen.getByTestId('phone-label-3')).toHaveTextContent('Phone:') + expect(fax).toBeInTheDocument() + expect(fax).toHaveAttribute('contact', data.contacts[0].numbers[4].number) + expect(fax).not.toHaveAttribute('sms') + expect(fax).not.toHaveAttribute('tty') + expect(fax).not.toHaveAttribute('extension') + expect(fax).toHaveAttribute('message-aria-describedby', 'Fax') + expect(screen.getByTestId('phone-label-4')).toHaveTextContent('Fax:') }) test('does not render numbers if null', () => { diff --git a/src/templates/layouts/pressRelease/index.tsx b/src/templates/layouts/pressRelease/index.tsx index 0f6b2f3aa..ab802c027 100644 --- a/src/templates/layouts/pressRelease/index.tsx +++ b/src/templates/layouts/pressRelease/index.tsx @@ -78,17 +78,26 @@ export const PressRelease = ({ {`${contact?.name}${contact?.description ? `, ${contact?.description}` : ''}`}

{contact?.numbers?.map((phone, index) => { + const label = phone.type === 'fax' ? 'Fax' : 'Phone' return (

+ + {`${label}:`} +

) From 682ab7540f9a9d76241f38e404dc3b3bb39d5b24 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Wed, 5 Mar 2025 15:01:01 -0800 Subject: [PATCH 4/9] adjustments for test coverage and mock. --- src/data/queries/tests/pressRelease.test.tsx | 26 +++ src/mocks/pressRelease.mock.json | 178 ++++++++++++++++++- src/types/drupal/node.ts | 2 +- 3 files changed, 204 insertions(+), 2 deletions(-) diff --git a/src/data/queries/tests/pressRelease.test.tsx b/src/data/queries/tests/pressRelease.test.tsx index 951b3f382..a8dff23a2 100644 --- a/src/data/queries/tests/pressRelease.test.tsx +++ b/src/data/queries/tests/pressRelease.test.tsx @@ -43,6 +43,32 @@ describe(`${RESOURCE_TYPES.PRESS_RELEASE} formatData`, () => { expect(formattedData.administration.name).toBeNull() expect(formattedData.pdfVersion).toBeNull() }) + test('handles missing or null contact fields correctly', () => { + const modifiedMockContact = { + ...nodePressReleaseMock, + field_press_release_contact: [ + { + id: undefined, + description: undefined, + name: undefined, + email: undefined, + numbers: [ + { + id: undefined, + type: undefined, + number: undefined, + ext: undefined, + } + ] + } + ], + } + const formattedData = queries.formatData( + RESOURCE_TYPES.PRESS_RELEASE, + modifiedMockContact + ) + expect(formattedData.contacts.id).toBeUndefined() + }) }) describe('DrupalJsonApiParams configuration for pressRelease', () => { diff --git a/src/mocks/pressRelease.mock.json b/src/mocks/pressRelease.mock.json index dbb0df281..691fe52e0 100644 --- a/src/mocks/pressRelease.mock.json +++ b/src/mocks/pressRelease.mock.json @@ -368,7 +368,183 @@ } } }, - "field_press_release_contact": [], + "field_press_release_contact": [ + { + "type": "node--person_profile", + "id": "7ecb5154-7e2c-4c16-a171-bb3710a4dab7", + "drupal_internal__nid": 94, + "langcode": "en", + "status": true, + "title": "Sheila Tunney", + "created": "2019-02-26T05:47:15+00:00", + "changed": "2024-11-25T18:00:07+00:00", + "breadcrumbs": [ + { + "uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/", + "title": "Home", + "options": [] + }, + { + "uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/pittsburgh-health-care", + "title": "VA Pittsburgh Health Care", + "options": [] + }, + { + "uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/pittsburgh-health-care/staff-profiles/sheila-tunney", + "title": "Sheila Tunney", + "options": [] + } + ], + "moderation_state": "published", + "expiration_date": null, + "warning_date": null, + "metatag": [ + { + "tag": "meta", + "attributes": { + "name": "title", + "content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs" + } + }, + { + "tag": "link", + "attributes": { + "rel": "image_src", + "href": "https://www.va.gov/img/design/logo/va-og-image.png" + } + }, + { + "tag": "meta", + "attributes": { + "property": "og:site_name", + "content": "Veterans Affairs" + } + }, + { + "tag": "meta", + "attributes": { + "property": "og:title", + "content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs" + } + }, + { + "tag": "meta", + "attributes": { + "name": "twitter:card", + "content": "summary_large_image" + } + }, + { + "tag": "meta", + "attributes": { + "name": "twitter:site", + "content": "@DeptVetAffairs" + } + }, + { + "tag": "meta", + "attributes": { + "name": "twitter:title", + "content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs" + } + } + ], + "path": { + "alias": "/pittsburgh-health-care/staff-profiles/sheila-tunney", + "pid": 214, + "langcode": "en" + }, + "field_body": null, + "field_complete_biography_create": false, + "field_description": "Public Affairs Specialist", + "field_email_address": "sheila.tunney@va.gov", + "field_intro_text": null, + "field_last_name": "Tunney", + "field_last_saved_by_an_editor": "2024-05-02T13:03:19+00:00", + "field_meta_tags": null, + "field_name_first": "Sheila", + "field_photo_allow_hires_download": false, + "field_suffix": null, + "links": { + "self": { + "href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/node/person_profile/7ecb5154-7e2c-4c16-a171-bb3710a4dab7?resourceVersion=id%3A934975" + } + }, + "node_type": { + "type": "node_type--node_type", + "id": "89b07673-7fd5-4292-8fba-58cc10c4e3ec", + "resourceIdObjMeta": { + "drupal_internal__target_id": "person_profile" + } + }, + "field_administration": { + "type": "taxonomy_term--administration", + "id": "87832236-1e54-4ce3-8141-8dec27c8a9a7", + "resourceIdObjMeta": { + "drupal_internal__target_id": 12 + } + }, + "field_complete_biography": null, + "field_media": null, + "field_office": { + "type": "node--health_care_region_page", + "id": "2bddb1a7-6fb1-4503-838d-9c2fcb51c46a", + "resourceIdObjMeta": { + "drupal_internal__target_id": 318 + } + }, + "field_telephone": { + "type": "paragraph--phone_number", + "id": "a96f65e2-5a82-4b59-b249-25c634e93108", + "drupal_internal__id": 163647, + "drupal_internal__revision_id": 1561519, + "langcode": "en", + "status": true, + "created": "2024-11-25T18:00:06+00:00", + "parent_id": "94", + "parent_type": "node", + "parent_field_name": "field_telephone", + "behavior_settings": [], + "default_langcode": true, + "revision_translation_affected": null, + "breadcrumbs": [], + "content_translation_source": "und", + "content_translation_outdated": false, + "content_translation_changed": "2024-11-25T18:00:06+00:00", + "field_phone_extension": null, + "field_phone_label": null, + "field_phone_number": "412-360-1479", + "field_phone_number_type": "phone", + "links": { + "self": { + "href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519" + } + }, + "resourceIdObjMeta": { + "target_revision_id": 1561519, + "drupal_internal__target_id": 163647 + }, + "paragraph_type": { + "type": "paragraphs_type--paragraphs_type", + "id": "9c5d2698-f605-42f2-a516-15949b84d17f", + "resourceIdObjMeta": { + "drupal_internal__target_id": "phone_number" + } + }, + "relationshipNames": [ + "paragraph_type" + ] + }, + "relationshipNames": [ + "node_type", + "field_administration", + "field_complete_biography", + "field_media", + "field_office", + "field_telephone" + ] + } + ], "field_press_release_downloads": [], "field_administration": { "drupal_internal__tid": 188, diff --git a/src/types/drupal/node.ts b/src/types/drupal/node.ts index f43879245..32ea6025d 100644 --- a/src/types/drupal/node.ts +++ b/src/types/drupal/node.ts @@ -284,7 +284,7 @@ export interface NodePersonProfile extends DrupalNode { /** Last name. */ field_last_name: string /** Phone number. */ - field_phone_number: string + field_telephone: ParagraphPhoneNumber[] /** A photo of the person. */ field_media: DrupalMediaImage /** The office or facility which this person is associated with. */ From 4b1a0f08f9df2282135a224943c592b0921b6092 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Wed, 5 Mar 2025 15:06:05 -0800 Subject: [PATCH 5/9] undo node type change --- src/types/drupal/node.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/drupal/node.ts b/src/types/drupal/node.ts index 32ea6025d..f43879245 100644 --- a/src/types/drupal/node.ts +++ b/src/types/drupal/node.ts @@ -284,7 +284,7 @@ export interface NodePersonProfile extends DrupalNode { /** Last name. */ field_last_name: string /** Phone number. */ - field_telephone: ParagraphPhoneNumber[] + field_phone_number: string /** A photo of the person. */ field_media: DrupalMediaImage /** The office or facility which this person is associated with. */ From 4f1fa372c540d2472b690a505397ee7e7f32ac95 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Wed, 5 Mar 2025 15:08:49 -0800 Subject: [PATCH 6/9] remove merge artifact --- src/types/formatted/contactInfo.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/types/formatted/contactInfo.ts b/src/types/formatted/contactInfo.ts index b541519d6..a48868891 100644 --- a/src/types/formatted/contactInfo.ts +++ b/src/types/formatted/contactInfo.ts @@ -59,10 +59,6 @@ export type EmailContact = PublishedParagraph & { export type AdditionalContact = PhoneContact | EmailContact -// TODO: Is this being used? benefitHubContacts is typed as Contact[] not BenefitHubcontact[] -export type BenefitHubContact = { - services: Contact[] -} export type Phone = { id: string type: string From 4e5dc22e662f6049e217b63c490af81ced1357e2 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Thu, 6 Mar 2025 09:40:38 -0800 Subject: [PATCH 7/9] more phone field updates and test coverage for press release. --- .../__snapshots__/newsStory.test.tsx.snap | 43 ++++++++++++++++++- .../__snapshots__/pressRelease.test.tsx.snap | 17 +++++++- src/data/queries/tests/pressRelease.test.tsx | 34 +++++++++------ src/mocks/newsStory.mock.json | 41 +++++++++++++++++- src/mocks/pressRelease.mock.json | 25 +++-------- src/mocks/staffProfile.mock.js | 41 +++++++++++++++++- .../layouts/pressRelease/index.test.tsx | 2 +- .../layouts/staffProfile/dataService.test.tsx | 2 - .../layouts/staffProfile/dataService.tsx | 1 - src/types/drupal/node.ts | 2 +- 10 files changed, 167 insertions(+), 41 deletions(-) diff --git a/src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap b/src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap index 211221862..d58c282c1 100644 --- a/src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap +++ b/src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap @@ -31,9 +31,50 @@ exports[`node--news_story formatData outputs formatted data 1`] = ` "field_meta_tags": null, "field_name_first": "Keith", "field_office": null, - "field_phone_number": null, "field_photo_allow_hires_download": false, "field_suffix": null, + "field_telephone": { + "behavior_settings": [], + "breadcrumbs": [], + "content_translation_changed": "2024-11-25T18:00:06+00:00", + "content_translation_outdated": false, + "content_translation_source": "und", + "created": "2024-11-25T18:00:06+00:00", + "default_langcode": true, + "drupal_internal__id": 163647, + "drupal_internal__revision_id": 1561519, + "field_phone_extension": null, + "field_phone_label": null, + "field_phone_number": "412-360-1479", + "field_phone_number_type": "phone", + "id": "a96f65e2-5a82-4b59-b249-25c634e93108", + "langcode": "en", + "links": { + "self": { + "href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519", + }, + }, + "paragraph_type": { + "id": "9c5d2698-f605-42f2-a516-15949b84d17f", + "resourceIdObjMeta": { + "drupal_internal__target_id": "phone_number", + }, + "type": "paragraphs_type--paragraphs_type", + }, + "parent_field_name": "field_telephone", + "parent_id": "94", + "parent_type": "node", + "relationshipNames": [ + "paragraph_type", + ], + "resourceIdObjMeta": { + "drupal_internal__target_id": 163647, + "target_revision_id": 1561519, + }, + "revision_translation_affected": null, + "status": true, + "type": "paragraph--phone_number", + }, "id": "c76037be-ebb0-4338-9b31-973a76958929", "langcode": "en", "links": { diff --git a/src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap b/src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap index 54ae6aa44..8b8b2d92d 100644 --- a/src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap +++ b/src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap @@ -34,7 +34,22 @@ exports[`node--press_release formatData output formatted data 1`] = ` "uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/wilmington-health-care/news-releases/wilmington-vamc-2019-annual-report", }, ], - "contacts": [], + "contacts": [ + { + "description": "Public Affairs Specialist", + "email": "sheila.tunney@va.gov", + "id": "7ecb5154-7e2c-4c16-a171-bb3710a4dab7", + "name": "Sheila Tunney", + "numbers": [ + { + "ext": null, + "id": "a96f65e2-5a82-4b59-b249-25c634e93108", + "number": "412-360-1479", + "type": "phone", + }, + ], + }, + ], "downloads": [], "entityId": 18141, "entityPath": "/wilmington-health-care/news-releases/wilmington-vamc-2019-annual-report", diff --git a/src/data/queries/tests/pressRelease.test.tsx b/src/data/queries/tests/pressRelease.test.tsx index a8dff23a2..aef13e8a7 100644 --- a/src/data/queries/tests/pressRelease.test.tsx +++ b/src/data/queries/tests/pressRelease.test.tsx @@ -48,26 +48,34 @@ describe(`${RESOURCE_TYPES.PRESS_RELEASE} formatData`, () => { ...nodePressReleaseMock, field_press_release_contact: [ { + ...nodePressReleaseMock.field_press_release_contact[0], id: undefined, - description: undefined, - name: undefined, - email: undefined, - numbers: [ - { - id: undefined, - type: undefined, - number: undefined, - ext: undefined, - } - ] - } + field_description: undefined, + title: undefined, + field_email_address: undefined, + field_telephone: { + ...nodePressReleaseMock.field_press_release_contact[0] + .field_telephone, + id: undefined, + field_phone_number_type: undefined, + field_phone_number: undefined, + field_phone_extension: undefined, + }, + }, ], } const formattedData = queries.formatData( RESOURCE_TYPES.PRESS_RELEASE, modifiedMockContact ) - expect(formattedData.contacts.id).toBeUndefined() + expect(formattedData.contacts[0].id).toBeNull() + expect(formattedData.contacts[0].description).toBeNull() + expect(formattedData.contacts[0].name).toBeNull() + expect(formattedData.contacts[0].email).toBeNull() + expect(formattedData.contacts[0].numbers[0].id).toBeNull() + expect(formattedData.contacts[0].numbers[0].type).toBeNull() + expect(formattedData.contacts[0].numbers[0].number).toBeNull() + expect(formattedData.contacts[0].numbers[0].ext).toBeNull() }) }) diff --git a/src/mocks/newsStory.mock.json b/src/mocks/newsStory.mock.json index fd7fd0910..d04130df4 100644 --- a/src/mocks/newsStory.mock.json +++ b/src/mocks/newsStory.mock.json @@ -195,7 +195,46 @@ "field_last_saved_by_editor": "2019-11-12T20:21:16+00:00", "field_meta_tags": null, "field_name_first": "Keith", - "field_phone_number": null, + "field_telephone": { + "type": "paragraph--phone_number", + "id": "a96f65e2-5a82-4b59-b249-25c634e93108", + "drupal_internal__id": 163647, + "drupal_internal__revision_id": 1561519, + "langcode": "en", + "status": true, + "created": "2024-11-25T18:00:06+00:00", + "parent_id": "94", + "parent_type": "node", + "parent_field_name": "field_telephone", + "behavior_settings": [], + "default_langcode": true, + "revision_translation_affected": null, + "breadcrumbs": [], + "content_translation_source": "und", + "content_translation_outdated": false, + "content_translation_changed": "2024-11-25T18:00:06+00:00", + "field_phone_extension": null, + "field_phone_label": null, + "field_phone_number": "412-360-1479", + "field_phone_number_type": "phone", + "links": { + "self": { + "href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519" + } + }, + "resourceIdObjMeta": { + "target_revision_id": 1561519, + "drupal_internal__target_id": 163647 + }, + "paragraph_type": { + "type": "paragraphs_type--paragraphs_type", + "id": "9c5d2698-f605-42f2-a516-15949b84d17f", + "resourceIdObjMeta": { + "drupal_internal__target_id": "phone_number" + } + }, + "relationshipNames": ["paragraph_type"] + }, "field_photo_allow_hires_download": false, "field_suffix": null, "links": { diff --git a/src/mocks/pressRelease.mock.json b/src/mocks/pressRelease.mock.json index 691fe52e0..86b2c680a 100644 --- a/src/mocks/pressRelease.mock.json +++ b/src/mocks/pressRelease.mock.json @@ -373,6 +373,9 @@ "type": "node--person_profile", "id": "7ecb5154-7e2c-4c16-a171-bb3710a4dab7", "drupal_internal__nid": 94, + "drupal_internal__vid": 988884, + "sticky": false, + "default_langcode": true, "langcode": "en", "status": true, "title": "Sheila Tunney", @@ -486,13 +489,7 @@ }, "field_complete_biography": null, "field_media": null, - "field_office": { - "type": "node--health_care_region_page", - "id": "2bddb1a7-6fb1-4503-838d-9c2fcb51c46a", - "resourceIdObjMeta": { - "drupal_internal__target_id": 318 - } - }, + "field_office": null, "field_telephone": { "type": "paragraph--phone_number", "id": "a96f65e2-5a82-4b59-b249-25c634e93108", @@ -531,18 +528,8 @@ "drupal_internal__target_id": "phone_number" } }, - "relationshipNames": [ - "paragraph_type" - ] - }, - "relationshipNames": [ - "node_type", - "field_administration", - "field_complete_biography", - "field_media", - "field_office", - "field_telephone" - ] + "relationshipNames": ["paragraph_type"] + } } ], "field_press_release_downloads": [], diff --git a/src/mocks/staffProfile.mock.js b/src/mocks/staffProfile.mock.js index ac31e7743..6f7e579d7 100644 --- a/src/mocks/staffProfile.mock.js +++ b/src/mocks/staffProfile.mock.js @@ -48,7 +48,46 @@ export const mockResponse = { field_last_name: 'Smathers', field_meta_tags: null, field_name_first: 'William', - field_phone_number: '412-551-9651', + field_telephone: { + type: 'paragraph--phone_number', + id: 'a96f65e2-5a82-4b59-b249-25c634e93108', + drupal_internal__id: 163647, + drupal_internal__revision_id: 1561519, + langcode: 'en', + status: true, + created: '2024-11-25T18:00:06+00:00', + parent_id: '94', + parent_type: 'node', + parent_field_name: 'field_telephone', + behavior_settings: [], + default_langcode: true, + revision_translation_affected: null, + breadcrumbs: [], + content_translation_source: 'und', + content_translation_outdated: false, + content_translation_changed: '2024-11-25T18:00:06+00:00', + field_phone_extension: null, + field_phone_label: null, + field_phone_number: '412-360-1479', + field_phone_number_type: 'phone', + links: { + self: { + href: 'https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519', + }, + }, + resourceIdObjMeta: { + target_revision_id: 1561519, + drupal_internal__target_id: 163647, + }, + paragraph_type: { + type: 'paragraphs_type--paragraphs_type', + id: '9c5d2698-f605-42f2-a516-15949b84d17f', + resourceIdObjMeta: { + drupal_internal__target_id: 'phone_number', + }, + }, + relationshipNames: ['paragraph_type'], + }, field_photo_allow_hires_download: false, field_suffix: 'Mr', field_body: null, diff --git a/src/templates/layouts/pressRelease/index.test.tsx b/src/templates/layouts/pressRelease/index.test.tsx index c68ae0ed2..6ea78f2c6 100644 --- a/src/templates/layouts/pressRelease/index.test.tsx +++ b/src/templates/layouts/pressRelease/index.test.tsx @@ -141,7 +141,7 @@ describe(' with valid data', () => { expect( screen.getByText(`${contact.name}, ${contact.description}`) ).toBeInTheDocument() - const emailLink = screen.getByText(contact.email) + const emailLink = screen.getByTestId('press-email') expect(emailLink).toBeInTheDocument() expect(emailLink).toHaveAttribute('href', `mailto:${contact.email}`) expect(screen.getByTestId('phone-0')).toBeInTheDocument() diff --git a/src/templates/layouts/staffProfile/dataService.test.tsx b/src/templates/layouts/staffProfile/dataService.test.tsx index 029190921..7a8f647f5 100644 --- a/src/templates/layouts/staffProfile/dataService.test.tsx +++ b/src/templates/layouts/staffProfile/dataService.test.tsx @@ -17,7 +17,6 @@ describe('transformStaffProfileData', () => { linkToBio: true, path: 'http:va.gov', description: 'OEF Transition Patient Advocate', - phone: '412-551-9651', email: 'william.smathers@aol.com', } @@ -36,7 +35,6 @@ describe('transformStaffProfileData', () => { linkToBio: true, path: null, description: 'OEF Transition Patient Advocate', - phone: '412-551-9651', email: 'william.smathers@aol.com', } diff --git a/src/templates/layouts/staffProfile/dataService.tsx b/src/templates/layouts/staffProfile/dataService.tsx index b5f8dff4d..940da8cbd 100644 --- a/src/templates/layouts/staffProfile/dataService.tsx +++ b/src/templates/layouts/staffProfile/dataService.tsx @@ -31,7 +31,6 @@ export const transformStaffProfileData = function ( linkToBio: entity.field_staff_profile.field_complete_biography_create, path: entity.field_staff_profile.field_entity?.entityUrl.path || null, description: entity.field_staff_profile.field_description, - phone: entity.field_staff_profile.field_phone_number, email: entity.field_staff_profile.field_email_address, } } diff --git a/src/types/drupal/node.ts b/src/types/drupal/node.ts index f43879245..6c15c2789 100644 --- a/src/types/drupal/node.ts +++ b/src/types/drupal/node.ts @@ -284,7 +284,7 @@ export interface NodePersonProfile extends DrupalNode { /** Last name. */ field_last_name: string /** Phone number. */ - field_phone_number: string + field_telephone: ParagraphPhoneNumber /** A photo of the person. */ field_media: DrupalMediaImage /** The office or facility which this person is associated with. */ From 5b3afcd9692ce4fce46b7dd1a8ec82a2b65ec6a5 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Fri, 7 Mar 2025 08:15:51 -0800 Subject: [PATCH 8/9] Update src/data/queries/tests/pressRelease.test.tsx Co-authored-by: Chris Valarida --- src/data/queries/tests/pressRelease.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/queries/tests/pressRelease.test.tsx b/src/data/queries/tests/pressRelease.test.tsx index aef13e8a7..abd00f262 100644 --- a/src/data/queries/tests/pressRelease.test.tsx +++ b/src/data/queries/tests/pressRelease.test.tsx @@ -44,7 +44,7 @@ describe(`${RESOURCE_TYPES.PRESS_RELEASE} formatData`, () => { expect(formattedData.pdfVersion).toBeNull() }) test('handles missing or null contact fields correctly', () => { - const modifiedMockContact = { + const modifiedMockContact: NodePressRelease = { ...nodePressReleaseMock, field_press_release_contact: [ { From 7f903f0f1eb053e55c002b805b8835284a062cf2 Mon Sep 17 00:00:00 2001 From: Brian Seek Date: Fri, 7 Mar 2025 08:19:42 -0800 Subject: [PATCH 9/9] Update src/types/formatted/contactInfo.ts Co-authored-by: Chris Valarida --- src/types/formatted/contactInfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/formatted/contactInfo.ts b/src/types/formatted/contactInfo.ts index a48868891..a392f516b 100644 --- a/src/types/formatted/contactInfo.ts +++ b/src/types/formatted/contactInfo.ts @@ -61,7 +61,7 @@ export type AdditionalContact = PhoneContact | EmailContact export type Phone = { id: string - type: string + type: 'phone' | 'tty' | 'sms' | 'fax' number: string ext: string }