Skip to content

[WS-2208]: Integrate the “Create Activity” POST API for “Save for later” click (happy flow)#13890

Draft
LukasFrm wants to merge 4 commits intolatestfrom
WS-2208-integrate-create-activity-post-api-for-save-for-later-click-happy-flow
Draft

[WS-2208]: Integrate the “Create Activity” POST API for “Save for later” click (happy flow)#13890
LukasFrm wants to merge 4 commits intolatestfrom
WS-2208-integrate-create-activity-post-api-for-save-for-later-click-happy-flow

Conversation

@LukasFrm
Copy link
Copy Markdown
Contributor

@LukasFrm LukasFrm commented Apr 9, 2026

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

Summary

When a signed-in user clicks the "Save for later" button on an article page, a POST request is now sent to the UAS (User Activity Service) Create Activity endpoint to save the article as a favourite.
On a successful response, the button text updates to "Remove from saved".
This is the happy-path only implementation - no error handling, retry logic, or fallback UI is included.

Code changes

  • Added handleSaveArticle in useUASButton hook — sends POST to UAS on click, updates saved state on success, guards against duplicate requests.
  • Wired onClick on SaveArticleButton; added title prop threaded from headline in ArticlePage.
  • Added createFavouritesPayload in uasUtility.ts to build the UAS POST body.
  • Consolidated UAS constants into FAVOURITES_CONFIG object; made buildGlobalId generic with optional resourceDomain/resourceType params.
  • Exposed setIsSaved from useUASFetchSaveStatus for post-save state updates.

Testing

  1. Run unit tests: yarn jest index.test.tsx index.test.tsx index.test.tsx index.test.ts --runInBand --no-coverage — all 27 tests should pass.
  2. Run yarn dev and navigate to an article page for the hindi service (the service enabled in the uasPersonalization toggle).
  3. Sign in with a valid BBC account (ensuring ckns_atkn cookie is present).
  4. Click the "Save for later" button.
  5. Open browser DevTools → Network tab and verify a POST request is sent to https://activity.test.api.bbc.co.uk/my/favourites with the correct headers (X-API-Key) and body payload (activityType: "favourites", resourceDomain: "articles", resourceType: "article", action: "favourited", metaData containing service, articleId, title).
  6. On a 202 response, verify the button text changes to "Remove from saved".
  7. Verify the button does not appear when not signed in or when the uasPersonalization toggle is off.

Useful Links

@LukasFrm LukasFrm requested a review from jinidev April 10, 2026 07:18
<button
css={styles.buttonWrapper}
type="button"
onClick={() => handleSaveAction(isSaved ? 'remove' : 'save')}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: Could we assign these strings (remove / save ) to an imported constant so they are maintained in a single location?

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.

2 participants