From 0cb18df44fb4e8e73212660064084f530bffb263 Mon Sep 17 00:00:00 2001 From: Javier Pedemonte Date: Fri, 19 Jan 2024 15:10:08 -0600 Subject: [PATCH] fix: use `collectionIds` instead of `collection_ids` for fn param --- .../DiscoverySearch/__tests__/DiscoverySearch.test.tsx | 2 +- .../src/utils/__tests__/useDataApi.test.tsx | 2 +- .../discovery-react-components/src/utils/useDataApi.ts | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/discovery-react-components/src/components/DiscoverySearch/__tests__/DiscoverySearch.test.tsx b/packages/discovery-react-components/src/components/DiscoverySearch/__tests__/DiscoverySearch.test.tsx index 144b92391..aeddb0602 100644 --- a/packages/discovery-react-components/src/components/DiscoverySearch/__tests__/DiscoverySearch.test.tsx +++ b/packages/discovery-react-components/src/components/DiscoverySearch/__tests__/DiscoverySearch.test.tsx @@ -327,7 +327,7 @@ describe('DiscoverySearch', () => { expect(spy).toHaveBeenCalledWith({ projectId: 'foo', filter: 'document_id::bar', - collection_ids: ['12345-12345-12345-12345'], + collectionIds: ['12345-12345-12345-12345'], aggregation: '', passages: { enabled: false diff --git a/packages/discovery-react-components/src/utils/__tests__/useDataApi.test.tsx b/packages/discovery-react-components/src/utils/__tests__/useDataApi.test.tsx index 9cd9131e3..f782c3cf8 100644 --- a/packages/discovery-react-components/src/utils/__tests__/useDataApi.test.tsx +++ b/packages/discovery-react-components/src/utils/__tests__/useDataApi.test.tsx @@ -799,7 +799,7 @@ describe('useFetchDocumentsApi', () => { fireEvent.click(fetchDocumentsButton, { target: { value: 'filter_string' } }); expect(checkParametersMock).toHaveBeenCalledWith({ projectId: 'foo', - collection_ids: ['12345-12345-12345-12345'], + collectionIds: ['12345-12345-12345-12345'], _return: [], aggregation: '', passages: {}, diff --git a/packages/discovery-react-components/src/utils/useDataApi.ts b/packages/discovery-react-components/src/utils/useDataApi.ts index b5bd50235..e283dee03 100644 --- a/packages/discovery-react-components/src/utils/useDataApi.ts +++ b/packages/discovery-react-components/src/utils/useDataApi.ts @@ -454,9 +454,11 @@ export const useFetchDocumentsApi = ( const fetchDocuments: FetchDocumentsActions['fetchDocuments'] = useCallback( (filter, collections, callback) => { - setSearchParameters((currentSearchParameters: DiscoveryV2.QueryParams) => { - return { ...currentSearchParameters, filter, collection_ids: collections }; - }); + setSearchParameters( + (currentSearchParameters: DiscoveryV2.QueryParams): DiscoveryV2.QueryParams => { + return { ...currentSearchParameters, filter, collectionIds: collections }; + } + ); setFetchToken({ trigger: true, callback }); }, [setSearchParameters, setFetchToken]