Query history: Fix search filtering if null value (#26768)

* Fix filtering if null value

* Add test coverage
This commit is contained in:
Ivana Huckova 2020-08-04 11:03:22 +02:00 committed by GitHub
parent 353b3822c1
commit 6a86e66d76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -20,7 +20,7 @@ const mock: any = {
datasourceId: 'datasource historyId',
datasourceName: 'datasource history name',
queries: [
{ expr: 'query1', refId: '1' },
{ expr: 'query1', maxLines: null, refId: '1' },
{ expr: 'query2', refId: '2' },
],
sessionName: '',
@ -96,7 +96,7 @@ describe('addToRichHistory', () => {
mock.storedHistory,
mock.storedHistory[0].datasourceId,
mock.storedHistory[0].datasourceName,
[{ expr: 'query1', refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
[{ expr: 'query1', maxLines: null, refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
mock.testStarred,
mock.testComment,
mock.testSessionName
@ -110,7 +110,7 @@ describe('addToRichHistory', () => {
mock.storedHistory,
mock.storedHistory[0].datasourceId,
mock.storedHistory[0].datasourceName,
[{ expr: 'query1', refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
[{ expr: 'query1', maxLines: null, refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery],
mock.testStarred,
mock.testComment,
mock.testSessionName

View File

@ -330,7 +330,7 @@ export function filterQueriesBySearchFilter(queries: RichHistoryQuery[], searchF
const listOfMatchingQueries = query.queries.filter(query =>
// Remove fields in which we don't want to be searching
Object.values(_.omit(query, ['datasource', 'key', 'refId', 'hide', 'queryType'])).some((value: any) =>
value.toString().includes(searchFilter)
value?.toString().includes(searchFilter)
)
);