Skip to content

[CDX-501] Add support for refined filters as top level URL parameters in browse results - #265

Open
Alexey-Pavlov wants to merge 1 commit into
masterfrom
cdx-501-node-sdk-add-refined_filters-support
Open

[CDX-501] Add support for refined filters as top level URL parameters in browse results#265
Alexey-Pavlov wants to merge 1 commit into
masterfrom
cdx-501-node-sdk-add-refined_filters-support

Conversation

@Alexey-Pavlov

Copy link
Copy Markdown
Contributor

This pull request enhances how refined filters are handled in the browse module by sending them as top-level URL parameters instead of nesting them within the qs parameter. It also introduces comprehensive tests to ensure this behavior and to verify that the original input is not mutated.

Refined filter handling improvements:

  • Updated createQueryParams in src/modules/browse.js to extract refined_filters from the qsParam object and send them as top-level parameters in the URL, while any remaining qsParam values are still sent under qs. This ensures proper API parameter structure and avoids unnecessary nesting.

Testing enhancements:

  • Added tests in spec/src/modules/browse.js to verify:
    • refined_filters are sent as top-level parameters when supplied in qsParam.
    • Other qsParam values are retained and sent correctly under qs when refined_filters is present.
    • The original qsParam object is not mutated during processing.

@Alexey-Pavlov
Alexey-Pavlov requested a review from a team August 7, 2026 10:39
@Alexey-Pavlov
Alexey-Pavlov requested a review from a team as a code owner August 7, 2026 10:39
Copilot AI review requested due to automatic review settings August 7, 2026 10:39

@constructor-claude-bedrock constructor-claude-bedrock Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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: ⚠️ Needs Work

fetch: fetchSpy,
});

browse.getBrowseResults(filterName, filterValue, { qsParam }).then((res) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 createQueryParams in src/modules/browse.js to extract refined_filters from qsParam and send it as a top-level query parameter while preserving remaining qsParam keys under qs.
  • Added browse specs to validate top-level refined_filters, retention of remaining qs payload, and non-mutation of the input qsParam.

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.

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.

2 participants