Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cypress/e2e/ContactUs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Validate Contact Us Landing page', () => {
cy.get('[data-cy = "contact-task-list"]')
.find('a')
.should('be.visible')
.and('have.length', '3')
.and('have.length', '4')
.and('not.have.length', 0)
.and('not.have.attr', 'href', '#undefined')
})
Expand Down
31 changes: 26 additions & 5 deletions graphql/mappers/contact-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ const getCachedContent = () => {
cache,
getFreshValue: async () => {
const response = await fetch(
`${process.env.AEM_GRAPHQL_ENDPOINT}getSchContactUsV1`
`${process.env.AEM_GRAPHQL_ENDPOINT}getSchContactUsV1`,
)
if (!response.ok) return null
return (await response.json()) as GetSchContactUsV1
},
ttl,
})
}

/**
* Awaited: Recursively unwraps the "awaited type" of a type.
* ReturnType: Obtain the return type of a function type
Expand All @@ -98,6 +98,7 @@ export async function getContactUsContent() {
const eiContactFragment = findFragmentByScId(response, 'ei-contact-us')
const oasContactFragment = findFragmentByScId(response, 'oas-contact-us')
const cppContactFragment = findFragmentByScId(response, 'cpp-contact-us')
const sinContactFragment = findFragmentByScId(response, 'sin-contact-us')

const mappedSecurity = {
en: {
Expand All @@ -108,7 +109,7 @@ export async function getContactUsContent() {
link: level.scPageNameEn,
text: level.scTitleEn,
}
}
},
),
pageName: response?.data.schPageV1ByPath.item.scPageNameEn,
heading: response?.data.schPageV1ByPath.item.scTitleEn,
Expand Down Expand Up @@ -144,6 +145,16 @@ export async function getContactUsContent() {
: '',
schBetaPopup: oasContactFragment?.schBetaPopUp,
},
{
linkId: sinContactFragment?.scId,
linkTitle: sinContactFragment?.scLinkTextEn,
linkAssistiveTitle: sinContactFragment?.scLinkTextAssistiveEn,
linkDestination: sinContactFragment?.scDestinationURLEn,
linkDescription: sinContactFragment?.scDescriptionEn?.json
? sinContactFragment.scDescriptionEn.json[0].content[0].value
: '',
schBetaPopup: sinContactFragment?.schBetaPopUp,
},
],
},
fr: {
Expand All @@ -154,7 +165,7 @@ export async function getContactUsContent() {
link: level.scPageNameFr,
text: level.scTitleFr,
}
}
},
),
pageName: response?.data.schPageV1ByPath.item.scPageNameFr,
heading: response?.data.schPageV1ByPath.item.scTitleFr,
Expand Down Expand Up @@ -190,6 +201,16 @@ export async function getContactUsContent() {
: '',
schBetaPopup: oasContactFragment?.schBetaPopUp,
},
{
linkId: sinContactFragment?.scId,
linkTitle: sinContactFragment?.scLinkTextFr,
linkAssistiveTitle: sinContactFragment?.scLinkTextAssistiveFr,
linkDestination: sinContactFragment?.scDestinationURLFr,
linkDescription: sinContactFragment?.scDescriptionFr?.json
? sinContactFragment.scDescriptionFr.json[0].content[0].value
: '',
schBetaPopup: sinContactFragment?.schBetaPopUp,
},
],
},
}
Expand All @@ -199,7 +220,7 @@ export async function getContactUsContent() {
const findFragmentByScId = (res: GetSchContactUsV1 | null, id: string) => {
return (
res?.data.schPageV1ByPath.item.scFragments.find(
({ scId }) => scId === id
({ scId }) => scId === id,
) ?? null
)
}
14 changes: 9 additions & 5 deletions pages/contact-us/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ const ContactLanding = (props: ContactLandingProps) => {
id={link.linkId}
data-testid={link.linkId}
aria-label={link.linkTitle}
href={`/${props.locale}/${props.content.pageName}/${(
link.linkDestination ?? ''
)
.split('/')
.pop()}`}
href={
link.linkDestination?.includes('http')
? link.linkDestination
: `/${props.locale}/${props.content.pageName}/${(
link.linkDestination ?? ''
)
.split('/')
.pop()}`
}
data-gc-analytics-customclick={`ESDC-EDSC_MSCA-MSDC-SCH:Contact Us:${link.linkTitle}`}
target={
newTabExceptions.includes(link.linkDestination ?? '')
Expand Down