diff --git a/src/resources/Search/Search.ts b/src/resources/Search/Search.ts index a429f6481..818a31566 100644 --- a/src/resources/Search/Search.ts +++ b/src/resources/Search/Search.ts @@ -24,10 +24,14 @@ export default class Search extends Ressource { listFields(params?: SearchListFieldsParams) { return this.api.get( - this.buildPath(`${Search.baseUrl}/fields`, { - ...params, - organizationId: params?.organizationId ?? this.api.organizationId, - }), + this.buildPath( + `${Search.baseUrl}/fields`, + { + ...params, + organizationId: params?.organizationId ?? this.api.organizationId, + }, + {skipEmptyString: false}, // otherwise we cannot use the empty pipeline (`pipeline=`) + ), ); } diff --git a/src/resources/Search/test/Search.spec.ts b/src/resources/Search/test/Search.spec.ts index 27336eb08..0fb6bb040 100644 --- a/src/resources/Search/test/Search.spec.ts +++ b/src/resources/Search/test/Search.spec.ts @@ -70,6 +70,14 @@ describe('Search', () => { ); }); + it('makes a get call to v2 search with its params to fetch the list of fields with an empty pipeline', () => { + search.listFields({viewAllContent: true, organizationId: 'my-org', pipeline: ''}); + expect(api.get).toHaveBeenCalledTimes(1); + expect(api.get).toHaveBeenCalledWith( + `${Search.baseUrl}/fields?viewAllContent=true&organizationId=my-org&pipeline=`, + ); + }); + it('adds the organizationId query param from the config if missing in the arguments', () => { const tempOrganizationId = api.organizationId; // change the value of organizationId on the mock