mirror of
https://github.com/elastic/kibana.git
synced 2025-06-28 03:01:21 -04:00
Set filter to undefined when it's empty on findExceptionLists method (#128455)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
bf2769d7ee
commit
a07c47c652
2 changed files with 26 additions and 1 deletions
|
@ -231,7 +231,7 @@ const fetchExceptionLists = async ({
|
||||||
signal,
|
signal,
|
||||||
}: ApiCallFetchExceptionListsProps): Promise<FoundExceptionListSchema> => {
|
}: ApiCallFetchExceptionListsProps): Promise<FoundExceptionListSchema> => {
|
||||||
const query = {
|
const query = {
|
||||||
filter: filters,
|
filter: filters || undefined,
|
||||||
namespace_type: namespaceTypes,
|
namespace_type: namespaceTypes,
|
||||||
page: pagination.page ? `${pagination.page}` : '1',
|
page: pagination.page ? `${pagination.page}` : '1',
|
||||||
per_page: pagination.perPage ? `${pagination.perPage}` : '20',
|
per_page: pagination.perPage ? `${pagination.perPage}` : '20',
|
||||||
|
|
|
@ -278,6 +278,31 @@ describe('Exceptions Lists API', () => {
|
||||||
expect(exceptionResponse.data).toEqual([getExceptionListSchemaMock()]);
|
expect(exceptionResponse.data).toEqual([getExceptionListSchemaMock()]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('it returns expected exception lists when empty filter', async () => {
|
||||||
|
const exceptionResponse = await fetchExceptionLists({
|
||||||
|
filters: '',
|
||||||
|
http: httpMock,
|
||||||
|
namespaceTypes: 'single,agnostic',
|
||||||
|
pagination: {
|
||||||
|
page: 1,
|
||||||
|
perPage: 20,
|
||||||
|
},
|
||||||
|
signal: abortCtrl.signal,
|
||||||
|
});
|
||||||
|
expect(httpMock.fetch).toHaveBeenCalledWith('/api/exception_lists/_find', {
|
||||||
|
method: 'GET',
|
||||||
|
query: {
|
||||||
|
namespace_type: 'single,agnostic',
|
||||||
|
page: '1',
|
||||||
|
per_page: '20',
|
||||||
|
sort_field: 'exception-list.created_at',
|
||||||
|
sort_order: 'desc',
|
||||||
|
},
|
||||||
|
signal: abortCtrl.signal,
|
||||||
|
});
|
||||||
|
expect(exceptionResponse.data).toEqual([getExceptionListSchemaMock()]);
|
||||||
|
});
|
||||||
|
|
||||||
test('it returns error if response payload fails decode', async () => {
|
test('it returns error if response payload fails decode', async () => {
|
||||||
const badPayload = getExceptionListSchemaMock();
|
const badPayload = getExceptionListSchemaMock();
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue