Skip to content

Commit

Permalink
Hide embeds on Lite (#12108)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 authored Oct 29, 2024
1 parent 98cb856 commit a90cb74
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/app/components/Embeds/OEmbed/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@ import OEmbedLoader from '.';
const Component = ({
props,
isAmp,
isLite,
service = 'pidgin',
}: {
props: OEmbedProps;
isAmp: boolean;
isLite?: boolean;
service?: Services;
}) => {
const OEmbedValue = useMemo(
() =>
({
id: 'c0000000000o',
isAmp,
isLite,
isApp: false,
pageType: ARTICLE_PAGE,
pathname: '/pathname',
service,
statusCode: 200,
canonicalLink: 'canonical_link',
}) as unknown as RequestContextProps,
[isAmp, service],
[isAmp, isLite, service],
);
return (
<RequestContext.Provider value={OEmbedValue}>
Expand Down Expand Up @@ -187,4 +190,13 @@ describe('OEmbed', () => {
expect(errorMessage).toBeInTheDocument();
});
});

describe('Lite', () => {
it('Should return null if isLite is true', () => {
const { container } = render(
<Component props={sampleRiddleProps} isAmp={false} isLite />,
);
expect(container).toBeEmptyDOMElement();
});
});
});
5 changes: 4 additions & 1 deletion src/app/components/Embeds/OEmbed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit a90cb74

Please sign in to comment.