Skip to content

Commit

Permalink
Merge branch 'latest' into amp-iframe-externalembed-constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
amoore108 committed Oct 2, 2024
2 parents 45da045 + c72afef commit 4b89f31
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 46 deletions.
6 changes: 0 additions & 6 deletions src/app/legacy/components/ScrollablePromo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { GridItemMediumNoMargin } from '#components/Grid';
import useViewTracker from '#hooks/useViewTracker';
import useClickTrackerHandler from '#hooks/useClickTrackerHandler';
import idSanitiser from '#lib/utilities/idSanitiser';
import { OptimizelyContext } from '@optimizely/react-sdk';
import useOptimizelyScrollDepth from '#app/hooks/useOptimizelyScrollDepth';
import { ServiceContext } from '../../../contexts/ServiceContext';
import Promo from './Promo';
import PromoList from './PromoList';
Expand Down Expand Up @@ -61,19 +59,15 @@ const LabelComponent = styled.strong`

const ScrollablePromo = ({ blocks, blockGroupIndex = null }) => {
const { script, service, dir, translations } = useContext(ServiceContext);
const { optimizely } = useContext(OptimizelyContext);

const eventTrackingData = {
componentName: `edoj${blockGroupIndex}`,
format: 'CHD=edoj',
optimizely,
};

const viewRef = useViewTracker(eventTrackingData);
const handleClickTracking = useClickTrackerHandler(eventTrackingData);

useOptimizelyScrollDepth();

if (!blocks || isEmpty(blocks)) {
return null;
}
Expand Down
11 changes: 0 additions & 11 deletions src/app/legacy/components/ScrollablePromo/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import ScrollablePromo from '.';
import { edOjA, edOjB } from './fixtures';
import { MEDIA_ARTICLE_PAGE } from '../../../routes/utils/pageTypes';

jest.mock('#app/hooks/useOptimizelyScrollDepth', () => ({
__esModule: true,
default: jest.fn(),
}));

describe('ScrollablePromo', () => {
it('should return null if no data is passed', () => {
const { container } = render(<ScrollablePromo blocks={[]} />);
Expand Down Expand Up @@ -83,7 +78,6 @@ describe('ScrollablePromo', () => {
expect(viewTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj1',
format: 'CHD=edoj',
optimizely: null,
});
});

Expand All @@ -100,12 +94,10 @@ describe('ScrollablePromo', () => {
expect(viewTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj1',
format: 'CHD=edoj',
optimizely: null,
});
expect(viewTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj2',
format: 'CHD=edoj',
optimizely: null,
});
});

Expand All @@ -118,7 +110,6 @@ describe('ScrollablePromo', () => {
expect(clickTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj1',
format: 'CHD=edoj',
optimizely: null,
});
});

Expand All @@ -135,12 +126,10 @@ describe('ScrollablePromo', () => {
expect(clickTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj1',
format: 'CHD=edoj',
optimizely: null,
});
expect(clickTrackerSpy).toHaveBeenCalledWith({
componentName: 'edoj2',
format: 'CHD=edoj',
optimizely: null,
});
});
});
Expand Down
17 changes: 1 addition & 16 deletions src/app/pages/ArticlePage/ArticlePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ import CpsRecommendations from '#containers/CpsRecommendations';
import InlinePodcastPromo from '#containers/PodcastPromo/Inline';
import { Article, OptimoBylineBlock } from '#app/models/types/optimo';
import ScrollablePromo from '#components/ScrollablePromo';

import useOptimizelyVariation from '#app/hooks/useOptimizelyVariation';
import OptimizelyArticleCompleteTracking from '#app/legacy/containers/OptimizelyArticleCompleteTracking';
import OptimizelyPageViewTracking from '#app/legacy/containers/OptimizelyPageViewTracking';
import ImageWithCaption from '../../components/ImageWithCaption';
import AdContainer from '../../components/Ad';
import EmbedImages from '../../components/Embeds/EmbedImages';
Expand Down Expand Up @@ -135,10 +131,6 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
...(isCPS && { pageTitle: `${atiAnalytics.pageTitle} - ${brandName}` }),
};

const scrollablePromoVariation = useOptimizelyVariation(
'scrollable_promo',
) as unknown as string;

const componentsToRender = {
visuallyHiddenHeadline,
headline: headings,
Expand Down Expand Up @@ -172,12 +164,7 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
embedImages: EmbedImages,
embedUploader: Uploader,
group: gist,
links: (props: ComponentToRenderProps) =>
scrollablePromoVariation === 'variation_1_aa' ? (
<ScrollablePromo {...props} />
) : (
<ScrollablePromo {...props} />
),
links: (props: ComponentToRenderProps) => <ScrollablePromo {...props} />,
mpu: (props: ComponentToRenderProps) =>
allowAdvertising ? <AdContainer {...props} slotType="mpu" /> : null,
wsoj: (props: ComponentToRenderProps) => (
Expand Down Expand Up @@ -292,8 +279,6 @@ const ArticlePage = ({ pageData }: { pageData: Article }) => {
mobileDivider={showTopics}
/>
)}
<OptimizelyArticleCompleteTracking />
<OptimizelyPageViewTracking />
</div>
);
};
Expand Down
9 changes: 0 additions & 9 deletions src/app/pages/ArticlePage/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@ jest.mock('../../components/ChartbeatAnalytics', () => {
const ChartbeatAnalytics = () => <div>chartbeat</div>;
return ChartbeatAnalytics;
});

jest.mock('../../components/ATIAnalytics');
jest.mock('#app/legacy/containers/OptimizelyArticleCompleteTracking');
jest.mock('#app/legacy/containers/OptimizelyPageViewTracking');
jest.mock('#app/hooks/useOptimizelyScrollDepth');

jest.mock('#app/hooks/useOptimizelyVariation', () => ({
__esModule: true,
default: jest.fn(),
}));

const input = {
bbcOrigin: 'https://www.test.bbc.co.uk',
Expand Down
5 changes: 1 addition & 4 deletions src/app/pages/ArticlePage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import withOptimizelyProvider from '#app/legacy/containers/PageHandlers/withOptimizelyProvider';
import ArticlePage from './ArticlePage';
import applyBasicPageHandlers from '../utils/applyBasicPageHandlers';

const OptimizelyArticle = withOptimizelyProvider(ArticlePage);

export default applyBasicPageHandlers(OptimizelyArticle);
export default applyBasicPageHandlers(ArticlePage);

0 comments on commit 4b89f31

Please sign in to comment.