Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(resource): fix search list fields to allow empty pipeline #763

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading