@@ -27,6 +27,145 @@ import { mountWithIntl } from 'test_utils/enzyme_helpers';
27
27
28
28
const executeTriggerActions = jest . fn ( ) ;
29
29
30
+ const dateHistogramData : LensMultiTable = {
31
+ type : 'lens_multitable' ,
32
+ tables : {
33
+ timeLayer : {
34
+ type : 'kibana_datatable' ,
35
+ rows : [
36
+ {
37
+ xAccessorId : 1585758120000 ,
38
+ splitAccessorId : "Men's Clothing" ,
39
+ yAccessorId : 1 ,
40
+ } ,
41
+ {
42
+ xAccessorId : 1585758360000 ,
43
+ splitAccessorId : "Women's Accessories" ,
44
+ yAccessorId : 1 ,
45
+ } ,
46
+ {
47
+ xAccessorId : 1585758360000 ,
48
+ splitAccessorId : "Women's Clothing" ,
49
+ yAccessorId : 1 ,
50
+ } ,
51
+ {
52
+ xAccessorId : 1585759380000 ,
53
+ splitAccessorId : "Men's Clothing" ,
54
+ yAccessorId : 1 ,
55
+ } ,
56
+ {
57
+ xAccessorId : 1585759380000 ,
58
+ splitAccessorId : "Men's Shoes" ,
59
+ yAccessorId : 1 ,
60
+ } ,
61
+ {
62
+ xAccessorId : 1585759380000 ,
63
+ splitAccessorId : "Women's Clothing" ,
64
+ yAccessorId : 1 ,
65
+ } ,
66
+ {
67
+ xAccessorId : 1585760700000 ,
68
+ splitAccessorId : "Men's Clothing" ,
69
+ yAccessorId : 1 ,
70
+ } ,
71
+ {
72
+ xAccessorId : 1585760760000 ,
73
+ splitAccessorId : "Men's Clothing" ,
74
+ yAccessorId : 1 ,
75
+ } ,
76
+ {
77
+ xAccessorId : 1585760760000 ,
78
+ splitAccessorId : "Men's Shoes" ,
79
+ yAccessorId : 1 ,
80
+ } ,
81
+ {
82
+ xAccessorId : 1585761120000 ,
83
+ splitAccessorId : "Men's Shoes" ,
84
+ yAccessorId : 1 ,
85
+ } ,
86
+ ] ,
87
+ columns : [
88
+ {
89
+ id : 'xAccessorId' ,
90
+ name : 'order_date per minute' ,
91
+ meta : {
92
+ type : 'date_histogram' ,
93
+ indexPatternId : 'indexPatternId' ,
94
+ aggConfigParams : {
95
+ field : 'order_date' ,
96
+ timeRange : { from : '2020-04-01T16:14:16.246Z' , to : '2020-04-01T17:15:41.263Z' } ,
97
+ useNormalizedEsInterval : true ,
98
+ scaleMetricValues : false ,
99
+ interval : '1m' ,
100
+ drop_partials : false ,
101
+ min_doc_count : 0 ,
102
+ extended_bounds : { } ,
103
+ } ,
104
+ } ,
105
+ formatHint : { id : 'date' , params : { pattern : 'HH:mm' } } ,
106
+ } ,
107
+ {
108
+ id : 'splitAccessorId' ,
109
+ name : 'Top values of category.keyword' ,
110
+ meta : {
111
+ type : 'terms' ,
112
+ indexPatternId : 'indexPatternId' ,
113
+ aggConfigParams : {
114
+ field : 'category.keyword' ,
115
+ orderBy : 'yAccessorId' ,
116
+ order : 'desc' ,
117
+ size : 3 ,
118
+ otherBucket : false ,
119
+ otherBucketLabel : 'Other' ,
120
+ missingBucket : false ,
121
+ missingBucketLabel : 'Missing' ,
122
+ } ,
123
+ } ,
124
+ formatHint : {
125
+ id : 'terms' ,
126
+ params : {
127
+ id : 'string' ,
128
+ otherBucketLabel : 'Other' ,
129
+ missingBucketLabel : 'Missing' ,
130
+ parsedUrl : {
131
+ origin : 'http://localhost:5601' ,
132
+ pathname : '/jiy/app/kibana' ,
133
+ basePath : '/jiy' ,
134
+ } ,
135
+ } ,
136
+ } ,
137
+ } ,
138
+ {
139
+ id : 'yAccessorId' ,
140
+ name : 'Count of records' ,
141
+ meta : {
142
+ type : 'count' ,
143
+ indexPatternId : 'indexPatternId' ,
144
+ aggConfigParams : { } ,
145
+ } ,
146
+ formatHint : { id : 'number' } ,
147
+ } ,
148
+ ] ,
149
+ } ,
150
+ } ,
151
+ dateRange : {
152
+ fromDate : new Date ( '2020-04-01T16:14:16.246Z' ) ,
153
+ toDate : new Date ( '2020-04-01T17:15:41.263Z' ) ,
154
+ } ,
155
+ } ;
156
+
157
+ const dateHistogramLayer : LayerArgs = {
158
+ layerId : 'timeLayer' ,
159
+ hide : false ,
160
+ xAccessor : 'xAccessorId' ,
161
+ yScaleType : 'linear' ,
162
+ xScaleType : 'time' ,
163
+ isHistogram : true ,
164
+ splitAccessor : 'splitAccessorId' ,
165
+ seriesType : 'bar_stacked' ,
166
+ accessors : [ 'yAccessorId' ] ,
167
+ } ;
168
+
30
169
const createSampleDatatableWithRows = ( rows : KibanaDatatableRow [ ] ) : KibanaDatatable => ( {
31
170
type : 'kibana_datatable' ,
32
171
columns : [
@@ -284,7 +423,7 @@ describe('xy_expression', () => {
284
423
Object {
285
424
"max": 1546491600000,
286
425
"min": 1546405200000,
287
- "minInterval": 1728000 ,
426
+ "minInterval": undefined ,
288
427
}
289
428
` ) ;
290
429
} ) ;
@@ -449,6 +588,39 @@ describe('xy_expression', () => {
449
588
expect ( component . find ( Settings ) . prop ( 'rotation' ) ) . toEqual ( 90 ) ;
450
589
} ) ;
451
590
591
+ test ( 'onBrushEnd returns correct context data for date histogram data' , ( ) => {
592
+ const { args } = sampleArgs ( ) ;
593
+
594
+ const wrapper = mountWithIntl (
595
+ < XYChart
596
+ data = { dateHistogramData }
597
+ args = { {
598
+ ...args ,
599
+ layers : [ dateHistogramLayer ] ,
600
+ } }
601
+ formatFactory = { getFormatSpy }
602
+ timeZone = "UTC"
603
+ chartTheme = { { } }
604
+ histogramBarTarget = { 50 }
605
+ executeTriggerActions = { executeTriggerActions }
606
+ />
607
+ ) ;
608
+
609
+ wrapper
610
+ . find ( Settings )
611
+ . first ( )
612
+ . prop ( 'onBrushEnd' ) ! ( 1585757732783 , 1585758880838 ) ;
613
+
614
+ expect ( executeTriggerActions ) . toHaveBeenCalledWith ( 'SELECT_RANGE_TRIGGER' , {
615
+ data : {
616
+ column : 0 ,
617
+ table : dateHistogramData . tables . timeLayer ,
618
+ range : [ 1585757732783 , 1585758880838 ] ,
619
+ } ,
620
+ timeFieldName : 'order_date' ,
621
+ } ) ;
622
+ } ) ;
623
+
452
624
test ( 'onElementClick returns correct context data' , ( ) => {
453
625
const geometry : GeometryValue = { x : 5 , y : 1 , accessor : 'y1' , mark : null } ;
454
626
const series = {
0 commit comments