@@ -566,3 +566,278 @@ describe('Connector Allow Drop', () => {
566
566
done ( ) ;
567
567
} ) ;
568
568
} ) ;
569
+ describe ( 'Connector Allow Drop' , ( ) => {
570
+ let diagram : Diagram ;
571
+ let ele : HTMLElement ;
572
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
573
+ beforeAll ( ( ) : void => {
574
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
575
+ if ( ! isDef ( window . performance ) ) {
576
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
577
+ this . skip ( ) ; //Skips test (in Chai)
578
+ return ;
579
+ }
580
+ ele = createElement ( 'div' , { id : 'AllowDrop' } ) ;
581
+ document . body . appendChild ( ele ) ;
582
+
583
+ let port1 = { id : "port1" , shape : "square" , offset : { x : 0 , y : 0.5 } }
584
+ let port2 = { id : "port2" , shape : "square" , offset : { x : 1 , y : 0.5 } }
585
+ let node1 : NodeModel = { id : 'node1' , width : 100 , height : 100 , offsetX : 150 , offsetY : 150 , annotations : [ { content : 'node1' } ] , } ;
586
+ let node2 : NodeModel = {
587
+ id : 'node2' , width : 100 , height : 100 , offsetX : 650 , offsetY : 150 , annotations : [ { content : 'node2' } ] ,
588
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
589
+ } ;
590
+ let node3 = {
591
+ id : 'node3' , width : 100 , height : 100 , offsetX : 490 , offsetY : 290 , annotations : [ { content : 'node3' } ] ,
592
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
593
+ } ;
594
+ let connector1 : ConnectorModel = {
595
+ id : 'connector1' , sourceID : "node1" , targetID : "node2" ,
596
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
597
+ } ;
598
+ diagram = new Diagram ( {
599
+ enableConnectorSplit : true ,
600
+ width : 700 , height : 600 , nodes : [ node1 , node2 , node3 ] ,
601
+ connectors : [ connector1 ]
602
+ } ) ;
603
+ diagram . appendTo ( '#AllowDrop' ) ;
604
+
605
+ } ) ;
606
+ afterAll ( ( ) : void => {
607
+ diagram . destroy ( ) ;
608
+ ele . remove ( ) ;
609
+ } ) ;
610
+ it ( "894577 - dropping node on connector after the highlighter is activated" , function ( done ) {
611
+ let highlighter : HTMLElement = null ;
612
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
613
+ mouseEvents . clickEvent ( diagramCanvas , 490 , 290 ) ;
614
+ mouseEvents . mouseDownEvent ( diagramCanvas , 490 , 290 ) ;
615
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 400 , 150 ) ;
616
+ highlighter = document . getElementById ( diagram . element . id + '_diagramAdorner_svg_highlighter' ) ;
617
+ expect ( highlighter !== null ) . toBe ( true ) ;
618
+ mouseEvents . mouseUpEvent ( diagramCanvas , 400 , 150 ) ;
619
+ expect ( diagram . connectors . length === 2 ) . toBe ( true ) ;
620
+ done ( ) ;
621
+ } ) ;
622
+ } ) ;
623
+ describe ( 'Connector Allow Drop' , ( ) => {
624
+ let diagram : Diagram ;
625
+ let ele : HTMLElement ;
626
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
627
+ beforeAll ( ( ) : void => {
628
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
629
+ if ( ! isDef ( window . performance ) ) {
630
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
631
+ this . skip ( ) ; //Skips test (in Chai)
632
+ return ;
633
+ }
634
+ ele = createElement ( 'div' , { id : 'AllowDrop' } ) ;
635
+ document . body . appendChild ( ele ) ;
636
+
637
+ let port1 = { id : "port1" , shape : "square" , offset : { x : 0 , y : 0.5 } }
638
+ let port2 = { id : "port2" , shape : "square" , offset : { x : 1 , y : 0.5 } }
639
+ let node1 : NodeModel = { id : 'node1' , width : 100 , height : 100 , offsetX : 150 , offsetY : 150 , annotations : [ { content : 'node1' } ] ,
640
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop } ;
641
+ let node2 : NodeModel = {
642
+ id : 'node2' , width : 100 , height : 100 , offsetX : 650 , offsetY : 150 , annotations : [ { content : 'node2' } ] ,
643
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
644
+ } ;
645
+ let connector1 : ConnectorModel = {
646
+ id : 'connector1' , sourceID : "node1" , targetID : "node2" ,
647
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
648
+ } ;
649
+ diagram = new Diagram ( {
650
+ enableConnectorSplit : true ,
651
+ width : 700 , height : 600 , nodes : [ node1 , node2 ] ,
652
+ connectors : [ connector1 ]
653
+ } ) ;
654
+ diagram . appendTo ( '#AllowDrop' ) ;
655
+
656
+ } ) ;
657
+ afterAll ( ( ) : void => {
658
+ diagram . destroy ( ) ;
659
+ ele . remove ( ) ;
660
+ } ) ;
661
+ it ( "894577 - dropping node on connector of having node's id as sourceID or targetID" , function ( done ) {
662
+ let highlighter : HTMLElement = null ;
663
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
664
+ mouseEvents . mouseDownEvent ( diagramCanvas , 660 , 160 ) ;
665
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 350 , 150 ) ;
666
+ highlighter = document . getElementById ( diagram . element . id + '_diagramAdorner_svg_highlighter' ) ;
667
+ expect ( highlighter !== null ) . toBe ( true ) ;
668
+ mouseEvents . mouseUpEvent ( diagramCanvas , 350 , 150 ) ;
669
+ expect ( diagram . connectors . length === 1 ) . toBe ( true ) ;
670
+ done ( ) ;
671
+ } ) ;
672
+ } ) ;
673
+ describe ( 'Connector Allow Drop' , ( ) => {
674
+ let diagram : Diagram ;
675
+ let ele : HTMLElement ;
676
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
677
+ beforeAll ( ( ) : void => {
678
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
679
+ if ( ! isDef ( window . performance ) ) {
680
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
681
+ this . skip ( ) ; //Skips test (in Chai)
682
+ return ;
683
+ }
684
+ ele = createElement ( 'div' , { id : 'AllowDrop' } ) ;
685
+ document . body . appendChild ( ele ) ;
686
+
687
+ let port1 = { id : "port1" , shape : "square" , offset : { x : 0 , y : 0.5 } }
688
+ let port2 = { id : "port2" , shape : "square" , offset : { x : 1 , y : 0.5 } }
689
+ let node1 : NodeModel = { id : 'node1' , width : 100 , height : 100 , offsetX : 150 , offsetY : 150 , annotations : [ { content : 'node1' } ] ,
690
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop } ;
691
+ let node2 : NodeModel = {
692
+ id : 'node2' , width : 100 , height : 100 , offsetX : 650 , offsetY : 150 , annotations : [ { content : 'node2' } ] ,
693
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
694
+ } ;
695
+ let connector1 : ConnectorModel = {
696
+ id : 'connector1' , sourceID : "node1" , targetID : "node2" ,
697
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
698
+ } ;
699
+ diagram = new Diagram ( {
700
+ enableConnectorSplit : true ,
701
+ width : 700 , height : 600 , nodes : [ node1 , node2 ] ,
702
+ connectors : [ connector1 ]
703
+ } ) ;
704
+ diagram . appendTo ( '#AllowDrop' ) ;
705
+
706
+ } ) ;
707
+ afterAll ( ( ) : void => {
708
+ diagram . destroy ( ) ;
709
+ ele . remove ( ) ;
710
+ } ) ;
711
+ it ( "894577 - dropping selector on connector of having node's id as sourceID or targetID" , function ( done ) {
712
+ let highlighter : HTMLElement = null ;
713
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
714
+ mouseEvents . clickEvent ( diagramCanvas , 660 , 160 ) ;
715
+ mouseEvents . mouseDownEvent ( diagramCanvas , 660 , 160 ) ;
716
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 350 , 150 ) ;
717
+ highlighter = document . getElementById ( diagram . element . id + '_diagramAdorner_svg_highlighter' ) ;
718
+ expect ( highlighter !== null ) . toBe ( true ) ;
719
+ mouseEvents . mouseUpEvent ( diagramCanvas , 350 , 150 ) ;
720
+ expect ( diagram . connectors . length === 1 ) . toBe ( true ) ;
721
+ done ( ) ;
722
+ } ) ;
723
+ } ) ;
724
+ describe ( 'Connector Allow Drop' , ( ) => {
725
+ let diagram : Diagram ;
726
+ let ele : HTMLElement ;
727
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
728
+ beforeAll ( ( ) : void => {
729
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
730
+ if ( ! isDef ( window . performance ) ) {
731
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
732
+ this . skip ( ) ; //Skips test (in Chai)
733
+ return ;
734
+ }
735
+ ele = createElement ( 'div' , { id : 'AllowDrop' } ) ;
736
+ document . body . appendChild ( ele ) ;
737
+
738
+ let node1 : NodeModel = { id : 'node1' , width : 100 , height : 100 , offsetX : 150 , offsetY : 150 , annotations : [ { content : 'node1' } ] ,
739
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop } ;
740
+ let node2 : NodeModel = {
741
+ id : 'node2' , width : 100 , height : 100 , offsetX : 650 , offsetY : 150 , annotations : [ { content : 'node2' } ] ,
742
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
743
+ } ;
744
+ let node3 : NodeModel = {
745
+ id : 'node3' , width : 100 , height : 100 , offsetX : 650 , offsetY : 450 , annotations : [ { content : 'node3' } ] ,
746
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
747
+ } ;
748
+ let group : NodeModel = {
749
+ id : 'group' , children : [ 'node2' , 'node3' ] , annotations : [ { content : 'Group' } ] ,
750
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
751
+ } ;
752
+ let connector1 : ConnectorModel = {
753
+ id : 'connector1' , sourceID : "node1" , targetID : "node2" , type : 'Orthogonal' ,
754
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
755
+ } ;
756
+ let connector2 : ConnectorModel = {
757
+ id : 'connector2' , sourceID : "node2" , targetID : "node3" , type : 'Orthogonal' ,
758
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
759
+ } ;
760
+ diagram = new Diagram ( {
761
+ enableConnectorSplit : true ,
762
+ width : 700 , height : 600 , nodes : [ node1 , node2 , node3 , group ] ,
763
+ connectors : [ connector1 , connector2 ]
764
+ } ) ;
765
+ diagram . appendTo ( '#AllowDrop' ) ;
766
+
767
+ } ) ;
768
+ afterAll ( ( ) : void => {
769
+ diagram . destroy ( ) ;
770
+ ele . remove ( ) ;
771
+ } ) ;
772
+ it ( "894577 - dropping group node on connector of having node's id as sourceID or targetID" , function ( done ) {
773
+ let highlighter : HTMLElement = null ;
774
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
775
+ mouseEvents . mouseDownEvent ( diagramCanvas , 640 , 260 ) ;
776
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 350 , 250 ) ;
777
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 160 , 103 ) ;
778
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 160 , 100 ) ;
779
+ mouseEvents . mouseUpEvent ( diagramCanvas , 160 , 100 ) ;
780
+ expect ( diagram . connectors . length === 2 ) . toBe ( true ) ;
781
+ done ( ) ;
782
+ } ) ;
783
+ } ) ;
784
+ describe ( 'Connector Allow Drop' , ( ) => {
785
+ let diagram : Diagram ;
786
+ let ele : HTMLElement ;
787
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
788
+ beforeAll ( ( ) : void => {
789
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
790
+ if ( ! isDef ( window . performance ) ) {
791
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
792
+ this . skip ( ) ; //Skips test (in Chai)
793
+ return ;
794
+ }
795
+ ele = createElement ( 'div' , { id : 'AllowDrop' } ) ;
796
+ document . body . appendChild ( ele ) ;
797
+
798
+ let node1 : NodeModel = { id : 'node1' , width : 100 , height : 100 , offsetX : 150 , offsetY : 150 , annotations : [ { content : 'node1' } ] ,
799
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop } ;
800
+ let node2 : NodeModel = {
801
+ id : 'node2' , width : 100 , height : 100 , offsetX : 650 , offsetY : 150 , annotations : [ { content : 'node2' } ] ,
802
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
803
+ } ;
804
+ let node3 : NodeModel = {
805
+ id : 'node3' , width : 100 , height : 100 , offsetX : 650 , offsetY : 450 , annotations : [ { content : 'node3' } ] ,
806
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
807
+ } ;
808
+ let group : NodeModel = {
809
+ id : 'group' , children : [ 'node2' , 'node3' ] , annotations : [ { content : 'Group' } ] ,
810
+ constraints : NodeConstraints . Default | NodeConstraints . AllowDrop
811
+ } ;
812
+ let connector1 : ConnectorModel = {
813
+ id : 'connector1' , sourceID : "node1" , targetID : "node2" , type : 'Orthogonal' ,
814
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
815
+ } ;
816
+ let connector2 : ConnectorModel = {
817
+ id : 'connector2' , sourceID : "node2" , targetID : "node3" , type : 'Orthogonal' ,
818
+ constraints : ConnectorConstraints . Default | ConnectorConstraints . AllowDrop
819
+ } ;
820
+ diagram = new Diagram ( {
821
+ enableConnectorSplit : true ,
822
+ width : 700 , height : 600 , nodes : [ node1 , node2 , node3 , group ] ,
823
+ connectors : [ connector1 , connector2 ]
824
+ } ) ;
825
+ diagram . appendTo ( '#AllowDrop' ) ;
826
+
827
+ } ) ;
828
+ afterAll ( ( ) : void => {
829
+ diagram . destroy ( ) ;
830
+ ele . remove ( ) ;
831
+ } ) ;
832
+ it ( "894577 - dropping group selector on connector of having node's id as sourceID or targetID" , function ( done ) {
833
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
834
+ mouseEvents . clickEvent ( diagramCanvas , 640 , 260 ) ;
835
+ mouseEvents . mouseDownEvent ( diagramCanvas , 640 , 260 ) ;
836
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 350 , 250 ) ;
837
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 160 , 103 ) ;
838
+ mouseEvents . mouseMoveEvent ( diagramCanvas , 160 , 100 ) ;
839
+ mouseEvents . mouseUpEvent ( diagramCanvas , 160 , 100 ) ;
840
+ expect ( diagram . connectors . length === 2 ) . toBe ( true ) ;
841
+ done ( ) ;
842
+ } ) ;
843
+ } ) ;
0 commit comments