@@ -22,7 +22,7 @@ describe('Legends', () => {
2222 cy . createMapVariable ( id )
2323 cy . fixture ( 'routes' ) . then ( ( { orgs, explorer} ) => {
2424 cy . visit ( `${ orgs } /${ id } ${ explorer } ` )
25- cy . getByTestID ( 'tree-nav' )
25+ cy . getByTestID ( 'tree-nav' ) . should ( 'be.visible' )
2626 } )
2727 } )
2828 } )
@@ -416,7 +416,7 @@ describe('Legends', () => {
416416 cy . fixture ( 'routes' ) . then ( ( { orgs} ) => {
417417 cy . get ( '@org' ) . then ( ( { id} : Organization ) => {
418418 cy . visit ( `${ orgs } /${ id } /dashboards-list` )
419- cy . getByTestID ( 'tree-nav' )
419+ cy . getByTestID ( 'tree-nav' ) . should ( 'be.visible' )
420420 } )
421421 } )
422422 } )
@@ -555,4 +555,109 @@ describe('Legends', () => {
555555 )
556556 } )
557557 } )
558+
559+ describe ( 'in Notebooks' , ( ) => {
560+ beforeEach ( ( ) => {
561+ cy . flush ( )
562+ cy . signin ( )
563+ cy . get ( '@org' ) . then ( ( { id} : Organization ) => {
564+ cy . createMapVariable ( id )
565+ cy . fixture ( 'routes' ) . then ( ( { orgs, notebooks} ) => {
566+ cy . visit ( `${ orgs } /${ id } ${ notebooks } ` )
567+ cy . getByTestID ( 'tree-nav' ) . should ( 'be.visible' )
568+ } )
569+ } )
570+ } )
571+
572+ it ( 'allows the user to toggle the hover legend and static legend' , ( ) => {
573+ cy . intercept ( 'PATCH' , '/api/v2private/notebooks/*' ) . as ( 'updateNotebook' )
574+ cy . writeData ( points ( 100 ) )
575+ const bucketName = 'defbuck'
576+
577+ cy . getByTestID ( 'preset-new' )
578+ . first ( )
579+ . click ( )
580+
581+ cy . getByTestID ( 'time-machine-submit-button' ) . should ( 'be.visible' )
582+
583+ // Delete 2 panels and leave "Visualize the Result"
584+ cy . getByTestID ( 'sidebar-button' )
585+ . first ( )
586+ . click ( )
587+ cy . getByTestID ( 'Delete--list-item' ) . click ( )
588+ cy . wait ( '@updateNotebook' )
589+
590+ cy . getByTestID ( 'sidebar-button' )
591+ . first ( )
592+ . click ( )
593+ cy . getByTestID ( 'Delete--list-item' ) . click ( )
594+ cy . wait ( '@updateNotebook' )
595+
596+ cy . get ( '.flow-panel__visible' ) . should ( 'have.length' , 1 )
597+
598+ // Add the Query Builder
599+ cy . get ( '.flow-divider--button' )
600+ . first ( )
601+ . click ( )
602+
603+ // Opening the menu adds another Query Builder button
604+ cy . getByTestID ( 'add-flow-btn--queryBuilder' ) . should ( 'have.length' , 2 )
605+
606+ // Click the newest Query Builder button
607+ cy . getByTestID ( 'add-flow-btn--queryBuilder' )
608+ . last ( )
609+ . click ( )
610+ cy . wait ( '@updateNotebook' )
611+
612+ cy . getByTestID ( 'bucket-selector' ) . within ( ( ) => {
613+ cy . getByTestID ( `selector-list ${ bucketName } ` ) . click ( )
614+ } )
615+ cy . wait ( '@updateNotebook' )
616+
617+ cy . getByTestID ( 'builder-card' )
618+ . eq ( 0 )
619+ . within ( ( ) => {
620+ cy . getByTestID ( `selector-list m` ) . click ( )
621+ } )
622+ cy . wait ( '@updateNotebook' )
623+
624+ cy . getByTestID ( 'builder-card' )
625+ . eq ( 1 )
626+ . within ( ( ) => {
627+ cy . getByTestID ( `selector-list v` ) . click ( )
628+ } )
629+ cy . wait ( '@updateNotebook' )
630+
631+ cy . getByTestID ( 'builder-card' )
632+ . eq ( 2 )
633+ . within ( ( ) => {
634+ cy . getByTestID ( `selector-list tv1` ) . click ( )
635+ } )
636+ cy . wait ( '@updateNotebook' )
637+
638+ cy . getByTestID ( 'time-machine-submit-button' ) . click ( )
639+ cy . get ( 'button.flows-config-visualization-button' ) . click ( )
640+
641+ cy . get ( '.flow-sidebar' ) . should ( 'be.visible' )
642+ cy . getByTestID ( 'hover-legend-toggle' ) . scrollIntoView ( )
643+
644+ // Toggling any legend triggers an api call to update the Notebook spec
645+ // Hover Legend starts as Show and is toggleable
646+ cy . get ( 'label[for="radio_hover_legend_hide"' ) . click ( )
647+ cy . wait ( '@updateNotebook' )
648+
649+ cy . get ( 'label[for="radio_hover_legend_show"' ) . click ( )
650+ cy . wait ( '@updateNotebook' )
651+
652+ // Static Legend starts as Hide and is toggleable
653+ cy . get ( 'label[for="radio_static_legend_show"' ) . click ( )
654+ cy . wait ( '@updateNotebook' )
655+ cy . get ( '.insert-cell-menu.always-on' ) . scrollIntoView ( )
656+ cy . getByTestID ( 'giraffe-static-legend' ) . should ( 'be.visible' )
657+
658+ cy . get ( 'label[for="radio_static_legend_hide"' ) . click ( )
659+ cy . wait ( '@updateNotebook' )
660+ cy . getByTestID ( 'giraffe-static-legend' ) . should ( 'not.exist' )
661+ } )
662+ } )
558663} )
0 commit comments