[CDX-501] Add support for refined filters as top level URL parameters in browse results - #265
[CDX-501] Add support for refined filters as top level URL parameters in browse results#265Alexey-Pavlov wants to merge 1 commit into
Conversation
… in browse results
There was a problem hiding this comment.
Code Review
This PR correctly extracts refined_filters from qsParam and promotes it to a top-level URL parameter in getBrowseResults, with good immutability handling via destructuring; the change is well-scoped and the tests cover the new behavior.
Inline comments: 4 discussions added
Overall Assessment:
| fetch: fetchSpy, | ||
| }); | ||
|
|
||
| browse.getBrowseResults(filterName, filterValue, { qsParam }).then((res) => { |
There was a problem hiding this comment.
Important Issue: All three new tests use the callback-style done pattern without a .catch() handler. If the promise rejects (e.g. network or assertion error), done is never called and the test silently times out rather than failing with a meaningful error. Add a rejection handler:
browse.getBrowseResults(filterName, filterValue, { qsParam })
.then((res) => {
// assertions...
done();
})
.catch(done);This matches the pattern already used in the surrounding existing tests in this file.
| expect(res).to.have.property('request').to.be.an('object'); | ||
| expect(requestedUrlParams).to.have.property('refined_filters'); | ||
| expect(requestedUrlParams.refined_filters).to.have.property('group_id').to.equal('BrandXY'); | ||
| expect(requestedUrlParams).to.not.have.property('qs'); |
There was a problem hiding this comment.
Suggestion: This assertion verifies that qs is absent when qsParam contains only refined_filters. Consider adding a complementary assertion that refined_filters is not nested inside a qs key (i.e. the old behaviour is definitively gone). The current assertions are correct but an explicit negative check would make the test intent clearer and catch future regressions more precisely.
There was a problem hiding this comment.
Pull request overview
Updates the browse module’s URL query construction so refined_filters provided via qsParam are promoted to a top-level URL parameter (instead of being nested inside the JSON-encoded qs param), aligning browse requests with the expected API parameter structure and avoiding unnecessary nesting.
Changes:
- Updated
createQueryParamsinsrc/modules/browse.jsto extractrefined_filtersfromqsParamand send it as a top-level query parameter while preserving remainingqsParamkeys underqs. - Added browse specs to validate top-level
refined_filters, retention of remainingqspayload, and non-mutation of the inputqsParam.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/modules/browse.js | Extracts refined_filters from qsParam and sends it as a top-level query param; only remaining qsParam content is JSON-encoded into qs. |
| spec/src/modules/browse.js | Adds coverage to assert correct URL param structure and that the input qsParam object is not mutated. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request enhances how refined filters are handled in the
browsemodule by sending them as top-level URL parameters instead of nesting them within theqsparameter. It also introduces comprehensive tests to ensure this behavior and to verify that the original input is not mutated.Refined filter handling improvements:
createQueryParamsinsrc/modules/browse.jsto extractrefined_filtersfrom theqsParamobject and send them as top-level parameters in the URL, while any remainingqsParamvalues are still sent underqs. This ensures proper API parameter structure and avoids unnecessary nesting.Testing enhancements:
spec/src/modules/browse.jsto verify:refined_filtersare sent as top-level parameters when supplied inqsParam.qsParamvalues are retained and sent correctly underqswhenrefined_filtersis present.qsParamobject is not mutated during processing.