Skip to content

Commit

Permalink
more phone field updates and test coverage for press release.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianseek committed Mar 6, 2025
1 parent 4f1fa37 commit 4e5dc22
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 41 deletions.
43 changes: 42 additions & 1 deletion src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 16 additions & 1 deletion src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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",
Expand Down
34 changes: 21 additions & 13 deletions src/data/queries/tests/pressRelease.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})

Expand Down
41 changes: 40 additions & 1 deletion src/mocks/newsStory.mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
25 changes: 6 additions & 19 deletions src/mocks/pressRelease.mock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": [],
Expand Down
41 changes: 40 additions & 1 deletion src/mocks/staffProfile.mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/templates/layouts/pressRelease/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe('<pressRelease> 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()
Expand Down
2 changes: 0 additions & 2 deletions src/templates/layouts/staffProfile/dataService.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('transformStaffProfileData', () => {
linkToBio: true,
path: 'http:va.gov',
description: 'OEF Transition Patient Advocate',
phone: '412-551-9651',
email: '[email protected]',
}

Expand All @@ -36,7 +35,6 @@ describe('transformStaffProfileData', () => {
linkToBio: true,
path: null,
description: 'OEF Transition Patient Advocate',
phone: '412-551-9651',
email: '[email protected]',
}

Expand Down
1 change: 0 additions & 1 deletion src/templates/layouts/staffProfile/dataService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/drupal/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 4e5dc22

Please sign in to comment.