@@ -5,7 +5,7 @@ import { ConnectorModel } from '../../../src/diagram/objects/connector-model';
5
5
import { NodeModel } from '../../../src/diagram/objects/node-model' ;
6
6
import { BpmnDiagrams } from '../../../src/diagram/objects/bpmn' ;
7
7
import { DiagramScroller } from '../../../src/diagram/interaction/scroller' ;
8
- import { Rect } from '../../../src/index' ;
8
+ import { LayerModel , Rect } from '../../../src/index' ;
9
9
import { MouseEvents } from '../../../spec/diagram/interaction/mouseevents.spec' ;
10
10
import { profile , inMB , getMemoryProfile } from '../../../spec/common.spec' ;
11
11
Diagram . Inject ( BpmnDiagrams ) ;
@@ -521,7 +521,7 @@ describe('PageSettings boundary constraints', () => {
521
521
diagram . pageSettings . boundaryConstraints = 'Page' ;
522
522
diagram . drawingObject = { id : 'connector11' , type : 'Straight' } ;
523
523
mouseEvents . dragAndDropEvent ( diagramCanvas , 250 , 400 , 250 , 520 ) ;
524
- expect ( ( diagram . connectors [ 2 ] . targetPoint . y === 392 ) || diagram . connectors [ 2 ] . targetPoint . y === 400 ) . toBe ( true ) ;
524
+ expect ( ( diagram . connectors [ 2 ] . targetPoint . y === 392 ) || diagram . connectors [ 2 ] . targetPoint . y === 400 ) . toBe ( true ) ;
525
525
done ( ) ;
526
526
} ) ;
527
527
it ( 'branch coverage for drag' , ( done : Function ) => {
@@ -782,3 +782,263 @@ describe('BPMN Shape Style Change', () => {
782
782
done ( ) ;
783
783
} ) ;
784
784
} )
785
+
786
+ describe ( 'Node undo-redo style change' , ( ) => {
787
+ let diagram : Diagram ;
788
+ let ele : HTMLElement ;
789
+ let scroller : DiagramScroller ;
790
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
791
+ beforeAll ( ( ) : void => {
792
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
793
+ if ( ! isDef ( window . performance ) ) {
794
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
795
+ this . skip ( ) ; //Skips test (in Chai)
796
+ return ;
797
+ }
798
+
799
+ ele = createElement ( 'div' , { id : 'diagram' } ) ;
800
+ document . body . appendChild ( ele ) ;
801
+ let node : NodeModel = {
802
+ id : 'node1' , width : 100 , height : 100 , offsetX : 100 , offsetY : 100 ,
803
+ } ;
804
+ diagram = new Diagram ( {
805
+ width : 800 , height : 800 , nodes : [ node ] ,
806
+ } ) ;
807
+ diagram . appendTo ( '#diagram' ) ;
808
+
809
+ } ) ;
810
+ afterAll ( ( ) : void => {
811
+ diagram . destroy ( ) ;
812
+ ele . remove ( ) ;
813
+ } ) ;
814
+ it ( 'Check node color after undo and redo' , ( done : Function ) => {
815
+ diagram . nodes [ 0 ] . style = {
816
+ fill : '#d8ecdc' ,
817
+ strokeColor : '#78BE83' ,
818
+ strokeWidth : 3 ,
819
+ gradient : {
820
+ // Start point of linear gradient
821
+ x1 : 0 ,
822
+ y1 : 0 ,
823
+ // End point of linear gradient
824
+ x2 : 100 ,
825
+ y2 : 100 ,
826
+ // Sets an array of stop objects
827
+ stops : [
828
+ {
829
+ color : 'white' ,
830
+ offset : 30 ,
831
+ opacity : 0.1
832
+ } ,
833
+ {
834
+ color : '#d8ecdc' ,
835
+ offset : 100 ,
836
+ opacity : 0.1
837
+ }
838
+ ] ,
839
+ type : 'Linear'
840
+ }
841
+ } ;
842
+ diagram . dataBind ( ) ;
843
+ diagram . undo ( ) ;
844
+ expect ( diagram . nodes [ 0 ] . style . fill === "white" ) . toBe ( true ) ;
845
+ diagram . redo ( ) ;
846
+ expect ( diagram . nodes [ 0 ] . style . fill === "#d8ecdc" ) . toBe ( true ) ;
847
+ done ( ) ;
848
+ } ) ;
849
+ it ( 'Add layer' , ( done : Function ) => {
850
+ var newNode = {
851
+ id : 'new' , offsetX : 300 , offsetY : 300 , height : 50 , width : 50
852
+ }
853
+ diagram . addLayer ( { objects : [ ] , visible : true } , [ newNode ] ) ;
854
+ expect ( diagram . layers . length === 2 ) . toBe ( true ) ;
855
+ done ( ) ;
856
+ } ) ;
857
+ it ( 'Remove layer' , ( done : Function ) => {
858
+ diagram . removeLayer ( diagram . layers [ 1 ] . id ) ;
859
+ expect ( diagram . layers . length === 1 ) . toBe ( true ) ;
860
+ done ( ) ;
861
+ } ) ;
862
+ } )
863
+ describe ( 'Swimlane child disappears' , ( ) => {
864
+ let diagram : Diagram ;
865
+ let ele : HTMLElement ;
866
+ let scroller : DiagramScroller ;
867
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
868
+ beforeAll ( ( ) : void => {
869
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
870
+ if ( ! isDef ( window . performance ) ) {
871
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
872
+ this . skip ( ) ; //Skips test (in Chai)
873
+ return ;
874
+ }
875
+
876
+ ele = createElement ( 'div' , { id : 'diagramlane' } ) ;
877
+ document . body . appendChild ( ele ) ;
878
+ let nodes : NodeModel [ ] = [
879
+ {
880
+ id : 'swimlane' ,
881
+ shape : {
882
+ type : 'SwimLane' ,
883
+ orientation : 'Horizontal' ,
884
+ header : {
885
+ annotation : { content : 'ONLINE PURCHASE STATUS' , style : { fill : '#111111' } } ,
886
+ height : 50 , style : { fontSize : 11 } ,
887
+ } ,
888
+ lanes : [
889
+ {
890
+ id : 'stackCanvas1' ,
891
+ header : {
892
+ annotation : { content : 'CUSTOMER' } , width : 50 ,
893
+ style : { fontSize : 11 }
894
+ } ,
895
+ height : 100 ,
896
+ children : [
897
+ {
898
+ id : 'Order' ,
899
+ annotations : [
900
+ {
901
+ content : 'ORDER' ,
902
+ style : { fontSize : 11 }
903
+ }
904
+ ] ,
905
+ margin : { left : 60 , top : 20 } ,
906
+ height : 40 , width : 100
907
+ } ,
908
+ {
909
+ id : 'selectItemaddcart' ,
910
+ annotations : [ { content : 'Select item\nAdd cart' } ] ,
911
+ margin : { left : 190 , top : 20 } ,
912
+ height : 40 , width : 100
913
+ } ,
914
+ ] ,
915
+ } ,
916
+
917
+ ] ,
918
+
919
+ } ,
920
+ offsetX : 420 , offsetY : 270 ,
921
+ height : 100 ,
922
+ width : 650
923
+ } ,
924
+ ] ;
925
+ let connectors : ConnectorModel [ ] = [
926
+ {
927
+ id : 'connector1' , sourceID : 'Order' ,
928
+ targetID : 'selectItemaddcart'
929
+ } ,
930
+
931
+ ] ;
932
+ diagram = new Diagram ( {
933
+ width : 800 , height : 800 , nodes : nodes ,
934
+ connectors : connectors
935
+ } ) ;
936
+ diagram . appendTo ( '#diagramlane' ) ;
937
+
938
+ } ) ;
939
+ afterAll ( ( ) : void => {
940
+ diagram . destroy ( ) ;
941
+ ele . remove ( ) ;
942
+ } ) ;
943
+ it ( 'Send swimlane child back and Check lane selection' , ( done : Function ) => {
944
+ diagram . select ( [ diagram . getObject ( 'Order' ) ] ) ;
945
+ diagram . sendToBack ( ) ;
946
+ diagram . clearSelection ( ) ;
947
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
948
+ mouseEvents . clickEvent ( diagramCanvas , 200 , 300 ) ;
949
+ expect ( diagram . selectedItems . nodes [ 0 ] . id === "swimlanestackCanvas10" ) . toBe ( true ) ;
950
+ done ( ) ;
951
+ } ) ;
952
+ } )
953
+ describe ( 'Swimlane send to back' , ( ) => {
954
+ let diagram : Diagram ;
955
+ let ele : HTMLElement ;
956
+ let scroller : DiagramScroller ;
957
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
958
+ beforeAll ( ( ) : void => {
959
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
960
+ if ( ! isDef ( window . performance ) ) {
961
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
962
+ this . skip ( ) ; //Skips test (in Chai)
963
+ return ;
964
+ }
965
+
966
+ ele = createElement ( 'div' , { id : 'diagramlane' } ) ;
967
+ document . body . appendChild ( ele ) ;
968
+ let nodes : NodeModel [ ] = [
969
+ {
970
+ id : 'swimlane' ,
971
+ shape : {
972
+ type : 'SwimLane' ,
973
+ orientation : 'Horizontal' ,
974
+ header : {
975
+ annotation : { content : 'ONLINE PURCHASE STATUS' , style : { fill : '#111111' } } ,
976
+ height : 50 , style : { fontSize : 11 } ,
977
+ } ,
978
+ lanes : [
979
+ {
980
+ id : 'stackCanvas1' ,
981
+ header : {
982
+ annotation : { content : 'CUSTOMER' } , width : 50 ,
983
+ style : { fontSize : 11 }
984
+ } ,
985
+ height : 100 ,
986
+ children : [
987
+ {
988
+ id : 'Order' ,
989
+ annotations : [
990
+ {
991
+ content : 'ORDER' ,
992
+ style : { fontSize : 11 }
993
+ }
994
+ ] ,
995
+ margin : { left : 60 , top : 20 } ,
996
+ height : 40 , width : 100
997
+ } ,
998
+ {
999
+ id : 'selectItemaddcart' ,
1000
+ annotations : [ { content : 'Select item\nAdd cart' } ] ,
1001
+ margin : { left : 190 , top : 20 } ,
1002
+ height : 40 , width : 100
1003
+ } ,
1004
+ ] ,
1005
+ } ,
1006
+
1007
+ ] ,
1008
+
1009
+ } ,
1010
+ offsetX : 420 , offsetY : 270 ,
1011
+ height : 100 ,
1012
+ width : 650
1013
+ } ,
1014
+ ] ;
1015
+ let connectors : ConnectorModel [ ] = [
1016
+ {
1017
+ id : 'connector1' , sourceID : 'Order' ,
1018
+ targetID : 'selectItemaddcart'
1019
+ } ,
1020
+
1021
+ ] ;
1022
+ diagram = new Diagram ( {
1023
+ width : 800 , height : 800 , nodes : nodes ,
1024
+ connectors : connectors
1025
+ } ) ;
1026
+ diagram . appendTo ( '#diagramlane' ) ;
1027
+
1028
+ } ) ;
1029
+ afterAll ( ( ) : void => {
1030
+ diagram . destroy ( ) ;
1031
+ ele . remove ( ) ;
1032
+ } ) ;
1033
+ it ( 'Send swimlane back and check 1st index swimlane got selected' , ( done : Function ) => {
1034
+ diagram . select ( [ diagram . getObject ( 'swimlane' ) ] ) ;
1035
+ diagram . copy ( ) ;
1036
+ diagram . paste ( ) ;
1037
+ diagram . sendToBack ( ) ;
1038
+ diagram . clearSelection ( ) ;
1039
+ let diagramCanvas : HTMLElement = document . getElementById ( diagram . element . id + 'content' ) ;
1040
+ mouseEvents . clickEvent ( diagramCanvas , 550 , 300 ) ;
1041
+ expect ( diagram . selectedItems . nodes [ 0 ] . id === "swimlanestackCanvas10" ) . toBe ( true ) ;
1042
+ done ( ) ;
1043
+ } ) ;
1044
+ } )
0 commit comments