Skip to content

Commit

Permalink
fix(search-product): incremental search not limited (#2519)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Jul 28, 2023
1 parent 9e124fb commit 3dec63e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ describe('@daffodil/search-product/driver/magento | DaffSearchProductMagentoDriv
});

describe('incremental | searching for products', () => {
it('should send the limit as page size', done => {
const limit = 5;
service.incremental('query', { limit }).subscribe(result => {
done();
});

const searchOp = controller.expectOne(addTypenameToDocument(daffSearchProductIncrementalQuery()));
expect(searchOp.operation.variables.pageSize).toEqual(limit);

searchOp.flush({
data: mockSearchProductsResponse,
});
});

describe('when the call to the Magento API is successful', () => {
it('should return a collection of product search results', done => {
service.incremental('query').subscribe(result => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,12 @@ export class DaffSearchProductMagentoDriver implements DaffSearchProductDriverIn
);
}

incremental(query: string, options: DaffSearchDriverOptions = {}): Observable<DaffSearchResultCollection<DaffSearchProductResult>> {
incremental(query: string, options: DaffSearchProductDriverOptions = {}): Observable<DaffSearchResultCollection<DaffSearchProductResult>> {
return this.apollo.query<MagentoSearchProductIncrementalResponse>({
query: daffSearchProductIncrementalQuery(this.extraPreviewFragments),
variables: {
search: query,
pageSize: options.pageSize || options.limit,
},
}).pipe(
map(({ data }) => daffSearchTransformResultsToCollection(daffTransformProductsToSearchResults(
Expand Down

0 comments on commit 3dec63e

Please sign in to comment.