@@ -6,7 +6,7 @@ var doubleClick = require('../assets/double_click');
66
77var createGraphDiv = require ( '../assets/create_graph_div' ) ;
88var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
9- var fail = require ( '../assets/fail_test' ) ;
9+ var failTest = require ( '../assets/fail_test' ) ;
1010var mouseEvent = require ( '../assets/mouse_event' ) ;
1111var touchEvent = require ( '../assets/touch_event' ) ;
1212
@@ -190,7 +190,7 @@ describe('@flaky Test select box and lasso in general:', function() {
190190 . then ( function ( ) {
191191 expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
192192 } )
193- . catch ( fail )
193+ . catch ( failTest )
194194 . then ( done ) ;
195195 } ) ;
196196
@@ -282,7 +282,7 @@ describe('@flaky Test select box and lasso in general:', function() {
282282 . then ( function ( ) {
283283 expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
284284 } )
285- . catch ( fail )
285+ . catch ( failTest )
286286 . then ( done ) ;
287287 } ) ;
288288
@@ -336,7 +336,7 @@ describe('@flaky Test select box and lasso in general:', function() {
336336 . then ( function ( ) {
337337 expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
338338 } )
339- . catch ( fail )
339+ . catch ( failTest )
340340 . then ( done ) ;
341341 } ) ;
342342
@@ -355,7 +355,7 @@ describe('@flaky Test select box and lasso in general:', function() {
355355 . then ( function ( ) {
356356 expect ( gd . data [ 0 ] . selectedpoints ) . toBeUndefined ( ) ;
357357 } )
358- . catch ( fail )
358+ . catch ( failTest )
359359 . then ( done ) ;
360360 } ) ;
361361
@@ -374,7 +374,7 @@ describe('@flaky Test select box and lasso in general:', function() {
374374 . then ( function ( ) {
375375 expect ( gd . _fullData [ 0 ] . selectedpoints ) . toBeUndefined ( ) ;
376376 } )
377- . catch ( fail )
377+ . catch ( failTest )
378378 . then ( done ) ;
379379 } ) ;
380380
@@ -408,7 +408,7 @@ describe('@flaky Test select box and lasso in general:', function() {
408408 . then ( function ( ) {
409409 expect ( doubleClickData ) . toBe ( null , 'with the correct deselect data' ) ;
410410 } )
411- . catch ( fail )
411+ . catch ( failTest )
412412 . then ( done ) ;
413413 } ) ;
414414 } ) ;
@@ -488,7 +488,7 @@ describe('@flaky Test select box and lasso in general:', function() {
488488 . then ( function ( ) {
489489 checkPointCount ( 0 , '(multiple invisible traces lasso)' ) ;
490490 } )
491- . catch ( fail )
491+ . catch ( failTest )
492492 . then ( done ) ;
493493 } ) ;
494494
@@ -527,7 +527,7 @@ describe('@flaky Test select box and lasso in general:', function() {
527527 expect ( selectedData . points [ 0 ] . x ) . toBe ( 0 ) ;
528528 expect ( selectedData . points [ 0 ] . y ) . toBe ( 0 ) ;
529529 } )
530- . catch ( fail )
530+ . catch ( failTest )
531531 . then ( done ) ;
532532 } ) ;
533533
@@ -549,7 +549,7 @@ describe('@flaky Test select box and lasso in general:', function() {
549549 . then ( function ( ) {
550550 assertSelectionNodes ( 0 , 0 ) ;
551551 } )
552- . catch ( fail )
552+ . catch ( failTest )
553553 . then ( done ) ;
554554 } ) ;
555555} ) ;
@@ -730,7 +730,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
730730 LASSOEVENTS , 'scatterternary lasso after relayout'
731731 ) ;
732732 } )
733- . catch ( fail )
733+ . catch ( failTest )
734734 . then ( done ) ;
735735 } ) ;
736736
@@ -766,7 +766,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
766766 null , LASSOEVENTS , 'scattercarpet lasso'
767767 ) ;
768768 } )
769- . catch ( fail )
769+ . catch ( failTest )
770770 . then ( done ) ;
771771 } ) ;
772772
@@ -823,7 +823,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
823823 [ [ 370 , 120 ] , [ 500 , 200 ] ] , null , null , NOEVENTS , 'scattermapbox pan'
824824 ) ;
825825 } )
826- . catch ( fail )
826+ . catch ( failTest )
827827 . then ( done ) ;
828828 } , LONG_TIMEOUT_INTERVAL ) ;
829829
@@ -889,7 +889,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
889889 [ [ 370 , 120 ] , [ 500 , 200 ] ] , null , null , NOEVENTS , 'scattergeo pan'
890890 ) ;
891891 } )
892- . catch ( fail )
892+ . catch ( failTest )
893893 . then ( done ) ;
894894 } , LONG_TIMEOUT_INTERVAL ) ;
895895
@@ -927,7 +927,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
927927 LASSOEVENTS , 'scatterpolar lasso'
928928 ) ;
929929 } )
930- . catch ( fail )
930+ . catch ( failTest )
931931 . then ( done ) ;
932932 } ) ;
933933
@@ -990,7 +990,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
990990 [ [ 370 , 120 ] , [ 500 , 200 ] ] , null , [ 280 , 190 ] , NOEVENTS , 'choropleth pan'
991991 ) ;
992992 } )
993- . catch ( fail )
993+ . catch ( failTest )
994994 . then ( done ) ;
995995 } , LONG_TIMEOUT_INTERVAL ) ;
996996
@@ -1063,7 +1063,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
10631063 null , BOXEVENTS , 'bar select'
10641064 ) ;
10651065 } )
1066- . catch ( fail )
1066+ . catch ( failTest )
10671067 . then ( done ) ;
10681068 } ) ;
10691069
@@ -1123,7 +1123,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
11231123 null , BOXEVENTS , 'date/category select'
11241124 ) ;
11251125 } )
1126- . catch ( fail )
1126+ . catch ( failTest )
11271127 . then ( done ) ;
11281128 } ) ;
11291129
@@ -1172,7 +1172,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
11721172 null , BOXEVENTS , 'histogram select'
11731173 ) ;
11741174 } )
1175- . catch ( fail )
1175+ . catch ( failTest )
11761176 . then ( done ) ;
11771177 } ) ;
11781178
@@ -1236,7 +1236,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
12361236 null , BOXEVENTS , 'box select'
12371237 ) ;
12381238 } )
1239- . catch ( fail )
1239+ . catch ( failTest )
12401240 . then ( done ) ;
12411241 } ) ;
12421242
@@ -1299,10 +1299,77 @@ describe('@flaky Test select box and lasso per trace:', function() {
12991299 null , BOXEVENTS , 'violin select'
13001300 ) ;
13011301 } )
1302- . catch ( fail )
1302+ . catch ( failTest )
13031303 . then ( done ) ;
13041304 } ) ;
13051305
1306+ [ 'ohlc' , 'candlestick' ] . forEach ( function ( type ) {
1307+ it ( 'should work for ' + type + ' traces' , function ( done ) {
1308+ var assertPoints = makeAssertPoints ( [ 'curveNumber' , 'x' , 'open' , 'high' , 'low' , 'close' ] ) ;
1309+ var assertSelectedPoints = makeAssertSelectedPoints ( ) ;
1310+ var assertRanges = makeAssertRanges ( ) ;
1311+ var assertLassoPoints = makeAssertLassoPoints ( ) ;
1312+ var l0 = 275 ;
1313+ var lv0 = '2011-01-03 18:00' ;
1314+ var r0 = 325 ;
1315+ var rv0 = '2011-01-04 06:00' ;
1316+ var l1 = 75 ;
1317+ var lv1 = '2011-01-01 18:00' ;
1318+ var r1 = 125 ;
1319+ var rv1 = '2011-01-02 06:00' ;
1320+ var t = 75 ;
1321+ var tv = 8 ;
1322+ var b = 325 ;
1323+ var bv = - 2 ;
1324+
1325+ Plotly . newPlot ( gd , [ {
1326+ type : type ,
1327+ x : [ '2011-01-02' , '2011-01-03' , '2011-01-04' ] ,
1328+ open : [ 1 , 2 , 3 ] ,
1329+ high : [ 3 , 4 , 5 ] ,
1330+ low : [ 0 , 1 , 2 ] ,
1331+ close : [ 0 , 3 , 2 ]
1332+ } ] , {
1333+ width : 400 ,
1334+ height : 400 ,
1335+ margin : { l : 50 , r : 50 , t : 50 , b : 50 } ,
1336+ yaxis : { range : [ - 3 , 9 ] } ,
1337+ xaxis : { rangeslider : { visible : false } } ,
1338+ dragmode : 'lasso'
1339+ } )
1340+ . then ( function ( ) {
1341+ return _run (
1342+ [ [ l0 , t ] , [ l0 , b ] , [ r0 , b ] , [ r0 , t ] , [ l0 , t ] ] ,
1343+ function ( ) {
1344+ assertPoints ( [ [ 0 , '2011-01-04' , 3 , 5 , 2 , 2 ] ] ) ;
1345+ assertSelectedPoints ( [ [ 2 ] ] ) ;
1346+ assertLassoPoints ( [
1347+ [ lv0 , lv0 , rv0 , rv0 , lv0 ] ,
1348+ [ tv , bv , bv , tv , tv ]
1349+ ] ) ;
1350+ } ,
1351+ null , LASSOEVENTS , type + ' lasso'
1352+ ) ;
1353+ } )
1354+ . then ( function ( ) {
1355+ return Plotly . relayout ( gd , 'dragmode' , 'select' ) ;
1356+ } )
1357+ . then ( function ( ) {
1358+ return _run (
1359+ [ [ l1 , t ] , [ r1 , b ] ] ,
1360+ function ( ) {
1361+ assertPoints ( [ [ 0 , '2011-01-02' , 1 , 3 , 0 , 0 ] ] ) ;
1362+ assertSelectedPoints ( [ [ 0 ] ] ) ;
1363+ assertRanges ( [ [ lv1 , rv1 ] , [ bv , tv ] ] ) ;
1364+ } ,
1365+ null , BOXEVENTS , type + ' select'
1366+ ) ;
1367+ } )
1368+ . catch ( failTest )
1369+ . then ( done ) ;
1370+ } ) ;
1371+ } ) ;
1372+
13061373 it ( 'should work on traces with enabled transforms' , function ( done ) {
13071374 var assertSelectedPoints = makeAssertSelectedPoints ( ) ;
13081375
@@ -1342,7 +1409,7 @@ describe('@flaky Test select box and lasso per trace:', function() {
13421409 BOXEVENTS , 'transformed trace select (all points selected)'
13431410 ) ;
13441411 } )
1345- . catch ( fail )
1412+ . catch ( failTest )
13461413 . then ( done ) ;
13471414 } ) ;
13481415} ) ;
@@ -1399,7 +1466,7 @@ describe('Test that selections persist:', function() {
13991466 style : [ 0.2 , 1 , 0.2 ]
14001467 } ) ;
14011468 } )
1402- . catch ( fail )
1469+ . catch ( failTest )
14031470 . then ( done ) ;
14041471 } ) ;
14051472
@@ -1445,7 +1512,7 @@ describe('Test that selections persist:', function() {
14451512 style : [ 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 0.2 , 1 , 1 , 1 ] ,
14461513 } ) ;
14471514 } )
1448- . catch ( fail )
1515+ . catch ( failTest )
14491516 . then ( done ) ;
14501517 } ) ;
14511518
@@ -1487,7 +1554,7 @@ describe('Test that selections persist:', function() {
14871554 style : [ 0.2 , 1 , 0.2 , 0.2 , 0.2 ] ,
14881555 } ) ;
14891556 } )
1490- . catch ( fail )
1557+ . catch ( failTest )
14911558 . then ( done ) ;
14921559 } ) ;
14931560} ) ;
0 commit comments