@@ -103,17 +103,8 @@ describe('LogsToolbar', () => {
103103
104104 let options : HTMLElement [ ] ;
105105
106- // count only has 1 option available
107- await userEvent . click ( screen . getByRole ( 'button' , { name : 'logs' } ) ) ;
108- options = screen . getAllByRole ( 'option' ) ;
109- expect ( options ) . toHaveLength ( 1 ) ;
110- expect ( options [ 0 ] ) . toHaveTextContent ( 'logs' ) ;
111- await userEvent . click ( options [ 0 ] ! ) ;
112- expect ( router . location . query . aggregateField ) . toEqual (
113- [ { groupBy : '' } , { yAxes : [ 'count(message)' ] } ] . map ( aggregateField =>
114- JSON . stringify ( aggregateField )
115- )
116- ) ;
106+ // count has no user changable argument
107+ expect ( screen . getByRole ( 'button' , { name : 'logs' } ) ) . toBeDisabled ( ) ;
117108
118109 // count unique only shows string attributes
119110 await userEvent . click ( screen . getByRole ( 'button' , { name : 'count' } ) ) ;
@@ -145,6 +136,37 @@ describe('LogsToolbar', () => {
145136 )
146137 ) ;
147138 } ) ;
139+
140+ it ( 'can add/delete visualizes' , async function ( ) {
141+ const { router} = render (
142+ < Wrapper >
143+ < LogsToolbar
144+ numberTags = { { bar : { key : 'bar' , name : 'bar' } , foo : { key : 'foo' , name : 'foo' } } }
145+ stringTags = { {
146+ message : { key : 'message' , name : 'message' } ,
147+ severity : { key : 'severity' , name : 'severity' } ,
148+ } }
149+ />
150+ </ Wrapper >
151+ ) ;
152+
153+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'count' } ) ) ;
154+ await userEvent . click ( screen . getByRole ( 'option' , { name : 'avg' } ) ) ;
155+
156+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Add Chart' } ) ) ;
157+ expect ( router . location . query . aggregateField ) . toEqual (
158+ [ { groupBy : '' } , { yAxes : [ 'avg(bar)' ] } , { yAxes : [ 'count(message)' ] } ] . map (
159+ aggregateField => JSON . stringify ( aggregateField )
160+ )
161+ ) ;
162+
163+ await userEvent . click ( screen . getAllByLabelText ( 'Remove Overlay' ) [ 0 ] ! ) ;
164+ expect ( router . location . query . aggregateField ) . toEqual (
165+ [ { groupBy : '' } , { yAxes : [ 'count(message)' ] } ] . map ( aggregateField =>
166+ JSON . stringify ( aggregateField )
167+ )
168+ ) ;
169+ } ) ;
148170 } ) ;
149171
150172 describe ( 'group by section' , ( ) => {
@@ -177,5 +199,37 @@ describe('LogsToolbar', () => {
177199 )
178200 ) ;
179201 } ) ;
202+
203+ it ( 'can add/delete group bys' , async function ( ) {
204+ const { router} = render (
205+ < Wrapper >
206+ < LogsToolbar
207+ numberTags = { { bar : { key : 'bar' , name : 'bar' } , foo : { key : 'foo' , name : 'foo' } } }
208+ stringTags = { {
209+ message : { key : 'message' , name : 'message' } ,
210+ severity : { key : 'severity' , name : 'severity' } ,
211+ } }
212+ />
213+ </ Wrapper >
214+ ) ;
215+
216+ await userEvent . click ( screen . getByRole ( 'button' , { name : '\u2014' } ) ) ;
217+ await userEvent . click ( screen . getByRole ( 'option' , { name : 'message' } ) ) ;
218+
219+ await userEvent . click ( screen . getByRole ( 'button' , { name : 'Add Group' } ) ) ;
220+ expect ( router . location . query . aggregateField ) . toEqual (
221+ [ { groupBy : 'message' } , { yAxes : [ 'count(message)' ] } , { groupBy : '' } ] . map (
222+ aggregateField => JSON . stringify ( aggregateField )
223+ )
224+ ) ;
225+
226+ await userEvent . click ( screen . getAllByLabelText ( 'Remove Column' ) [ 0 ] ! ) ;
227+ expect ( router . location . query . aggregateField ) . toEqual (
228+ // BUG: a little weird that the 2nd group by moves up to take its place
229+ [ { groupBy : '' } , { yAxes : [ 'count(message)' ] } ] . map ( aggregateField =>
230+ JSON . stringify ( aggregateField )
231+ )
232+ ) ;
233+ } ) ;
180234 } ) ;
181235} ) ;
0 commit comments