@@ -10,6 +10,11 @@ describe('FluxQueryBuilder', () => {
1010 cy . setFeatureFlags ( {
1111 newDataExplorer : true ,
1212 } ) . then ( ( ) => {
13+ const writeData = [ ]
14+ for ( let i = 0 ; i < 30 ; i ++ ) {
15+ writeData . push ( `ndbc,air_temp_degc=${ i } _degrees station_id=${ i } ` )
16+ }
17+ cy . writeData ( writeData , 'defbuck' )
1318 cy . wait ( 100 )
1419 cy . getByTestID ( 'flux-query-builder-toggle' ) . then ( $toggle => {
1520 cy . wrap ( $toggle ) . should ( 'be.visible' )
@@ -26,21 +31,12 @@ describe('FluxQueryBuilder', () => {
2631 } )
2732
2833 describe ( 'Schema browser' , ( ) => {
29- const bucketName = 'NOAA National Buoy Data '
34+ const bucketName = 'defbuck '
3035 const measurement = 'ndbc'
31- const searchField = 'air_temp_degc'
32- const searchTagKey = 'station_id'
33-
34- it ( 'bucket selector can search and select a bucket, then search and select a measurement' , ( ) => {
35- // no other selectors should be visible, except the bucket selector
36- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . should ( 'be.visible' )
37- cy . getByTestID ( 'measurement-selector--dropdown-button' ) . should (
38- 'not.exist'
39- )
40- cy . getByTestID ( 'field-tag-key-search-bar' ) . should ( 'not.exist' )
41- cy . getByTestID ( 'field-selector' ) . should ( 'not.exist' )
42- cy . getByTestID ( 'tag-selector-key' ) . should ( 'not.exist' )
36+ const searchTagKey = 'air_temp_degc'
37+ const searchField = 'station_id'
4338
39+ it ( 'can search buckets, measurements, fields and tag keys dynamically and loads more data when truncated' , ( ) => {
4440 // open the bucket list
4541 cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
4642
@@ -83,71 +79,59 @@ describe('FluxQueryBuilder', () => {
8379 // upon selection, will show a search bar
8480 // and a list of fields and tag keys
8581 cy . getByTestID ( 'field-tag-key-search-bar' ) . should ( 'be.visible' )
86- cy . getByTestID ( 'field-selector' ) . should ( 'be.visible' )
87- cy . getByTestID ( 'tag-selector-key' ) . should ( 'be.visible' )
88- } )
89-
90- it ( 'search bar can search fields and tag keys dynamically' , ( ) => {
91- // select a bucket
92- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
93- cy . getByTestID ( `bucket-selector--dropdown--${ bucketName } ` ) . click ( )
94-
95- // check the monaco editor is mounted to prepare for schema injection
96- cy . getByTestID ( 'flux-editor' ) . should ( 'be.visible' )
97-
98- // select a measurement
99- cy . getByTestID ( 'measurement-selector--dropdown-button' )
100- . should ( 'contain' , 'Select measurement' )
101- . click ( )
102- cy . getByTestID ( `searchable-dropdown--item ${ measurement } ` ) . click ( )
82+ cy . getByTestID ( 'field-selector' )
83+ . should ( 'be.visible' )
84+ . should ( 'not.contain' , 'Loading' )
85+ cy . getByTestID ( 'tag-selector--key' )
86+ . should ( 'be.visible' )
87+ . should ( 'not.contain' , 'Loading' )
10388
10489 // search a feild, should contain only the feild, no tag keys
10590 cy . getByTestID ( 'field-tag-key-search-bar' )
10691 . should ( 'be.visible' )
10792 . type ( searchField )
108- cy . getByTestID ( 'field-selector' ) . within ( ( ) => {
109- cy . getByTestID ( 'field-selector--list-item--selectable' ) . should (
110- 'contain' ,
111- searchField
112- )
113- } )
93+ cy . getByTestID ( 'field-selector' )
94+ . should ( 'be.visible' )
95+ . should ( 'not.contain' , 'Loading' )
96+ . should ( 'not.contain' , 'No Fields Found' )
97+ cy . getByTestID ( 'tag-selector--key' )
98+ . should ( 'be.visible' )
99+ . should ( 'not.contain' , 'Loading' )
100+ cy . getByTestID ( 'tag-selector-key' )
101+ . should ( 'be.visible' )
102+ . should ( 'contain' , 'No Tags Found' )
114103
115104 // clear the search bar
116105 cy . getByTestID ( 'dismiss-button' ) . click ( )
117106
107+ cy . getByTestID ( 'field-selector' )
108+ . should ( 'be.visible' )
109+ . should ( 'not.contain' , 'Loading' )
110+ . should ( 'not.contain' , 'No Fields Found' )
111+ cy . getByTestID ( 'tag-selector--key' )
112+ . should ( 'be.visible' )
113+ . should ( 'not.contain' , 'Loading' )
114+ cy . getByTestID ( 'tag-selector-key' )
115+ . should ( 'be.visible' )
116+ . should ( 'not.contain' , 'No Tags Found' )
117+
118118 // search a tag key, should not contain any fields
119119 cy . getByTestID ( 'field-tag-key-search-bar' )
120120 . should ( 'be.visible' )
121121 . type ( searchTagKey )
122122
123- cy . getByTestID ( 'field-selector' ) . within ( ( ) => {
124- cy . getByTestID ( 'field-selector--list-item' )
125- . should ( 'be.visible' )
126- . should ( 'contain' , 'No Fields Found' )
127- } )
123+ cy . getByTestID ( 'field-selector' )
124+ . should ( 'not.contain' , 'Loading' )
125+ . should ( 'contain' , 'No Fields Found' )
128126
129- // not recommend to assert for searchTagKey value
130- // since it will expand all the tag keys, which triggers
131- // numbers of API calls that are time consuming and unnecessary
132- } )
133-
134- it ( 'fields show all items when less than 8 items, and show "Load More" when more than 8 items' , ( ) => {
135- // if less than 8 items, show all items
136- const bucketNameA = 'Air Sensor Data'
137- const measurementA = 'airSensors'
138-
139- // select a bucket
140- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
141- cy . getByTestID ( `bucket-selector--dropdown--${ bucketNameA } ` ) . click ( )
142-
143- // check the monaco editor is mounted to prepare for schema injection
144- cy . getByTestID ( 'flux-editor' ) . should ( 'be.visible' )
127+ cy . getByTestID ( 'tag-selector--key' )
128+ . should ( 'be.visible' )
129+ . should ( 'not.contain' , 'Loading' )
130+ cy . getByTestID ( 'tag-selector-key' )
131+ . should ( 'be.visible' )
132+ . should ( 'not.contain' , 'No Tags Found' )
145133
146- // select a measurement
147- cy . getByTestID ( 'measurement-selector--dropdown-button' )
148- . should ( 'contain' , 'Select measurement' )
149- . click ( )
150- cy . getByTestID ( `searchable-dropdown--item ${ measurementA } ` ) . click ( )
134+ cy . getByTestID ( 'field-tag-key-search-bar' ) . clear ( )
151135
152136 // less than 8 items, no "Load More" button
153137 cy . getByTestID ( 'field-selector' ) . within ( ( ) => {
@@ -157,35 +141,27 @@ describe('FluxQueryBuilder', () => {
157141 cy . getByTestID ( 'field-selector--load-more-button' ) . should ( 'not.exist' )
158142 } )
159143
160- // if more than 8 items, show "Load More" button
161- // and load additional 25 items
162-
163- // select another bucket
164- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
165- cy . getByTestID ( `bucket-selector--dropdown--${ bucketName } ` ) . click ( )
166-
167- // select another measurement
168- cy . getByTestID ( 'measurement-selector--dropdown-button' )
169- . should ( 'contain' , 'Select measurement' )
170- . click ( )
171- cy . getByTestID ( `searchable-dropdown--item ${ measurement } ` ) . click ( )
172-
173144 // more than 8 items, show 'Load More' button
174- cy . getByTestID ( 'field-selector' ) . within ( ( ) => {
175- cy . getByTestID ( 'field-selector--list-item--selectable' )
176- . should ( 'be.visible' )
177- . should ( 'have.length' , 8 )
178- cy . getByTestID ( 'field-selector--load-more-button' )
179- . should ( 'be.visible' )
180- . trigger ( 'click' )
181- . then ( ( ) => {
182- // when load more is chosen, up to 25 additional entries should be shown
183- cy . getByTestID ( 'field-selector--list-item--selectable' )
184- . should ( 'be.visible' )
185- . should ( 'have.length.above' , 8 )
186- . and ( 'have.length.at.most' , 33 ) // 8 + 25
187- } )
145+ cy . getByTestID ( 'tag-selector--key' ) . within ( ( ) => {
146+ cy . get ( '.tag-selector-value--header' ) . click ( )
188147 } )
148+ cy . getByTestID ( 'tag-selector-value--list-item--selectable' )
149+ . should ( 'be.visible' )
150+ . should ( 'have.length' , 8 )
151+ cy . getByTestID ( 'tag-selector-value--load-more-button' )
152+ . should ( 'be.visible' )
153+ . trigger ( 'click' )
154+ . then ( ( ) => {
155+ // when load more is chosen, up to 25 additional entries should be shown
156+ cy . getByTestID ( 'tag-selector-value--list-item--selectable' )
157+ . should ( 'be.visible' )
158+ . should ( 'have.length.above' , 8 )
159+ . and ( 'have.length.at.most' , 33 ) // 8 + 25
160+ } )
161+
162+ // not recommend to assert for searchTagKey value
163+ // since it will expand all the tag keys, which triggers
164+ // numbers of API calls that are time consuming and unnecessary
189165 } )
190166 } )
191167} )
0 commit comments