-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathflows.cy.ts
More file actions
591 lines (486 loc) · 19.6 KB
/
flows.cy.ts
File metadata and controls
591 lines (486 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
import {Organization} from '../../../src/types'
describe('Flows', () => {
beforeEach(() => {
cy.flush()
cy.signin()
cy.get('@org').then(({id}: Organization) =>
cy.fixture('routes').then(({orgs}) => {
cy.visit(`${orgs}/${id}`)
})
)
// Double check that the new schemaComposition flag does not interfere.
cy.setFeatureFlags({
schemaComposition: true,
})
// cy.wait($time) is necessary to consistently ensure sufficient time for the feature flag override.
// The flag reset happens via redux, (it's not a network request), so we can't cy.wait($intercepted_route).
cy.wait(1200)
cy.getByTestID('version-info')
cy.getByTestID('nav-item-flows').should('be.visible')
cy.getByTestID('nav-item-flows').click()
})
it('CRUD a flow from the index page', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const now = Date.now()
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
'defbuck'
)
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input')
.clear()
.type('My Flow {enter}')
cy.wait('@updateNotebook')
// "Add Another Panel" menu is present and there is a Query Builder button
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 1)
cy.getByTestID('sidebar-button').first().click()
cy.getByTestID('Delete--list-item').click()
cy.get('.flow-divider--button').first().click()
// Opening the menu adds another Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 2)
// Click the newest Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').last().click()
cy.getByTestID('selector-list defbuck').first().click()
cy.getByTestID('selector-list test').first().click()
cy.getByTestID('time-machine-submit-button').click()
cy.getByTestID('simple-table').should('have.length', 1)
cy.getByTestID('giraffe-layer-line').should('have.length', 1)
})
it('can execute preview, see results, change tags, execute preview, see different results', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const newBucketName = 'lets goooo'
const now = Date.now()
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, newBucketName)
})
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
newBucketName
)
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input')
.clear()
.type('My Flow {enter}')
cy.wait('@updateNotebook')
// "Add Another Panel" menu is present and there is a Query Builder button
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 1)
// Delete the first panel
cy.getByTestID('sidebar-button').first().click()
cy.getByTestID('Delete--list-item').click()
cy.get('.flow-divider--button').first().click()
// Opening the menu adds another Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 2)
// Click the newest Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').last().click()
// select our bucket
cy.getByTestID('bucket-selector').within(() => {
cy.getByTestID('selector-list lets goooo').click()
})
// select measurement and field
cy.getByTestID('builder-card')
.eq(0)
.within(() => {
cy.getByTestID(`selector-list test`).click()
})
cy.getByTestID('builder-card')
.eq(1)
.within(() => {
cy.getByTestID(`selector-list dopeness`).click()
})
// select beans tag and click preview
cy.getByTestID('builder-card')
.eq(2)
.within(() => {
cy.getByTestID(`selector-list beans`).click()
})
cy.getByTestID('time-machine-submit-button').click()
// we should only see beans in the table
cy.getByTestID('simple-table').should('be.visible')
cy.getByTestID('table-cell beans').first().should('be.visible')
cy.getByTestID('table-cell cool').should('not.exist')
// change tag to cool and click preview
cy.getByTestID('builder-card')
.eq(2)
.within(() => {
cy.getByTestID(`selector-list cool`).click()
})
cy.getByTestID('time-machine-submit-button').click()
// we should only see cool in the table
cy.getByTestID('simple-table').should('be.visible')
cy.getByTestID('table-cell cool').first().should('be.visible')
})
it('can create and delete a flow from the list page', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const newBucketName = 'shmucket'
const now = Date.now()
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, newBucketName)
})
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
newBucketName
)
const flowName = 'Flowbooks'
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input')
.clear()
.type(`${flowName}{enter}`)
cy.wait('@updateNotebook')
cy.getByTestID('page-title').contains(flowName)
cy.getByTestID('sidebar-button').first().click()
cy.getByTestID('Delete--list-item').click()
cy.wait('@updateNotebook')
cy.get('.flow-divider--button').first().click()
// Opening the menu adds another Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 2)
// Click the newest Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').last().click()
cy.wait('@updateNotebook')
// select our bucket
cy.getByTestID('bucket-selector').within(() => {
cy.getByTestID(`selector-list ${newBucketName}`).click()
})
cy.wait('@updateNotebook')
// select measurement and field
cy.getByTestID('builder-card')
.eq(0)
.within(() => {
cy.getByTestID(`selector-list test`).click()
})
cy.wait('@updateNotebook')
cy.getByTestID('builder-card')
.eq(1)
.within(() => {
cy.getByTestID(`selector-list dopeness`).click()
})
cy.wait('@updateNotebook')
// select beans tag and click preview
cy.getByTestID('builder-card')
.eq(2)
.within(() => {
cy.getByTestID(`selector-list beans`).click()
})
cy.wait('@updateNotebook')
cy.getByTestID('time-machine-submit-button').click()
// we should only see beans in the table
cy.getByTestID('simple-table').should('be.visible')
cy.getByTestID('table-cell beans').first().should('be.visible')
cy.getByTestID('table-cell cool').should('not.exist')
// This is a random validator that the autorefresh option doesn't pop up
// In Flows again without explicit changes
cy.getByTestID('autorefresh-dropdown--button').should('not.exist')
cy.clickNavBarItem('nav-item-flows')
cy.get('@org').then(({id}: Organization) =>
cy.fixture('routes').then(({orgs}) => {
cy.location('pathname').should('eq', `${orgs}/${id}/notebooks`)
})
)
cy.get('.cf-resource-card').should('have.length', 1)
cy.getByTestID('resource-editable-name').contains(`${flowName}`)
})
it('should have the same number of flow panels and no presentation panel when presentation mode is off', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const newBucketName = 'shmucket'
const now = Date.now()
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, newBucketName)
})
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
newBucketName
)
const flowName = 'Flowbooks'
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input')
.clear()
.type(`${flowName}{enter}`)
cy.wait('@updateNotebook')
// "Add Another Panel" menu is present and there is a Query Builder button
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 1)
cy.getByTestID('sidebar-button').first().click()
cy.getByTestID('Delete--list-item').click()
cy.get('.flow-divider--button').first().click()
// Opening the menu adds another Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 2)
// Click the newest Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').last().click()
// select our bucket
cy.getByTestID('bucket-selector').within(() => {
cy.getByTestID(`selector-list ${newBucketName}`).click()
})
// select measurement and field
cy.getByTestID('builder-card')
.eq(0)
.within(() => {
cy.getByTestID(`selector-list test`).click()
})
cy.getByTestID('builder-card')
.eq(1)
.within(() => {
cy.getByTestID(`selector-list dopeness`).click()
})
// select beans tag and click preview
cy.getByTestID('builder-card')
.eq(2)
.within(() => {
cy.getByTestID(`selector-list beans`).click()
})
cy.getByTestID('time-machine-submit-button').click()
// we should only see beans in the table
cy.getByTestID('simple-table').should('be.visible')
cy.getByTestID('table-cell beans').first().should('be.visible')
cy.getByTestID('table-cell cool').should('not.exist')
// there are exactly 3 Flow panels
cy.get('.flow-panel__visible').should('have.length', 3)
// exit the flow, reload, and come back in
cy.clickNavBarItem('nav-item-flows')
cy.getByTestID('tree-nav').should('be.visible')
cy.getByTestID('resource-editable-name').should('exist')
cy.getByTestID('resource-editable-name').click()
// validation and visualization should exist
cy.getByTestID('simple-table').should('exist')
cy.getByTestID('giraffe-inner-plot').should('exist')
// there are still exactly 3 flow panels and no presentation panels
cy.get('.flow-panel__visible').should('have.length', 3)
cy.get('.presentation-panel').should('not.exist')
})
it('should have a presentation panel and no flow panels when presentation mode is on', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const newBucketName = 'shmucket'
const now = Date.now()
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, newBucketName)
})
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
newBucketName
)
const flowName = 'Flowbooks'
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input')
.clear()
.type(`${flowName}{enter}`)
cy.wait('@updateNotebook')
// "Add Another Panel" menu is present and there is a Query Builder button
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 1)
cy.getByTestID('sidebar-button').first().click()
cy.getByTestID('Delete--list-item').click()
cy.get('.flow-divider--button').first().click()
// Opening the menu adds another Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').should('have.length', 2)
// Click the newest Query Builder button
cy.getByTestID('add-flow-btn--queryBuilder').last().click()
// select our bucket
cy.getByTestID('bucket-selector').within(() => {
cy.getByTestID(`selector-list ${newBucketName}`).click()
})
// select measurement and field
cy.getByTestID('builder-card')
.eq(0)
.within(() => {
cy.getByTestID(`selector-list test`).click()
})
cy.getByTestID('builder-card')
.eq(1)
.within(() => {
cy.getByTestID(`selector-list dopeness`).click()
})
// select beans tag and click preview
cy.getByTestID('builder-card')
.eq(2)
.within(() => {
cy.getByTestID(`selector-list beans`).click()
})
cy.getByTestID('time-machine-submit-button').click()
// we should only see beans in the table
cy.getByTestID('simple-table').should('be.visible')
cy.getByTestID('table-cell beans').first().should('be.visible')
cy.getByTestID('table-cell cool').should('not.exist')
// there are exactly 3 Flow panels before turning on presentation mode
cy.get('.flow-panel__visible').should('have.length', 3)
// enable presentation mode
cy.getByTestID('slide-toggle').click()
// exit the flow, reload, and come back in
cy.clickNavBarItem('nav-item-flows')
cy.getByTestID('tree-nav').should('be.visible')
cy.getByTestID('resource-editable-name').should('exist')
cy.getByTestID('resource-editable-name').click()
// visualization should exist but not validation
cy.getByTestID('simple-table').should('not.exist')
cy.getByTestID('giraffe-inner-plot').should('be.visible')
// there are no flow panels and exactly 1 presentation panel
cy.get('.flow-panel__visible').should('have.length', 0)
cy.get('.presentation-panel').should('have.length', 1)
cy.get('.presentation-panel').should('be.visible')
})
it('should have certain dropdown menu items', () => {
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
const defaultMenuItems = ['Delete', 'Duplicate', 'Hide Panel']
const items = [
{
panel: 'queryBuilder',
menuItems: [
...defaultMenuItems,
'Convert to |> Flux',
'Export to Client Library',
'Link to Source',
'Link to Results',
'Link to Panel',
],
},
{
panel: 'rawFluxEditor',
menuItems: [
...defaultMenuItems,
'Export to Client Library',
'Link to Source',
'Link to Results',
'Link to Panel',
],
},
{
panel: 'table',
menuItems: [...defaultMenuItems, 'Download as CSV', 'Link to Panel'],
},
{
panel: 'visualization',
menuItems: [...defaultMenuItems, 'Download as CSV', 'Link to Panel'],
},
{
panel: 'markdown',
menuItems: [...defaultMenuItems, 'Link to Panel'],
},
{
panel: 'notification',
menuItems: [...defaultMenuItems, 'Link to Panel'],
},
{
panel: 'schedule',
menuItems: [...defaultMenuItems, 'Link to Panel'],
},
]
// Intercepts
cy.intercept('/api/v2/orgs/*/secrets').as('fetchSecrets')
items.forEach(item => {
cy.get('.flow-divider--button').first().click()
// "Add Another Panel" menu is present and there is a duplicate of each button
cy.get('.insert-cell-menu.always-on').contains('Add Another Panel')
cy.getByTestID(`add-flow-btn--${item.panel}`).should('have.length', 2)
// Click the newest button from opening the panel button
cy.get('.insert-cell-menu.always-on').within(() => {
cy.getByTestID(`add-flow-btn--${item.panel}`).last().click()
if (item.panel === 'notification') {
cy.wait('@fetchSecrets')
}
})
cy.getByTestID('sidebar-button').last().click()
cy.getByTestID('dropdown-menu').should('be.visible')
cy.getByTestID('dropdown-menu--contents')
.find('.flow-sidebar--dropdownmenu-container')
.children()
.should('have.length.gte', item.menuItems.length)
item.menuItems.forEach(menuItem => {
cy.getByTestID(`${menuItem}--list-item`).should('be.visible')
})
})
})
it('can create a Band plot without crashing', () => {
cy.intercept('PATCH', '/api/v2private/notebooks/*').as('updateNotebook')
const newBucketName = 'lets goooo'
const now = Date.now()
cy.get<Organization>('@org').then(({id, name}: Organization) => {
cy.createBucket(id, name, newBucketName)
})
cy.writeData(
[
`test,container_name=cool dopeness=12 ${now - 1000}000000`,
`test,container_name=beans dopeness=18 ${now - 1200}000000`,
`test,container_name=cool dopeness=14 ${now - 1400}000000`,
`test,container_name=beans dopeness=10 ${now - 1600}000000`,
],
newBucketName
)
cy.getByTestID('preset-new').first().click()
cy.getByTestID('time-machine-submit-button').should('be.visible')
cy.getByTestID('page-title').first().click()
cy.getByTestID('renamable-page-title--input').type(
'I am not afraid of Band Plot {enter}'
)
cy.wait('@updateNotebook')
// select our bucket
cy.getByTestID('bucket-selector').within(() => {
cy.getByTestID('selector-list lets goooo').click()
})
// select measurement and field
cy.getByTestID('builder-card')
.eq(0)
.within(() => {
cy.getByTestID(`selector-list test`).click()
})
cy.getByTestID('builder-card')
.eq(1)
.within(() => {
cy.getByTestID(`selector-list dopeness`).click()
})
cy.get('input.flow-panel--title-input')
.eq(1)
.should('have.value', 'Validate the Data')
cy.getByTestID('sidebar-button').eq(1).click()
cy.get('button.cf-dropdown-item[title="Delete"]')
.should('be.visible')
.click()
cy.get('input.flow-panel--title-input')
.eq(1)
.should('have.value', 'Visualize the Result')
cy.getByTestID('view-type--dropdown').click()
cy.getByTestID('view-type--band').click()
cy.get(
'.flow-panel--persistent-control > button.cf-button[title="Run"]'
).click()
cy.getByTestID('giraffe-layer-band-chart').should('be.visible')
cy.get('button.cf-button[title="Configure Visualization"]').click()
cy.getByTestID('dropdown--button-main-column').within(() => {
cy.get('.cf-dropdown--selected').contains('_result')
})
})
})