Skip to content

Commit

Permalink
fix(headless): forward headless commerce category facet retrieve count (
Browse files Browse the repository at this point in the history
#4420)

In commerce category facets, the `retrieveCount` property is ignored by
the `toggleSelect` method. To fix this, we extract it from the selection
and pass it in to the action.

Opening this as a temporary fix, but will try to fix this properly by
overriding the `toggleSelect` on the category facet controller in a
later PR.

[MHUB-1790]

[MHUB-1790]:
https://coveord.atlassian.net/browse/MHUB-1790?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
  • Loading branch information
Spuffynism authored Sep 17, 2024
1 parent e5bf6b8 commit 44b5871
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,19 @@ describe('CoreCommerceFacet', () => {
facet.toggleSelect(facetValue());
expect(fetchProductsActionCreator).toHaveBeenCalled();
});

it('sets retrieveCount when provided in selection', () => {
const selection = {
...facetValue(),
retrieveCount: 30,
};
facet.toggleSelect(selection);
expect(toggleSelectActionCreator).toHaveBeenCalledWith({
facetId,
selection,
retrieveCount: 30,
});
});
});

describe('#toggleExclude', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ export function buildCoreCommerceFacet<
props.options.toggleSelectActionCreator({
selection,
facetId,
...('retrieveCount' in selection
? {retrieveCount: selection.retrieveCount}
: {}),
})
);
dispatch(props.options.fetchProductsActionCreator());
Expand Down

0 comments on commit 44b5871

Please sign in to comment.