@@ -3,7 +3,7 @@ import { Diagram } from '../../../src/diagram/diagram';
3
3
import { ConnectorModel } from '../../../src/diagram/objects/connector-model' ;
4
4
import { NodeModel , BasicShapeModel } from '../../../src/diagram/objects/node-model' ;
5
5
import { PathPortModel , PointPortModel } from '../../../src/diagram/objects/port-model' ;
6
- import { Segments , accessibilityElement , ConnectorConstraints , NodeConstraints , PortVisibility , PortConstraints , ControlPointsVisibility } from '../../../src/diagram/enum/enum' ;
6
+ import { Segments , accessibilityElement , ConnectorConstraints , NodeConstraints , PortVisibility , PortConstraints , ControlPointsVisibility , AnnotationConstraints } from '../../../src/diagram/enum/enum' ;
7
7
import { Connector } from '../../../src/diagram/objects/connector' ;
8
8
import { StraightSegmentModel } from '../../../src/diagram/objects/connector-model' ;
9
9
import { PathElement } from '../../../src/diagram/core/elements/path-element' ;
@@ -2347,4 +2347,100 @@ describe('Diagram Control', () => {
2347
2347
done ( ) ;
2348
2348
} ) ;
2349
2349
} ) ;
2350
+
2351
+ describe ( '881512-Wrapping of the connector annotation at run time not working properly.' , ( ) => {
2352
+ let diagram : Diagram ;
2353
+ let ele : HTMLElement ;
2354
+ let count : number = 0 ;
2355
+ let mouseEvents : MouseEvents = new MouseEvents ( ) ;
2356
+ beforeAll ( ( ) : void => {
2357
+ const isDef = ( o : any ) => o !== undefined && o !== null ;
2358
+ if ( ! isDef ( window . performance ) ) {
2359
+ console . log ( "Unsupported environment, window.performance.memory is unavailable" ) ;
2360
+ this . skip ( ) ; //Skips test (in Chai)
2361
+ return ;
2362
+ }
2363
+ ele = createElement ( 'div' , { id : 'diagramConnectorWrap' } ) ;
2364
+ document . body . appendChild ( ele ) ;
2365
+
2366
+ let connectors : ConnectorModel [ ] = [
2367
+ {
2368
+ id : 'connector1' , sourcePoint : { x : 280 , y : 300 } , targetPoint : { x : 400 , y : 300 } , annotations : [ { content : 'This is very longlonglong text' , style : {
2369
+ textWrapping : 'Wrap' ,
2370
+ fontSize : 8 ,
2371
+ color : 'Black' ,
2372
+ } ,
2373
+ verticalAlignment : 'Top' ,
2374
+ horizontalAlignment : 'Center' ,
2375
+ constraints : AnnotationConstraints . ReadOnly ,
2376
+ type : 'Path' , } ]
2377
+ } ,
2378
+ {
2379
+ id : 'connector2' , sourceID :'node1' , targetID :'node2' , annotations : [ { content : 'This is very longlonglong text' , style : {
2380
+ textWrapping : 'Wrap' ,
2381
+ fontSize : 8 ,
2382
+ color : 'Black' ,
2383
+ } ,
2384
+ verticalAlignment : 'Top' ,
2385
+ horizontalAlignment : 'Center' ,
2386
+ constraints : AnnotationConstraints . ReadOnly ,
2387
+ type : 'Path' , } ]
2388
+ } ,
2389
+ ] ;
2390
+ let nodes : NodeModel [ ] = [
2391
+ {
2392
+ id : 'node1' , width : 70 , height : 50 , offsetX : 100 , offsetY : 100 , annotations : [ { content : 'Node1' } ]
2393
+ } ,
2394
+ {
2395
+ id : 'node2' , width : 70 , height : 50 , offsetX : 270 , offsetY : 100 , annotations : [ { content : 'Node2' } ]
2396
+ } ,
2397
+ ] ;
2398
+ diagram = new Diagram ( {
2399
+
2400
+ width : '1000px' , height : '500px' , nodes : nodes , connectors : connectors ,
2401
+
2402
+ } ) ;
2403
+ diagram . appendTo ( '#diagramConnectorWrap' ) ;
2404
+
2405
+ } ) ;
2406
+ afterAll ( ( ) : void => {
2407
+ diagram . destroy ( ) ;
2408
+ ele . remove ( ) ;
2409
+ } ) ;
2410
+ it ( 'Changing node offset dynamically and checking connector annotation size' , function ( done : Function ) {
2411
+ let connector = diagram . nameTable [ 'connector2' ] ;
2412
+ let preTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2413
+ let node = diagram . nodes [ 0 ] ;
2414
+ node . offsetX = 130 ;
2415
+ diagram . dataBind ( ) ;
2416
+ let curTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2417
+ expect ( preTextBounds . width !== curTextBounds . width && curTextBounds . width < preTextBounds . width ) . toBe ( true ) ;
2418
+ done ( ) ;
2419
+ } ) ;
2420
+ it ( 'Changing connector source point dynamically and checking connector annotation size' , function ( done : Function ) {
2421
+ let connector = diagram . nameTable [ 'connector1' ] ;
2422
+ let preTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2423
+ connector . sourcePoint = { x :320 , y :300 } ;
2424
+ diagram . dataBind ( ) ;
2425
+ let curTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2426
+ expect ( preTextBounds . width !== curTextBounds . width && curTextBounds . width < preTextBounds . width ) . toBe ( true ) ;
2427
+ done ( ) ;
2428
+ } ) ;
2429
+ it ( 'Changing node offset using mouse events and checking connector annotation size' , function ( done : Function ) {
2430
+ let connector = diagram . nameTable [ 'connector2' ] ;
2431
+ let preTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2432
+ let diagramCanvas = document . getElementById ( diagram . element . id + 'content' ) ;
2433
+ let node = diagram . nodes [ 1 ] ;
2434
+ mouseEvents . clickEvent ( diagramCanvas , node . offsetX , node . offsetY ) ;
2435
+ mouseEvents . mouseMoveEvent ( diagramCanvas , node . offsetX , node . offsetY ) ;
2436
+ mouseEvents . mouseDownEvent ( diagramCanvas , node . offsetX , node . offsetY ) ;
2437
+ mouseEvents . mouseMoveEvent ( diagramCanvas , node . offsetX + 30 , node . offsetY ) ;
2438
+ mouseEvents . mouseMoveEvent ( diagramCanvas , node . offsetX + 80 , node . offsetY ) ;
2439
+ mouseEvents . mouseMoveEvent ( diagramCanvas , node . offsetX + 120 , node . offsetY ) ;
2440
+ mouseEvents . mouseUpEvent ( diagramCanvas , node . offsetX + 120 , node . offsetY ) ;
2441
+ let curTextBounds = connector . wrapper . children [ 3 ] . bounds ;
2442
+ expect ( preTextBounds . width !== curTextBounds . width && curTextBounds . width > preTextBounds . width ) . toBe ( true ) ;
2443
+ done ( ) ;
2444
+ } ) ;
2445
+ } ) ;
2350
2446
} ) ;
0 commit comments