Skip to content

WS-2610: Sport Data Polling (Front end changes)#14015

Merged
Isabella-Mitchell merged 52 commits into
latestfrom
WS-2610-sport-data-polling
May 21, 2026
Merged

WS-2610: Sport Data Polling (Front end changes)#14015
Isabella-Mitchell merged 52 commits into
latestfrom
WS-2610-sport-data-polling

Conversation

@Isabella-Mitchell
Copy link
Copy Markdown
Contributor

@Isabella-Mitchell Isabella-Mitchell commented May 14, 2026

Resolves JIRA: https://bbc.atlassian.net/browse/WS-2610

Summary

Front end changes to support polling of sports data header

Code changes

  • Created a useSportDataPolling hook (as opposed to refactoring isLivePagePolling) - polls with 15s interval
  • Created makeRequest fetcher within hook.
  • Use this hook within the sportsDataHeader (I thought this would be better than using it at the page level)
  • Updates unit tests and Storybook stories/helpers to match the new prop/hook usage.

Testing

  1. N/A until polling route is available (I did create a fake fetcher during development but have removed this).
  2. Locally you can check what happens if polling is not working:
  3. http://localhost:7081/afrique/live/c7gk1vjglxn1t - polling is enabled (since the sports data is live), so polling is attempted. However polling is returning null, so the content does not change
    http://localhost:7081/afrique/live/c7gk1vjglxn1t?renderer_env=test - polling is not live, so the initial data is displayed

Useful Links

@Isabella-Mitchell Isabella-Mitchell changed the title Ws 2610 sport data polling WS-2610: Sport Data Polling (Front end changes) May 15, 2026
@Isabella-Mitchell Isabella-Mitchell marked this pull request as ready for review May 19, 2026 14:53
Copilot AI review requested due to automatic review settings May 19, 2026 14:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds client-side polling support for the Sport Data “HeadToHeadV2” header on Live pages by introducing a dedicated polling hook + fetcher, and wiring it into the HeadToHeadV2 component and its consumers (tests/storybook updated accordingly).

Changes:

  • Introduces useSportDataPolling (15s interval) and a makeRequest fetcher for polling updated sport event data.
  • Updates Live page + Sport Data header to pass initialSportData (instead of data) and to supply a live/polling flag.
  • Updates unit tests and Storybook stories/helpers to match the new prop/hook usage.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ws-nextjs-app/pages/[service]/live/[id]/LivePageLayout.tsx Passes sport header initial data + live flag; adjusts local typing for sport data content.
ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx Updates mocks/fixtures to reflect new HeadToHeadV2 prop shape.
src/app/hooks/useSportDataPolling/index.ts New polling hook that periodically requests updated sport data.
src/app/hooks/useSportDataPolling/index.test.ts Unit tests for the new polling hook behavior.
src/app/hooks/useSportDataPolling/makeRequest/makeRequest.ts New fetcher for the sports polling endpoint.
src/app/hooks/useSportDataPolling/makeRequest/makeRequest.test.ts Unit tests for the new fetcher.
src/app/hooks/useSportDataPolling/fixture/fixtureSportData.js Fixture for initial sport data used in hook tests.
src/app/hooks/useSportDataPolling/fixture/fixtureSportDataUpdate.js Fixture for an updated sport data payload used in hook tests.
src/app/components-webcore/SportDataHeader/head-to-head-v2/head-to-head-v2.tsx Wires polling hook into the HeadToHeadV2 component and adds new props.
src/app/components-webcore/SportDataHeader/head-to-head-v2/types.ts Extends sport event type to include an event urn.
src/app/components-webcore/SportDataHeader/head-to-head-v2/tests/index.test.tsx Mocks polling hook and updates prop usage for component tests.
src/app/components-webcore/SportDataHeader/head-to-head-v2/storybook/helpers/base-component.tsx Updates Storybook helper usage to pass initialSportData.
src/app/components-webcore/SportDataHeader/head-to-head-v2/head-to-head-v2.stories.tsx Updates stories to use initialSportData and satisfies the new urn requirement in args.
Comments suppressed due to low confidence (1)

ws-nextjs-app/pages/[service]/live/[id]/LivePageLayout.tsx:72

  • sportDataEventContent.live is declared as a required boolean, but the component logic treats it as nullable (isSportDataLive ?? isLive) and tests pass live: undefined. To keep the types aligned with actual/expected data, live should be optional (or boolean | null) in ComponentProps.
    sportDataEventContent?: {
      urn: string;
      live: boolean;
      sportDataEvent: HeadToHeadV2Data;
      title: string;

Comment thread ws-nextjs-app/pages/[service]/live/[id]/LivePageLayout.tsx Outdated
Comment thread src/app/components-webcore/SportDataHeader/head-to-head-v2/types.ts
Comment thread src/app/hooks/useSportDataPolling/makeRequest/makeRequest.ts Outdated
Comment thread src/app/hooks/useSportDataPolling/index.ts
Comment thread src/app/hooks/useSportDataPolling/index.test.ts
Comment thread ws-nextjs-app/pages/[service]/live/[id]/LivePageLayout.tsx
@Isabella-Mitchell
Copy link
Copy Markdown
Contributor Author

Heads up to reviewers - I've made an update based on the polling request data structure - (now it's live on test, I see had the structure slightly wrong) - https://github.com/bbc/simorgh/pull/14052/changes

@Isabella-Mitchell Isabella-Mitchell merged commit 77a00eb into latest May 21, 2026
13 checks passed
@Isabella-Mitchell Isabella-Mitchell deleted the WS-2610-sport-data-polling branch May 21, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants