Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSTEAMA-1257: Stabilise integration tests hitting LIVE endpoints #11753

Merged
merged 40 commits into from
Aug 7, 2024

Conversation

alex-magana
Copy link
Contributor

@alex-magana alex-magana commented Jul 8, 2024

Resolves JIRA WSTEAMA-1257

Overall changes

Removes reliance on BFF data in the integration test suite to stabilise test
execution outcome during routine runs in CI as well as the local environment.

Code changes

  • Remove BFF_PATH and INTEGRATION_TEST_BUILD from the integration tests configuration.
  • Update the certsRequired to remove INTEGRATION_TEST_BUILD from the evelauted condition.
  • Update the unit tests for the certsRequired utility to reference LIGHTHOUSE_BUILD instead of LIGHTHOUSE_TEST_BUILD.
  • Update data and schemas of UGC Uploader and Live Page fixtures.
  • Add changes to the local routing logic to consume fixture data, from the local API, for UGC Uploader and Live Page tests.
  • Implement API endpoints to serve local fixtures for UGC Uploader and Live Page tests.

Sample API routes

http://localhost:7081/api/local/pidgin/live/c7p765ynk9qt
http://localhost:7081/api/local/zhongwen/simp/live/c0000000000t
http://localhost:7081/api/local/somali/send/u130092370

Note

UGC Uploader forms to proved script specific forms as seen in the example below.
https://www.bbc.com/serbian/send/u50853665
For this reason, this PR doesn't include a placeholder fixture file for dual script services.

Testing

  1. List the steps used to test this PR.

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@alex-magana alex-magana force-pushed the WSTEAMA-1257-stabilise-integration-tests branch from 0b296ea to 13c7196 Compare July 31, 2024 13:25
@alex-magana alex-magana marked this pull request as ready for review August 1, 2024 13:54
})[pageType];

const constructDataFilePath = (dataPathId: string[]) => {
if (dataPathId.length > 4) {
Copy link
Contributor Author

@alex-magana alex-magana Aug 1, 2024

Choose a reason for hiding this comment

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

This check exists to ensure the API endpoints aren't exploited
on account of using the catch-all [...id] notation.

The catch-all/api/local/[...id] route is in place to enable support for dual
script variants in the request path.

Copy link
Contributor

@amoore108 amoore108 Aug 1, 2024

Choose a reason for hiding this comment

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

We may be able to use the catch-all syntax for API routes, similar to what we've done within the pages/[service]/live and pages/[service]/send folders. The entry point into those pages is [[...variant]].page.tsx which catches the optional variant parameter.

Would something like /api/local/[service]/[pageType]/[id]/[[...variant]] work? Thats the pattern for our current Next.js pages. That could change in the future though once we migrate other page types over than have the variant within the URL params, rather than at the end, but may be something to tackle at that time.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would mean that you would need to work out where to point to the .json file in the API, since the folder structure for the JSON data would be different to the actual route requested. I think that may be ok though? Otherwise the local URL would need manually constructed as you have in constructedPageFetchUrl, so I guess either way there will be some manual pathing required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback Aaron.
I had considered going the /api/local/[service]/[pageType]/[id]/[[...variant]]
way similar to your recommendation. I however sought to replicate the current dual script
routes for Live Pages such as the pages linked below hence logic seen in constructDataFilePath.

https://www.bbc.com/zhongwen/simp/live/world-47367050
https://www.bbc.com/zhongwen/trad/live/world-47367050

In keeping with the current route structure for Live Pages where the optional catch-all
supports passing the variant at the end, I'll change the API to accept the variant at the
end of the URL path.


const getFixtureLocation = (pageType: string) =>
({
live: 'livePage',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any chance that this could be renamed (and the fixtures moved) to live instead of livePage? Just for consistency / better dev-x because we can find things more easily..?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is probably what Aaron is also discussing https://github.com/bbc/simorgh/pull/11753/files#r1700322809

Copy link
Contributor Author

@alex-magana alex-magana Aug 2, 2024

Choose a reason for hiding this comment

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

Thanks for the feedback Karina.
Yes. This is feasible. I adopted the livePage directory name based
on what's currently on latest.
We can adopt the name, live, directory though and remove the need to infer it using
getFixtureLocation.
I'll proceed to make this change.

@alex-magana alex-magana self-assigned this Aug 5, 2024
Copy link
Contributor

@amoore108 amoore108 left a comment

Choose a reason for hiding this comment

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

Looks great, really nice work!

@andrewscfc andrewscfc merged commit 97b8640 into latest Aug 7, 2024
11 checks passed
@andrewscfc andrewscfc deleted the WSTEAMA-1257-stabilise-integration-tests branch August 7, 2024 08:54
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