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
[UI] fix filter on api explorer #26657
Conversation
CI Results: |
f2bfa58
to
1bbddb1
Compare
return ( | ||
taggedOps | ||
.map((tagObj) => { | ||
const operations = tagObj.operations.filter((operationObj) => { |
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 line was failing because the type of tagObj
changed to a Map
, which does not have an .operations
property. instead we need to use the Map API's get & set methods to access or set properties.
// then traverse again and remove the top level item if there are no operations left after filtering | ||
.filter((tagObj) => !!tagObj.operations.size) | ||
); | ||
const filteredOperations = taggedOps.reduce((acc, tagObj) => { |
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.
the reduce function here allows us to combine the previous map
, filter
and thenmap
that we had before. π
Build Results: |
assert.dom('[data-test-swagger-ui]').exists('renders component'); | ||
await waitUntil(() => find('.operation-filter-input')); | ||
assert.dom('.opblock-post').exists({ count: 2 }, 'renders two blocks'); | ||
// for some reason search results are not rendered immediately in tests, |
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.
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.
yeah, i tried many variations of waitUntil
, waitFor
and setTimeout
to wait for the search results to update to no avail. what's bizarre is that when i add a await this.pauseTest()
immediately after fillIn('some search term')
, the text input is still empty and the search results don't update, but if i insert a debugger
the search input and results work exactly as expected. so there's something going on with timing here.
unfortunately since the execution of the opsFilter
function (aka our custom search function) happens outside of our context (within the source code of swagger-ui-dist
, it's difficult to debug. my thoughts were exactly what you mentioned -- if our search function errors, the whole page breaks, and so asserting that the search input gets entered correctly tells us that the page is "working" (for the most part). π
i'll update my comment in the code here to make that more clear, though!
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.
Great work tracking this down! Thanks for the additional comments and test coverage π€©
6144533
to
b48138e
Compare
π οΈ Description
Fixes the search filter on the OpenAPI explorer.
π Links
πΈ Screenshots
Screen.Recording.2024-04-26.at.11.51.48.AM.mov
ποΈ How to Build and Test the Change
Visit the OpenApi explorer page and the search box should work again π