@@ -826,4 +826,60 @@ describe('legend interaction', function() {
826
826
} ) ;
827
827
} ) ;
828
828
} ) ;
829
+
830
+ describe ( 'carpet plots' , function ( ) {
831
+ afterAll ( destroyGraphDiv ) ;
832
+
833
+ function _click ( index ) {
834
+ var item = d3 . selectAll ( 'rect.legendtoggle' ) [ 0 ] [ index || 0 ] ;
835
+ return new Promise ( function ( resolve ) {
836
+ item . dispatchEvent ( new MouseEvent ( 'mousedown' ) ) ;
837
+ item . dispatchEvent ( new MouseEvent ( 'mouseup' ) ) ;
838
+ setTimeout ( resolve , DBLCLICKDELAY + 20 ) ;
839
+ } ) ;
840
+ }
841
+
842
+ function _dblclick ( index ) {
843
+ var item = d3 . selectAll ( 'rect.legendtoggle' ) [ 0 ] [ index || 0 ] ;
844
+ return new Promise ( function ( resolve ) {
845
+ item . dispatchEvent ( new MouseEvent ( 'mousedown' ) ) ;
846
+ item . dispatchEvent ( new MouseEvent ( 'mouseup' ) ) ;
847
+ item . dispatchEvent ( new MouseEvent ( 'mousedown' ) ) ;
848
+ item . dispatchEvent ( new MouseEvent ( 'mouseup' ) ) ;
849
+ setTimeout ( resolve , 20 ) ;
850
+ } ) ;
851
+ }
852
+
853
+ function assertVisible ( gd , expectation ) {
854
+ var actual = gd . _fullData . map ( function ( trace ) { return trace . visible ; } ) ;
855
+ expect ( actual ) . toEqual ( expectation ) ;
856
+ }
857
+
858
+ it ( 'should ignore carpet traces when toggling' , function ( done ) {
859
+ var _mock = Lib . extendDeep ( { } , require ( '@mocks/cheater.json' ) ) ;
860
+ var gd = createGraphDiv ( ) ;
861
+
862
+ Plotly . plot ( gd , _mock ) . then ( function ( ) {
863
+ assertVisible ( gd , [ true , true , true , true ] ) ;
864
+ } )
865
+ . then ( _click )
866
+ . then ( function ( ) {
867
+ assertVisible ( gd , [ true , 'legendonly' , true , true ] ) ;
868
+ } )
869
+ . then ( _click )
870
+ . then ( function ( ) {
871
+ assertVisible ( gd , [ true , true , true , true ] ) ;
872
+ } )
873
+ . then ( _dblclick )
874
+ . then ( function ( ) {
875
+ assertVisible ( gd , [ true , true , 'legendonly' , 'legendonly' ] ) ;
876
+ } )
877
+ . then ( _dblclick )
878
+ . then ( function ( ) {
879
+ assertVisible ( gd , [ true , true , true , true ] ) ;
880
+ } )
881
+ . catch ( fail )
882
+ . then ( done ) ;
883
+ } ) ;
884
+ } ) ;
829
885
} ) ;
0 commit comments