-
Notifications
You must be signed in to change notification settings - Fork 220
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
Conversation
0b296ea
to
13c7196
Compare
})[pageType]; | ||
|
||
const constructDataFilePath = (dataPathId: string[]) => { | ||
if (dataPathId.length > 4) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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..?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
ws-nextjs-app/pages/api/local/[service]/[pageType]/[id]/[[...variant]].api.ts
Dismissed
Show dismissed
Hide dismissed
ws-nextjs-app/pages/api/local/[service]/[pageType]/[id]/[[...variant]].api.ts
Fixed
Show fixed
Hide fixed
ws-nextjs-app/pages/api/local/[service]/[pageType]/[id]/[[...variant]].api.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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!
…:bbc/simorgh into WSTEAMA-1257-stabilise-integration-tests
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
LIGHTHOUSE_BUILD
instead ofLIGHTHOUSE_TEST_BUILD
.Sample API routes
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
Helpful Links
Add Links to useful resources related to this PR if applicable.
Coding Standards
Repository use guidelines