Skip to content

Commit

Permalink
fix(resource): fix search list fields to allow empty pipeline (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
aboissinot-coveo authored Nov 2, 2023
1 parent 87d52da commit b9cd9d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/resources/Search/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ export default class Search extends Ressource {

listFields(params?: SearchListFieldsParams) {
return this.api.get<SearchListFieldsResponse>(
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=`)
),
);
}

Expand Down
8 changes: 8 additions & 0 deletions src/resources/Search/test/Search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9cd9d1

Please sign in to comment.