Skip to content

Commit

Permalink
Add separate AMP iframe src
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 committed Oct 18, 2024
1 parent 99c2a42 commit b85992a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/pages/ArticlePage/ElectionBanner/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const IFRAME_BASE_URL = getEnvConfig().SIMORGH_INCLUDES_BASE_URL;

export default {
iframeSrc: `${IFRAME_BASE_URL}/include/vjafwest/1365-2024-us-presidential-election-banner/develop/{service}/app`,
iframeSrcAmp: `${IFRAME_BASE_URL}/include/vjafwest/1365-2024-us-presidential-election-banner/develop/{service}/app/amp`,
iframeHeight: 340,
thingIds: [
'647d5613-e0e2-4ef5-b0ce-b491de38bdbd', // https://www.bbc.co.uk/things/647d5613-e0e2-4ef5-b0ce-b491de38bdbd
Expand Down
12 changes: 12 additions & 0 deletions src/app/pages/ArticlePage/ElectionBanner/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ describe('ElectionBanner', () => {
);

expect(getByTestId(bannerElement)).toBeInTheDocument();

const iframe = getByTestId(bannerElement).querySelector(
isAmp ? 'amp-iframe' : 'iframe',
);

expect(iframe).toHaveAttribute(
'src',
BANNER_CONFIG[isAmp ? 'iframeSrcAmp' : 'iframeSrc'].replace(
'{service}',
'news',
),
);
});

it('should not render ElectionBanner when aboutTags do not contain the correct thingLabel', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/ArticlePage/ElectionBanner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ElectionBanner({ aboutTags }: { aboutTags: Tag[] }) {
if (isLite) return null;
if (isLive()) return null; // TODO: Remove once going Live

const { iframeSrc, iframeHeight, thingIds } = BANNER_CONFIG;
const { iframeSrc, iframeSrcAmp, iframeHeight, thingIds } = BANNER_CONFIG;

const validAboutTag = aboutTags?.some(tag => thingIds.includes(tag.thingId));

Expand All @@ -39,7 +39,7 @@ export default function ElectionBanner({ aboutTags }: { aboutTags: Tag[] }) {
ampMetadata={{
imageWidth: 1,
imageHeight: iframeHeight,
src: iframeSrc.replace('{service}', service),
src: iframeSrcAmp.replace('{service}', service),
image:
'https://news.files.bbci.co.uk/include/vjassets/img/app-launcher.png',
}}
Expand Down

0 comments on commit b85992a

Please sign in to comment.