{keyPoints && (
diff --git a/ws-nextjs-app/pages/[service]/live/[id]/live.stories.tsx b/ws-nextjs-app/pages/[service]/live/[id]/live.stories.tsx
index f5a3c4574d4..02c13835f33 100644
--- a/ws-nextjs-app/pages/[service]/live/[id]/live.stories.tsx
+++ b/ws-nextjs-app/pages/[service]/live/[id]/live.stories.tsx
@@ -1,6 +1,7 @@
import PageLayoutWrapper from '#app/components/PageLayoutWrapper';
import liveFixture from '#data/pidgin/live/c7p765ynk9qt.json';
import liveFixtureWithLiveMedia from '#data/mundo/live/c7dkx155e626t.json';
+import liveFixtureWithSportDataHeader from '#data/afrique/live/c7gk1vjglxn1t.json';
import postFixture from '#data/pidgin/posts/postFixtureCleaned.json';
import Live, { ComponentProps } from './LivePageLayout';
@@ -35,3 +36,9 @@ export default {
export const Example = () =>
;
export const WithLiveStream = () =>
;
+export const WithSportDataHeader = () => (
+
+);
diff --git a/ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx b/ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx
index e2dfcc273b9..22a68772b2d 100644
--- a/ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx
+++ b/ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx
@@ -7,9 +7,11 @@ import {
} from '#app/components/react-testing-library-with-providers';
import liveFixture from '#data/pidgin/live/c7p765ynk9qt.json';
import postFixture from '#data/pidgin/posts/postFixture.json';
+import sportDataFixture from '#data/afrique/live/c7gk1vjglxn1t.json';
import { GetServerSidePropsContext } from 'next';
import MockIntersectionObserver from '#app/components/intersection-observer-testing-library';
import * as useLivePagePolling from '#app/hooks/useLivePagePolling';
+import * as isLiveEnvModule from '#app/lib/utilities/isLive';
import Live, { ComponentProps } from './LivePageLayout';
import { getServerSideProps } from './[[...variant]].page';
import { StreamResponse } from './Post/types';
@@ -19,6 +21,27 @@ jest.mock('#app/hooks/useLivePagePolling', () => ({
default: jest.fn(),
}));
+jest.mock('#app/lib/utilities/isLive', () => ({
+ __esModule: true,
+ default: jest.fn(() => false),
+}));
+
+jest.mock('#app/components-webcore/SportDataHeader/head-to-head-v2', () => ({
+ __esModule: true,
+ default: jest.fn(
+ ({ data, isConciseView, shouldHideBadges, shouldShowActions }) => (
+
+ {data?.home?.fullName} vs {data?.away?.fullName}
+
+ ),
+ ),
+}));
+
type HelmetMetaTag = {
property?: string;
content?: string;
@@ -557,4 +580,129 @@ describe('Live Page', () => {
expect((ogTitleMeta as HelmetMetaTag)?.content).toEqual(expectedOgTitle);
expect((ogImageMeta as HelmetMetaTag)?.content).toEqual(expectedOgImage);
});
+
+ describe('SportData handling', () => {
+ it('should render HeadToHeadV2 when sportDataEventContent is present and not in live env', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ expect(screen.getByTestId('head-to-head-v2')).toBeInTheDocument();
+ });
+
+ it('should pass correct data to HeadToHeadV2 component', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ const headToHeadElement = screen.getByTestId('head-to-head-v2');
+ expect(headToHeadElement).toHaveTextContent('Bologna vs Aston Villa');
+ });
+
+ it('should pass correct props to HeadToHeadV2 component', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ const headToHeadElement = screen.getByTestId('head-to-head-v2');
+ expect(headToHeadElement).toHaveAttribute('data-concise', 'false');
+ expect(headToHeadElement).toHaveAttribute('data-hide-badges', 'false');
+ expect(headToHeadElement).toHaveAttribute('data-show-actions', 'false');
+ });
+
+ it('should render a h1 when displaying sportData', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ const { container } = await act(async () => {
+ return render(
);
+ });
+
+ const title = container.querySelector('h1');
+ expect(title).toBeInTheDocument();
+ });
+
+ it('should render a visually hidden h1 when displaying sportData', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ const visuallyHiddenTitle = screen.getByText(
+ 'Villa gain upper hand with gritty Europa League win at Bologna',
+ );
+ expect(visuallyHiddenTitle).toBeInTheDocument();
+ expect(visuallyHiddenTitle).toHaveStyle(
+ 'overflow: hidden; position: absolute; width: 1px;',
+ );
+ });
+
+ it('should not render HeadToHeadV2 when sportDataEventContent is not present', async () => {
+ mockPollingUpdate(mockPageData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ expect(screen.queryByTestId('head-to-head-v2')).not.toBeInTheDocument();
+ });
+
+ it('should not render HeadToHeadV2 when in live environment', async () => {
+ const pageDataWithSportData = {
+ ...mockPageData,
+ sportDataEventContent: sportDataFixture.data.sportDataEventContent,
+ };
+ mockPollingUpdate(pageDataWithSportData);
+
+ jest.spyOn(isLiveEnvModule, 'default').mockReturnValue(true);
+
+ await act(async () => {
+ render(
);
+ });
+
+ expect(screen.queryByTestId('head-to-head-v2')).not.toBeInTheDocument();
+
+ jest.spyOn(isLiveEnvModule, 'default').mockReturnValue(false);
+ });
+
+ it('should render Header when sportDataEventContent is not present', async () => {
+ mockPollingUpdate(mockPageData);
+
+ await act(async () => {
+ render(
);
+ });
+
+ expect(
+ screen.getByText(
+ 'Israeli tanks shell Jabalia camp as heavy fighting continues in north Gaza',
+ ),
+ ).toBeInTheDocument();
+ });
+ });
});