@@ -17,6 +17,50 @@ describe('Script Builder', () => {
1717 writeData . push ( `ndbc,air_temp_degc=70_degrees station_id_${ i } =${ i } ` )
1818 }
1919
20+ const bucketName = 'defbuck'
21+ const measurement = 'ndbc'
22+
23+ const selectSchema = ( ) => {
24+ cy . log ( 'select bucket' )
25+ cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
26+ cy . getByTestID ( 'bucket-selector--search-bar' ) . type ( bucketName )
27+ cy . getByTestID ( `bucket-selector--dropdown--${ bucketName } ` ) . click ( )
28+ cy . getByTestID ( 'bucket-selector--dropdown-button' ) . should (
29+ 'contain' ,
30+ bucketName
31+ )
32+
33+ cy . log ( 'select measurement' )
34+ cy . getByTestID ( 'measurement-selector--dropdown-button' )
35+ . should ( 'be.visible' )
36+ . should ( 'contain' , 'Select measurement' )
37+ . click ( )
38+ cy . getByTestID ( 'measurement-selector--dropdown--menu' ) . type ( measurement )
39+ cy . getByTestID ( `searchable-dropdown--item ${ measurement } ` )
40+ . should ( 'be.visible' )
41+ . click ( )
42+ cy . getByTestID ( 'measurement-selector--dropdown-button' ) . should (
43+ 'contain' ,
44+ measurement
45+ )
46+ }
47+
48+ const confirmSchemaComposition = ( ) => {
49+ cy . getByTestID ( 'flux-editor' , { timeout : 30000 } )
50+ // we set a manual delay on page load, for composition initialization
51+ // https://github.com/influxdata/ui/blob/e76f934c6af60e24c6356f4e4ce9b067e5a9d0d5/src/languageSupport/languages/flux/lsp/connection.ts#L435-L440
52+ . contains ( `from(bucket: "${ bucketName } ")` , { timeout : 30000 } )
53+ cy . getByTestID ( 'flux-editor' ) . contains (
54+ `|> filter(fn: (r) => r._measurement == "${ measurement } ")`
55+ )
56+ cy . getByTestID ( 'flux-editor' ) . contains (
57+ `|> yield(name: "_editor_composition")`
58+ )
59+ cy . getByTestID ( 'flux-editor' ) . within ( ( ) => {
60+ cy . get ( '.composition-sync--on' ) . should ( 'have.length' , 4 ) // four lines
61+ } )
62+ }
63+
2064 beforeEach ( ( ) => {
2165 cy . flush ( ) . then ( ( ) => {
2266 cy . signin ( ) . then ( ( ) => {
@@ -44,6 +88,61 @@ describe('Script Builder', () => {
4488 } )
4589 } )
4690
91+ describe ( 'Results display' , ( ) => {
92+ beforeEach ( ( ) => {
93+ window . sessionStorage . setItem (
94+ 'dataExplorer.schema' ,
95+ JSON . parse ( JSON . stringify ( DEFAULT_SCHEMA ) )
96+ )
97+ cy . setFeatureFlags ( {
98+ schemaComposition : true ,
99+ newDataExplorer : true ,
100+ } ) . then ( ( ) => {
101+ // cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override.
102+ // The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route).
103+ cy . wait ( 1200 ) . then ( ( ) => {
104+ cy . reload ( )
105+ cy . getByTestID ( 'flux-sync--toggle' )
106+ } )
107+ } )
108+
109+ cy . get ( '@org' ) . then ( ( { id} : Organization ) => {
110+ cy . intercept ( 'POST' , `/api/v2/query?orgID=${ id } ` , req => {
111+ const { extern} = req . body
112+ if (
113+ extern ?. body [ 0 ] ?. location ?. source ==
114+ `option v = { timeRangeStart: -1h,\n timeRangeStop: now()}`
115+ ) {
116+ req . alias = 'query -1h'
117+ } else if (
118+ extern ?. body [ 0 ] ?. location ?. source ==
119+ `option v = { timeRangeStart: -15m,\n timeRangeStop: now()}`
120+ ) {
121+ req . alias = 'query -15m'
122+ }
123+ } )
124+ } )
125+ } )
126+
127+ it ( 'will allow querying of different data ranges' , ( ) => {
128+ cy . getByTestID ( 'flux-editor' , { timeout : 30000 } )
129+ selectSchema ( )
130+ confirmSchemaComposition ( )
131+
132+ cy . log ( 'query with default date range of -1h' )
133+ cy . getByTestID ( 'time-machine-submit-button' ) . should ( 'exist' ) . click ( )
134+ cy . wait ( '@query -1h' )
135+
136+ cy . log ( 'query date range can be adjusted' )
137+ cy . getByTestID ( 'timerange-dropdown' ) . within ( ( ) => {
138+ cy . getByTestID ( 'dropdown--button' ) . should ( 'exist' ) . click ( )
139+ } )
140+ cy . getByTestID ( 'dropdown-item-past15m' ) . should ( 'exist' ) . click ( )
141+ cy . getByTestID ( 'time-machine-submit-button' ) . should ( 'exist' ) . click ( )
142+ cy . wait ( '@query -15m' )
143+ } )
144+ } )
145+
47146 describe ( 'Schema browser' , ( ) => {
48147 const bucketName = 'defbuck'
49148 const measurement = 'ndbc'
@@ -213,50 +312,6 @@ describe('Script Builder', () => {
213312 } )
214313 } )
215314
216- const bucketName = 'defbuck'
217- const measurement = 'ndbc'
218-
219- const selectSchema = ( ) => {
220- cy . log ( 'select bucket' )
221- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . click ( )
222- cy . getByTestID ( 'bucket-selector--search-bar' ) . type ( bucketName )
223- cy . getByTestID ( `bucket-selector--dropdown--${ bucketName } ` ) . click ( )
224- cy . getByTestID ( 'bucket-selector--dropdown-button' ) . should (
225- 'contain' ,
226- bucketName
227- )
228-
229- cy . log ( 'select measurement' )
230- cy . getByTestID ( 'measurement-selector--dropdown-button' )
231- . should ( 'be.visible' )
232- . should ( 'contain' , 'Select measurement' )
233- . click ( )
234- cy . getByTestID ( 'measurement-selector--dropdown--menu' ) . type ( measurement )
235- cy . getByTestID ( `searchable-dropdown--item ${ measurement } ` )
236- . should ( 'be.visible' )
237- . click ( )
238- cy . getByTestID ( 'measurement-selector--dropdown-button' ) . should (
239- 'contain' ,
240- measurement
241- )
242- }
243-
244- const confirmSchemaComposition = ( ) => {
245- cy . getByTestID ( 'flux-editor' , { timeout : 30000 } )
246- // we set a manual delay on page load, for composition initialization
247- // https://github.com/influxdata/ui/blob/e76f934c6af60e24c6356f4e4ce9b067e5a9d0d5/src/languageSupport/languages/flux/lsp/connection.ts#L435-L440
248- . contains ( `from(bucket: "${ bucketName } ")` , { timeout : 30000 } )
249- cy . getByTestID ( 'flux-editor' ) . contains (
250- `|> filter(fn: (r) => r._measurement == "${ measurement } ")`
251- )
252- cy . getByTestID ( 'flux-editor' ) . contains (
253- `|> yield(name: "_editor_composition")`
254- )
255- cy . getByTestID ( 'flux-editor' ) . within ( ( ) => {
256- cy . get ( '.composition-sync--on' ) . should ( 'have.length' , 4 ) // four lines
257- } )
258- }
259-
260315 describe ( 'default sync and resetting behavior:' , ( ) => {
261316 it ( 'sync defaults to on. Can be toggled on/off. And can diverge (be disabled).' , ( ) => {
262317 cy . log ( 'starts as synced' )
0 commit comments