@@ -10,6 +10,8 @@ var fail = require('../assets/fail_test');
10
10
var mouseEvent = require ( '../assets/mouse_event' ) ;
11
11
var customMatchers = require ( '../assets/custom_matchers' ) ;
12
12
13
+ var LONG_TIMEOUT_INTERVAL = 5 * jasmine . DEFAULT_TIMEOUT_INTERVAL ;
14
+
13
15
14
16
describe ( 'select box and lasso' , function ( ) {
15
17
var mock = require ( '@mocks/14.json' ) ;
@@ -465,4 +467,134 @@ describe('select box and lasso', function() {
465
467
. catch ( fail )
466
468
. then ( done ) ;
467
469
} ) ;
470
+
471
+ it ( '@noCI should work on scattermapbox traces' , function ( done ) {
472
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/mapbox_bubbles-text' ) ) ;
473
+ var gd = createGraphDiv ( ) ;
474
+ var eventData ;
475
+
476
+ fig . layout . dragmode = 'select' ;
477
+ fig . config = {
478
+ mapboxAccessToken : require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN
479
+ } ;
480
+
481
+ function assertPoints ( expected ) {
482
+ var pts = eventData . points || [ ] ;
483
+
484
+ expect ( pts . length ) . toBe ( expected . length , 'selected points length' ) ;
485
+
486
+ pts . forEach ( function ( p , i ) {
487
+ var e = expected [ i ] ;
488
+ expect ( p . lon ) . toBe ( e . lon , 'selected pt lon val' ) ;
489
+ expect ( p . lat ) . toBe ( e . lat , 'selected pt lat val' ) ;
490
+ } ) ;
491
+ }
492
+
493
+ function assertRanges ( expected ) {
494
+ var ranges = ( eventData . range || { } ) . mapbox || [ ] ;
495
+ expect ( ranges ) . toBeCloseTo2DArray ( expected , 1 , 'select box range (in lon/lat)' ) ;
496
+ }
497
+
498
+ function assertLassoPoints ( expected ) {
499
+ var lassoPoints = ( eventData . lassoPoints || { } ) . mapbox || [ ] ;
500
+ expect ( lassoPoints ) . toBeCloseTo2DArray ( expected , 1 , 'lasso points (in lon/lat)' ) ;
501
+ }
502
+
503
+ Plotly . plot ( gd , fig ) . then ( function ( ) {
504
+ var selectingCnt = 0 ;
505
+ var selectedCnt = 0 ;
506
+ var deselectCnt = 0 ;
507
+
508
+ gd . once ( 'plotly_selecting' , function ( ) {
509
+ assertSelectionNodes ( 1 , 2 ) ;
510
+ selectingCnt ++ ;
511
+ } ) ;
512
+
513
+ gd . once ( 'plotly_selected' , function ( d ) {
514
+ assertSelectionNodes ( 0 , 2 ) ;
515
+ selectedCnt ++ ;
516
+ eventData = d ;
517
+ } ) ;
518
+
519
+ gd . once ( 'plotly_deselect' , function ( ) {
520
+ deselectCnt ++ ;
521
+ assertSelectionNodes ( 0 , 0 ) ;
522
+ } ) ;
523
+
524
+ drag ( [ [ 370 , 120 ] , [ 500 , 200 ] ] ) ;
525
+ assertPoints ( [ { lon : 30 , lat : 30 } ] ) ;
526
+ assertRanges ( [ [ 21.99 , 34.55 ] , [ 38.14 , 25.98 ] ] ) ;
527
+
528
+ return doubleClick ( 250 , 200 ) . then ( function ( ) {
529
+ expect ( selectingCnt ) . toBe ( 1 , 'plotly_selecting call count' ) ;
530
+ expect ( selectedCnt ) . toBe ( 1 , 'plotly_selected call count' ) ;
531
+ expect ( deselectCnt ) . toBe ( 1 , 'plotly_deselect call count' ) ;
532
+ } ) ;
533
+ } )
534
+ . then ( function ( ) {
535
+ return Plotly . relayout ( gd , 'dragmode' , 'lasso' ) ;
536
+ } )
537
+ . then ( function ( ) {
538
+ var selectingCnt = 0 ;
539
+ var selectedCnt = 0 ;
540
+ var deselectCnt = 0 ;
541
+
542
+ gd . once ( 'plotly_selecting' , function ( ) {
543
+ assertSelectionNodes ( 1 , 2 ) ;
544
+ selectingCnt ++ ;
545
+ } ) ;
546
+
547
+ gd . once ( 'plotly_selected' , function ( d ) {
548
+ assertSelectionNodes ( 0 , 2 ) ;
549
+ selectedCnt ++ ;
550
+ eventData = d ;
551
+ } ) ;
552
+
553
+ gd . once ( 'plotly_deselect' , function ( ) {
554
+ deselectCnt ++ ;
555
+ assertSelectionNodes ( 0 , 0 ) ;
556
+ } ) ;
557
+
558
+ drag ( [ [ 300 , 200 ] , [ 300 , 300 ] , [ 400 , 300 ] , [ 400 , 200 ] , [ 300 , 200 ] ] ) ;
559
+ assertPoints ( [ { lon : 20 , lat : 20 } ] ) ;
560
+ assertLassoPoints ( [
561
+ [ 13.28 , 25.97 ] , [ 13.28 , 14.33 ] , [ 25.71 , 14.33 ] , [ 25.71 , 25.97 ] , [ 13.28 , 25.97 ]
562
+ ] ) ;
563
+
564
+ return doubleClick ( 250 , 200 ) . then ( function ( ) {
565
+ expect ( selectingCnt ) . toBe ( 1 , 'plotly_selecting call count' ) ;
566
+ expect ( selectedCnt ) . toBe ( 1 , 'plotly_selected call count' ) ;
567
+ expect ( deselectCnt ) . toBe ( 1 , 'plotly_deselect call count' ) ;
568
+ } ) ;
569
+ } )
570
+ . then ( function ( ) {
571
+ // make selection handlers don't get called in 'pan' dragmode
572
+ return Plotly . relayout ( gd , 'dragmode' , 'pan' ) ;
573
+ } )
574
+ . then ( function ( ) {
575
+ var selectingCnt = 0 ;
576
+ var selectedCnt = 0 ;
577
+ var deselectCnt = 0 ;
578
+
579
+ gd . once ( 'plotly_selecting' , function ( ) {
580
+ selectingCnt ++ ;
581
+ } ) ;
582
+
583
+ gd . once ( 'plotly_selected' , function ( ) {
584
+ selectedCnt ++ ;
585
+ } ) ;
586
+
587
+ gd . once ( 'plotly_deselect' , function ( ) {
588
+ deselectCnt ++ ;
589
+ } ) ;
590
+
591
+ return doubleClick ( 250 , 200 ) . then ( function ( ) {
592
+ expect ( selectingCnt ) . toBe ( 0 , 'plotly_selecting call count' ) ;
593
+ expect ( selectedCnt ) . toBe ( 0 , 'plotly_selected call count' ) ;
594
+ expect ( deselectCnt ) . toBe ( 0 , 'plotly_deselect call count' ) ;
595
+ } ) ;
596
+ } )
597
+ . catch ( fail )
598
+ . then ( done ) ;
599
+ } , LONG_TIMEOUT_INTERVAL ) ;
468
600
} ) ;
0 commit comments