From a90cb7498e50e76ffbeb527562c1d3954781f9cf Mon Sep 17 00:00:00 2001 From: Aaron Moore Date: Tue, 29 Oct 2024 10:00:56 +0000 Subject: [PATCH] Hide embeds on Lite (#12108) --- src/app/components/Embeds/OEmbed/index.test.tsx | 14 +++++++++++++- src/app/components/Embeds/OEmbed/index.tsx | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/components/Embeds/OEmbed/index.test.tsx b/src/app/components/Embeds/OEmbed/index.test.tsx index a79058d3924..20650087315 100644 --- a/src/app/components/Embeds/OEmbed/index.test.tsx +++ b/src/app/components/Embeds/OEmbed/index.test.tsx @@ -22,10 +22,12 @@ import OEmbedLoader from '.'; const Component = ({ props, isAmp, + isLite, service = 'pidgin', }: { props: OEmbedProps; isAmp: boolean; + isLite?: boolean; service?: Services; }) => { const OEmbedValue = useMemo( @@ -33,6 +35,7 @@ const Component = ({ ({ id: 'c0000000000o', isAmp, + isLite, isApp: false, pageType: ARTICLE_PAGE, pathname: '/pathname', @@ -40,7 +43,7 @@ const Component = ({ statusCode: 200, canonicalLink: 'canonical_link', }) as unknown as RequestContextProps, - [isAmp, service], + [isAmp, isLite, service], ); return ( @@ -187,4 +190,13 @@ describe('OEmbed', () => { expect(errorMessage).toBeInTheDocument(); }); }); + + describe('Lite', () => { + it('Should return null if isLite is true', () => { + const { container } = render( + , + ); + expect(container).toBeEmptyDOMElement(); + }); + }); }); diff --git a/src/app/components/Embeds/OEmbed/index.tsx b/src/app/components/Embeds/OEmbed/index.tsx index 688bb3401e3..d68b0859685 100644 --- a/src/app/components/Embeds/OEmbed/index.tsx +++ b/src/app/components/Embeds/OEmbed/index.tsx @@ -12,8 +12,11 @@ import AmpIframeEmbed from '../AmpIframeEmbed'; import { OEmbedProps } from '../types'; const OEmbedLoader = ({ oembed }: OEmbedProps) => { - const { isAmp, canonicalLink } = useContext(RequestContext); + const { isAmp, isLite, canonicalLink } = useContext(RequestContext); const { translations } = useContext(ServiceContext); + + if (isLite) return null; + const { html, provider_name, oEmbedType, parameters, url } = oembed; const isVDJEmbed = oEmbedType === 'vdj-embed';