forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Drilldowns] {{event.points}} in URL drilldown for VALUE_CLICK_TRIGGER (
elastic#76771) {{event.points}} in URL drilldown for VALUE_CLICK_TRIGGER Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
4c734e4
commit d398dbf
Showing
7 changed files
with
192 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
...k/plugins/embeddable_enhanced/public/drilldowns/url_drilldown/url_drilldown_scope.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
getEventScope, | ||
getMockEventScope, | ||
ValueClickTriggerEventScope, | ||
} from './url_drilldown_scope'; | ||
|
||
const createPoint = ({ | ||
field, | ||
value, | ||
}: { | ||
field: string; | ||
value: string | null | number | boolean; | ||
}) => ({ | ||
table: { | ||
columns: [ | ||
{ | ||
name: field, | ||
id: '1-1', | ||
meta: { | ||
type: 'histogram', | ||
indexPatternId: 'logstash-*', | ||
aggConfigParams: { | ||
field, | ||
interval: 30, | ||
otherBucket: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
rows: [ | ||
{ | ||
'1-1': '2048', | ||
}, | ||
], | ||
}, | ||
column: 0, | ||
row: 0, | ||
value, | ||
}); | ||
|
||
describe('VALUE_CLICK_TRIGGER', () => { | ||
describe('supports `points[]`', () => { | ||
test('getEventScope()', () => { | ||
const mockDataPoints = [ | ||
createPoint({ field: 'field0', value: 'value0' }), | ||
createPoint({ field: 'field1', value: 'value1' }), | ||
createPoint({ field: 'field2', value: 'value2' }), | ||
]; | ||
|
||
const eventScope = getEventScope({ | ||
data: { data: mockDataPoints }, | ||
}) as ValueClickTriggerEventScope; | ||
|
||
expect(eventScope.key).toBe('field0'); | ||
expect(eventScope.value).toBe('value0'); | ||
expect(eventScope.points).toHaveLength(mockDataPoints.length); | ||
expect(eventScope.points).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"key": "field0", | ||
"value": "value0", | ||
}, | ||
Object { | ||
"key": "field1", | ||
"value": "value1", | ||
}, | ||
Object { | ||
"key": "field2", | ||
"value": "value2", | ||
}, | ||
] | ||
`); | ||
}); | ||
|
||
test('getMockEventScope()', () => { | ||
const mockEventScope = getMockEventScope([ | ||
'VALUE_CLICK_TRIGGER', | ||
]) as ValueClickTriggerEventScope; | ||
expect(mockEventScope.points.length).toBeGreaterThan(3); | ||
expect(mockEventScope.points).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"key": "event.points.0.key", | ||
"value": "event.points.0.value", | ||
}, | ||
Object { | ||
"key": "event.points.1.key", | ||
"value": "event.points.1.value", | ||
}, | ||
Object { | ||
"key": "event.points.2.key", | ||
"value": "event.points.2.value", | ||
}, | ||
Object { | ||
"key": "event.points.3.key", | ||
"value": "event.points.3.value", | ||
}, | ||
] | ||
`); | ||
}); | ||
}); | ||
|
||
describe('handles undefined, null or missing values', () => { | ||
test('undefined or missing values are removed from the result scope', () => { | ||
const point = createPoint({ field: undefined } as any); | ||
const eventScope = getEventScope({ | ||
data: { data: [point] }, | ||
}) as ValueClickTriggerEventScope; | ||
|
||
expect('key' in eventScope).toBeFalsy(); | ||
expect('value' in eventScope).toBeFalsy(); | ||
}); | ||
|
||
test('null value stays in the result scope', () => { | ||
const point = createPoint({ field: 'field', value: null }); | ||
const eventScope = getEventScope({ | ||
data: { data: [point] }, | ||
}) as ValueClickTriggerEventScope; | ||
|
||
expect(eventScope.value).toBeNull(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.