Skip to content

[WS-2839]: Hide articles in myNews page when metadata is not present#14170

Open
LukasFrm wants to merge 12 commits into
latestfrom
WS-2839-hide-articles-in-mynews-page-when-metadata-is-not-present
Open

[WS-2839]: Hide articles in myNews page when metadata is not present#14170
LukasFrm wants to merge 12 commits into
latestfrom
WS-2839-hide-articles-in-mynews-page-when-metadata-is-not-present

Conversation

@LukasFrm

@LukasFrm LukasFrm commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

Summary

image

Articles with metaData: null are now filtered out before rendering on the My News page.
Sanitises promoImageAltText before it is posted to the UAS favourites API. Article alt text containing newline characters (e.g. "शाहरुख़ ख़ान\n") was causing the stored metadata to be silently dropped when fetching saved articles back from UAS.

Code changes

  • metaData made optional on UasActivityItem; items without it are filtered in getRecentActivity
  • Add sanitiseMetadataString helper in uasUtility.ts that strips \r/\n characters and trims whitespace from a string before it is sent to UAS (otherwise if present inmetaData, the object itself is stripped).
  • Apply sanitiseMetadataString to promoImageAltText so all save/update payloads are clean.
  • Add a new uasUtility.test.ts with unit tests covering trailing newlines, \r\n, embedded newlines, empty/undefined input, and clean strings.

Testing

  1. Save an article where the image alt text contains a trailing newline (POST payload's metaData should include promoImageAltText: "शाहरुख़ ख़ान\n" ).
  2. Confirm the POST payload's metaData.promoImageAltText has no \n in it (check Network tab or logs).
  3. Fetch saved articles (My News page) and confirm the article appears with correct metadata.
  4. Run yarn test src/app/lib/uasApi/uasUtility.test.ts — all tests should pass.

Useful Links

@LukasFrm LukasFrm marked this pull request as ready for review July 3, 2026 06:18
Comment thread src/app/lib/uasApi/uasUtility.ts Outdated
Comment thread src/app/lib/uasApi/uasUtility.ts Outdated
@LukasFrm LukasFrm requested review from elvinasv and jinidev July 7, 2026 09:52

@elvinasv elvinasv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tested using http://localhost.bbc.com:7081/hindi/articles/cwy0pz7qydzo?renderer_env=live(which has an invalid metadata). Works as expected 👍

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.

4 participants