Skip to content

Commit ba45cd3

Browse files
brianseekcvalarida
andauthored
VAMS-20163 news release contact number (#919)
Co-authored-by: Chris Valarida <[email protected]>
1 parent ecb04ba commit ba45cd3

13 files changed

+468
-17
lines changed

src/data/queries/pressRelease.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const params: QueryParams<null> = () => {
1919
'media--document',
2020
]),
2121
'field_press_release_contact',
22+
'field_press_release_contact.field_telephone',
2223
'field_listing',
2324
'field_administration',
2425
...getNestedIncludes('field_pdf_version', 'media--document'),
@@ -75,14 +76,22 @@ export const formatter: QueryFormatter<NodePressRelease, PressRelease> = (
7576
}
7677
})
7778
: []
79+
// Setting phone numbers to an array even though there is only one in case multiple are added in the future.
7880
const formattedContacts = entity.field_press_release_contact
7981
? entity.field_press_release_contact.map((contact) => {
8082
return {
8183
id: contact?.id || null,
8284
description: contact?.field_description || null,
8385
name: contact?.title || null,
8486
email: contact?.field_email_address || null,
85-
phone: contact?.field_phone_number || null,
87+
numbers: [contact?.field_telephone].map((number) => {
88+
return {
89+
id: number?.id || null,
90+
type: number?.field_phone_number_type || null,
91+
number: number?.field_phone_number || null,
92+
ext: number?.field_phone_extension || null,
93+
}
94+
}),
8695
}
8796
})
8897
: []

src/data/queries/tests/__snapshots__/newsStory.test.tsx.snap

+42-1
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,50 @@ exports[`node--news_story formatData outputs formatted data 1`] = `
3131
"field_meta_tags": null,
3232
"field_name_first": "Keith",
3333
"field_office": null,
34-
"field_phone_number": null,
3534
"field_photo_allow_hires_download": false,
3635
"field_suffix": null,
36+
"field_telephone": {
37+
"behavior_settings": [],
38+
"breadcrumbs": [],
39+
"content_translation_changed": "2024-11-25T18:00:06+00:00",
40+
"content_translation_outdated": false,
41+
"content_translation_source": "und",
42+
"created": "2024-11-25T18:00:06+00:00",
43+
"default_langcode": true,
44+
"drupal_internal__id": 163647,
45+
"drupal_internal__revision_id": 1561519,
46+
"field_phone_extension": null,
47+
"field_phone_label": null,
48+
"field_phone_number": "412-360-1479",
49+
"field_phone_number_type": "phone",
50+
"id": "a96f65e2-5a82-4b59-b249-25c634e93108",
51+
"langcode": "en",
52+
"links": {
53+
"self": {
54+
"href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519",
55+
},
56+
},
57+
"paragraph_type": {
58+
"id": "9c5d2698-f605-42f2-a516-15949b84d17f",
59+
"resourceIdObjMeta": {
60+
"drupal_internal__target_id": "phone_number",
61+
},
62+
"type": "paragraphs_type--paragraphs_type",
63+
},
64+
"parent_field_name": "field_telephone",
65+
"parent_id": "94",
66+
"parent_type": "node",
67+
"relationshipNames": [
68+
"paragraph_type",
69+
],
70+
"resourceIdObjMeta": {
71+
"drupal_internal__target_id": 163647,
72+
"target_revision_id": 1561519,
73+
},
74+
"revision_translation_affected": null,
75+
"status": true,
76+
"type": "paragraph--phone_number",
77+
},
3778
"id": "c76037be-ebb0-4338-9b31-973a76958929",
3879
"langcode": "en",
3980
"links": {

src/data/queries/tests/__snapshots__/pressRelease.test.tsx.snap

+16-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,22 @@ exports[`node--press_release formatData output formatted data 1`] = `
3434
"uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/wilmington-health-care/news-releases/wilmington-vamc-2019-annual-report",
3535
},
3636
],
37-
"contacts": [],
37+
"contacts": [
38+
{
39+
"description": "Public Affairs Specialist",
40+
"email": "[email protected]",
41+
"id": "7ecb5154-7e2c-4c16-a171-bb3710a4dab7",
42+
"name": "Sheila Tunney",
43+
"numbers": [
44+
{
45+
"ext": null,
46+
"id": "a96f65e2-5a82-4b59-b249-25c634e93108",
47+
"number": "412-360-1479",
48+
"type": "phone",
49+
},
50+
],
51+
},
52+
],
3853
"downloads": [],
3954
"entityId": 18141,
4055
"entityPath": "/wilmington-health-care/news-releases/wilmington-vamc-2019-annual-report",

src/data/queries/tests/pressRelease.test.tsx

+35-1
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,48 @@ describe(`${RESOURCE_TYPES.PRESS_RELEASE} formatData`, () => {
4343
expect(formattedData.administration.name).toBeNull()
4444
expect(formattedData.pdfVersion).toBeNull()
4545
})
46+
test('handles missing or null contact fields correctly', () => {
47+
const modifiedMockContact: NodePressRelease = {
48+
...nodePressReleaseMock,
49+
field_press_release_contact: [
50+
{
51+
...nodePressReleaseMock.field_press_release_contact[0],
52+
id: undefined,
53+
field_description: undefined,
54+
title: undefined,
55+
field_email_address: undefined,
56+
field_telephone: {
57+
...nodePressReleaseMock.field_press_release_contact[0]
58+
.field_telephone,
59+
id: undefined,
60+
field_phone_number_type: undefined,
61+
field_phone_number: undefined,
62+
field_phone_extension: undefined,
63+
},
64+
},
65+
],
66+
}
67+
const formattedData = queries.formatData(
68+
RESOURCE_TYPES.PRESS_RELEASE,
69+
modifiedMockContact
70+
)
71+
expect(formattedData.contacts[0].id).toBeNull()
72+
expect(formattedData.contacts[0].description).toBeNull()
73+
expect(formattedData.contacts[0].name).toBeNull()
74+
expect(formattedData.contacts[0].email).toBeNull()
75+
expect(formattedData.contacts[0].numbers[0].id).toBeNull()
76+
expect(formattedData.contacts[0].numbers[0].type).toBeNull()
77+
expect(formattedData.contacts[0].numbers[0].number).toBeNull()
78+
expect(formattedData.contacts[0].numbers[0].ext).toBeNull()
79+
})
4680
})
4781

4882
describe('DrupalJsonApiParams configuration for pressRelease', () => {
4983
test('params function sets the correct include fields', () => {
5084
const paramsInstance = params()
5185
const queryString = decodeURIComponent(paramsInstance.getQueryString())
5286
expect(queryString).toMatch(
53-
/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/
87+
/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/
5488
)
5589
})
5690
})

src/mocks/newsStory.mock.json

+40-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,46 @@
195195
"field_last_saved_by_editor": "2019-11-12T20:21:16+00:00",
196196
"field_meta_tags": null,
197197
"field_name_first": "Keith",
198-
"field_phone_number": null,
198+
"field_telephone": {
199+
"type": "paragraph--phone_number",
200+
"id": "a96f65e2-5a82-4b59-b249-25c634e93108",
201+
"drupal_internal__id": 163647,
202+
"drupal_internal__revision_id": 1561519,
203+
"langcode": "en",
204+
"status": true,
205+
"created": "2024-11-25T18:00:06+00:00",
206+
"parent_id": "94",
207+
"parent_type": "node",
208+
"parent_field_name": "field_telephone",
209+
"behavior_settings": [],
210+
"default_langcode": true,
211+
"revision_translation_affected": null,
212+
"breadcrumbs": [],
213+
"content_translation_source": "und",
214+
"content_translation_outdated": false,
215+
"content_translation_changed": "2024-11-25T18:00:06+00:00",
216+
"field_phone_extension": null,
217+
"field_phone_label": null,
218+
"field_phone_number": "412-360-1479",
219+
"field_phone_number_type": "phone",
220+
"links": {
221+
"self": {
222+
"href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519"
223+
}
224+
},
225+
"resourceIdObjMeta": {
226+
"target_revision_id": 1561519,
227+
"drupal_internal__target_id": 163647
228+
},
229+
"paragraph_type": {
230+
"type": "paragraphs_type--paragraphs_type",
231+
"id": "9c5d2698-f605-42f2-a516-15949b84d17f",
232+
"resourceIdObjMeta": {
233+
"drupal_internal__target_id": "phone_number"
234+
}
235+
},
236+
"relationshipNames": ["paragraph_type"]
237+
},
199238
"field_photo_allow_hires_download": false,
200239
"field_suffix": null,
201240
"links": {

src/mocks/pressRelease.mock.json

+164-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,170 @@
368368
}
369369
}
370370
},
371-
"field_press_release_contact": [],
371+
"field_press_release_contact": [
372+
{
373+
"type": "node--person_profile",
374+
"id": "7ecb5154-7e2c-4c16-a171-bb3710a4dab7",
375+
"drupal_internal__nid": 94,
376+
"drupal_internal__vid": 988884,
377+
"sticky": false,
378+
"default_langcode": true,
379+
"langcode": "en",
380+
"status": true,
381+
"title": "Sheila Tunney",
382+
"created": "2019-02-26T05:47:15+00:00",
383+
"changed": "2024-11-25T18:00:07+00:00",
384+
"breadcrumbs": [
385+
{
386+
"uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/",
387+
"title": "Home",
388+
"options": []
389+
},
390+
{
391+
"uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/pittsburgh-health-care",
392+
"title": "VA Pittsburgh Health Care",
393+
"options": []
394+
},
395+
{
396+
"uri": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/pittsburgh-health-care/staff-profiles/sheila-tunney",
397+
"title": "Sheila Tunney",
398+
"options": []
399+
}
400+
],
401+
"moderation_state": "published",
402+
"expiration_date": null,
403+
"warning_date": null,
404+
"metatag": [
405+
{
406+
"tag": "meta",
407+
"attributes": {
408+
"name": "title",
409+
"content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs"
410+
}
411+
},
412+
{
413+
"tag": "link",
414+
"attributes": {
415+
"rel": "image_src",
416+
"href": "https://www.va.gov/img/design/logo/va-og-image.png"
417+
}
418+
},
419+
{
420+
"tag": "meta",
421+
"attributes": {
422+
"property": "og:site_name",
423+
"content": "Veterans Affairs"
424+
}
425+
},
426+
{
427+
"tag": "meta",
428+
"attributes": {
429+
"property": "og:title",
430+
"content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs"
431+
}
432+
},
433+
{
434+
"tag": "meta",
435+
"attributes": {
436+
"name": "twitter:card",
437+
"content": "summary_large_image"
438+
}
439+
},
440+
{
441+
"tag": "meta",
442+
"attributes": {
443+
"name": "twitter:site",
444+
"content": "@DeptVetAffairs"
445+
}
446+
},
447+
{
448+
"tag": "meta",
449+
"attributes": {
450+
"name": "twitter:title",
451+
"content": "Sheila Tunney | VA Pittsburgh health care | Veterans Affairs"
452+
}
453+
}
454+
],
455+
"path": {
456+
"alias": "/pittsburgh-health-care/staff-profiles/sheila-tunney",
457+
"pid": 214,
458+
"langcode": "en"
459+
},
460+
"field_body": null,
461+
"field_complete_biography_create": false,
462+
"field_description": "Public Affairs Specialist",
463+
"field_email_address": "[email protected]",
464+
"field_intro_text": null,
465+
"field_last_name": "Tunney",
466+
"field_last_saved_by_an_editor": "2024-05-02T13:03:19+00:00",
467+
"field_meta_tags": null,
468+
"field_name_first": "Sheila",
469+
"field_photo_allow_hires_download": false,
470+
"field_suffix": null,
471+
"links": {
472+
"self": {
473+
"href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/node/person_profile/7ecb5154-7e2c-4c16-a171-bb3710a4dab7?resourceVersion=id%3A934975"
474+
}
475+
},
476+
"node_type": {
477+
"type": "node_type--node_type",
478+
"id": "89b07673-7fd5-4292-8fba-58cc10c4e3ec",
479+
"resourceIdObjMeta": {
480+
"drupal_internal__target_id": "person_profile"
481+
}
482+
},
483+
"field_administration": {
484+
"type": "taxonomy_term--administration",
485+
"id": "87832236-1e54-4ce3-8141-8dec27c8a9a7",
486+
"resourceIdObjMeta": {
487+
"drupal_internal__target_id": 12
488+
}
489+
},
490+
"field_complete_biography": null,
491+
"field_media": null,
492+
"field_office": null,
493+
"field_telephone": {
494+
"type": "paragraph--phone_number",
495+
"id": "a96f65e2-5a82-4b59-b249-25c634e93108",
496+
"drupal_internal__id": 163647,
497+
"drupal_internal__revision_id": 1561519,
498+
"langcode": "en",
499+
"status": true,
500+
"created": "2024-11-25T18:00:06+00:00",
501+
"parent_id": "94",
502+
"parent_type": "node",
503+
"parent_field_name": "field_telephone",
504+
"behavior_settings": [],
505+
"default_langcode": true,
506+
"revision_translation_affected": null,
507+
"breadcrumbs": [],
508+
"content_translation_source": "und",
509+
"content_translation_outdated": false,
510+
"content_translation_changed": "2024-11-25T18:00:06+00:00",
511+
"field_phone_extension": null,
512+
"field_phone_label": null,
513+
"field_phone_number": "412-360-1479",
514+
"field_phone_number_type": "phone",
515+
"links": {
516+
"self": {
517+
"href": "https://content-build-medc0xjkxm4jmpzxl3tfbcs7qcddsivh.ci.cms.va.gov/jsonapi/paragraph/phone_number/a96f65e2-5a82-4b59-b249-25c634e93108?resourceVersion=id%3A1561519"
518+
}
519+
},
520+
"resourceIdObjMeta": {
521+
"target_revision_id": 1561519,
522+
"drupal_internal__target_id": 163647
523+
},
524+
"paragraph_type": {
525+
"type": "paragraphs_type--paragraphs_type",
526+
"id": "9c5d2698-f605-42f2-a516-15949b84d17f",
527+
"resourceIdObjMeta": {
528+
"drupal_internal__target_id": "phone_number"
529+
}
530+
},
531+
"relationshipNames": ["paragraph_type"]
532+
}
533+
}
534+
],
372535
"field_press_release_downloads": [],
373536
"field_administration": {
374537
"drupal_internal__tid": 188,

0 commit comments

Comments
 (0)