From a98a734ba1902124a239011c4248da3b02b429d3 Mon Sep 17 00:00:00 2001 From: Aaron Moore Date: Fri, 1 Nov 2024 13:01:28 +0000 Subject: [PATCH] Election banner - Handle Turkce service URL (#12126) --- .../ArticlePage/ElectionBanner/index.test.tsx | 19 +++++++++++++++++++ .../ArticlePage/ElectionBanner/index.tsx | 15 ++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/app/pages/ArticlePage/ElectionBanner/index.test.tsx b/src/app/pages/ArticlePage/ElectionBanner/index.test.tsx index 216be8658cb..de3d9554abd 100644 --- a/src/app/pages/ArticlePage/ElectionBanner/index.test.tsx +++ b/src/app/pages/ArticlePage/ElectionBanner/index.test.tsx @@ -108,6 +108,25 @@ describe('ElectionBanner', () => { expect(getByTestId(ELEMENT_ID)).toBeInTheDocument(); }); + it('should render the correct VJ URL for Turkce service', () => { + const { getByTestId } = render( + , + { + toggles: { electionBanner: { enabled: true } }, + isAmp, + service: 'turkce', + }, + ); + + const wrappingEl = getByTestId(ELEMENT_ID); + + const iframe = wrappingEl.querySelector('iframe, amp-iframe'); + const iframeSrc = iframe?.getAttribute('src'); + + expect(iframeSrc).not.toContain('turkce'); + expect(iframeSrc).toContain('turkish'); + }); + it('should not render ElectionBanner when taggings contain the editorialSensitivityId', () => { const { queryByTestId } = render( { + switch (service) { + case 'turkce': + return url.replace('{service}', 'turkish'); + default: + return url.replace('{service}', service); + } +}; + export default function ElectionBanner({ aboutTags, taggings }: Props) { const { service } = useContext(ServiceContext); const { isAmp, isLite } = useContext(RequestContext); @@ -53,7 +63,10 @@ export default function ElectionBanner({ aboutTags, taggings }: Props) { } = getEnvConfig(); const iframeSrcToUse = SIMORGH_APP_ENV === 'live' ? iframeSrc : iframeDevSrc; - const iframeSrcWithService = iframeSrcToUse.replace('{service}', service); + const iframeSrcWithService = handleUrlServiceTransform( + iframeSrcToUse, + service, + ); if (isAmp) { return (