@@ -2,7 +2,8 @@ import TestContainer from 'mocha-test-container-support';
2
2
3
3
import {
4
4
act ,
5
- cleanup
5
+ cleanup ,
6
+ waitFor
6
7
} from '@testing-library/preact/pure' ;
7
8
8
9
import {
@@ -13,7 +14,8 @@ import {
13
14
insertBpmnStyles ,
14
15
withPropertiesPanel ,
15
16
enableLogging ,
16
- getBpmnJS
17
+ getBpmnJS ,
18
+ changeInput
17
19
} from 'test/TestHelper' ;
18
20
19
21
import {
@@ -54,6 +56,10 @@ import ExamplePropertiesProvider from './extension/ExamplePropertiesProvider';
54
56
import ZeebeTooltipProvider from 'src/contextProvider/zeebe/TooltipProvider' ;
55
57
import CamundaPlatformTooltipProvider from 'src/contextProvider/camunda-platform/TooltipProvider' ;
56
58
59
+ import { getExtensionElementsList } from 'src/utils/ExtensionElementsUtil' ;
60
+
61
+ import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil' ;
62
+
57
63
const singleStart = window . __env__ && window . __env__ . SINGLE_START ;
58
64
59
65
insertCoreStyles ( ) ;
@@ -501,6 +507,209 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
501
507
expect ( getHeaderName ( propertiesContainer ) ) . to . eql ( 'start' ) ;
502
508
} ) ;
503
509
510
+ describe ( 'input' , function ( ) {
511
+
512
+ let modeler ;
513
+ const diagramXml = require ( 'test/fixtures/integration.bpmn' ) . default ;
514
+
515
+ beforeEach ( function ( ) {
516
+ return act ( async ( ) => {
517
+ ( { modeler } = await createModeler ( diagramXml , {
518
+ propertiesPanel : {
519
+ parent : propertiesContainer ,
520
+ layout : {
521
+ groups : {
522
+ 'general' : { open : true } ,
523
+ 'taskDefinition' : { open : true } ,
524
+ 'link' : { open : true }
525
+ }
526
+ }
527
+ }
528
+ } ) ) ;
529
+ } ) ;
530
+ } ) ;
531
+
532
+
533
+ describe ( 'feel (optional)' , function ( ) {
534
+
535
+ const OPTIONAL_FEEL_SELECTOR = '[name=taskDefinitionType]' ;
536
+
537
+ it ( 'should trim value' , async function ( ) {
538
+
539
+ // given
540
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
541
+ selection = modeler . get ( 'selection' ) ,
542
+ serviceTask = elementRegistry . get ( 'ServiceTask_1' ) ;
543
+ await act ( ( ) => {
544
+ selection . select ( serviceTask ) ;
545
+ } ) ;
546
+
547
+ // when
548
+ const input = domQuery ( OPTIONAL_FEEL_SELECTOR , container ) ;
549
+ input . focus ( ) ;
550
+ changeInput ( input , ' bar ' ) ;
551
+ input . blur ( ) ;
552
+
553
+ // then
554
+ await waitFor ( ( ) => {
555
+ expect ( getTaskDefinition ( serviceTask ) . get ( 'type' ) ) . to . eql ( 'bar' ) ;
556
+ } ) ;
557
+ } ) ;
558
+
559
+
560
+ it ( 'should not propagate input to other element' , async function ( ) {
561
+
562
+ // given
563
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
564
+ selection = modeler . get ( 'selection' ) ,
565
+ serviceTask = elementRegistry . get ( 'ServiceTask_1' ) ,
566
+ anotherServiceTask = elementRegistry . get ( 'ServiceTask_2' ) ;
567
+ const originalValueOfAnotherServiceTask = getTaskDefinition ( anotherServiceTask ) . get ( 'type' ) ;
568
+ await act ( ( ) => {
569
+ selection . select ( serviceTask ) ;
570
+ } ) ;
571
+
572
+ // when
573
+ const input = domQuery ( OPTIONAL_FEEL_SELECTOR , container ) ;
574
+ input . focus ( ) ;
575
+ changeInput ( input , 'newValue' ) ;
576
+ input . blur ( ) ;
577
+
578
+ await act ( ( ) => {
579
+ selection . select ( anotherServiceTask ) ;
580
+ } ) ;
581
+
582
+ // and when
583
+ const input2 = domQuery ( OPTIONAL_FEEL_SELECTOR , container ) ;
584
+ input2 . focus ( ) ;
585
+
586
+ // then
587
+ expect ( input2 . value ) . to . eql ( originalValueOfAnotherServiceTask ) ;
588
+ expect ( getTaskDefinition ( anotherServiceTask ) . get ( 'type' ) ) . to . eql ( originalValueOfAnotherServiceTask ) ;
589
+ } ) ;
590
+ } ) ;
591
+
592
+
593
+ describe ( 'text area' , function ( ) {
594
+
595
+ const TEXT_AREA_SELECTOR = '[name=name]' ;
596
+
597
+ it ( 'should trim value' , async function ( ) {
598
+
599
+ // given
600
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
601
+ selection = modeler . get ( 'selection' ) ,
602
+ serviceTask = elementRegistry . get ( 'ServiceTask_1' ) ;
603
+ await act ( ( ) => {
604
+ selection . select ( serviceTask ) ;
605
+ } ) ;
606
+
607
+ // when
608
+ const input = domQuery ( TEXT_AREA_SELECTOR , container ) ;
609
+ input . focus ( ) ;
610
+ changeInput ( input , ' bar ' ) ;
611
+ input . blur ( ) ;
612
+
613
+ // then
614
+ await waitFor ( ( ) => {
615
+ expect ( getName ( serviceTask ) ) . to . eql ( 'bar' ) ;
616
+ } ) ;
617
+ } ) ;
618
+
619
+
620
+ it ( 'should not propagate input to other element' , async function ( ) {
621
+
622
+ // given
623
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
624
+ selection = modeler . get ( 'selection' ) ,
625
+ serviceTask = elementRegistry . get ( 'ServiceTask_1' ) ,
626
+ anotherServiceTask = elementRegistry . get ( 'ServiceTask_2' ) ;
627
+ const originalValueOfAnotherServiceTask = getName ( anotherServiceTask ) ;
628
+ await act ( ( ) => {
629
+ selection . select ( serviceTask ) ;
630
+ } ) ;
631
+
632
+ // when
633
+ const input = domQuery ( TEXT_AREA_SELECTOR , container ) ;
634
+ input . focus ( ) ;
635
+ changeInput ( input , 'newValue' ) ;
636
+ input . blur ( ) ;
637
+
638
+ await act ( ( ) => {
639
+ selection . select ( anotherServiceTask ) ;
640
+ } ) ;
641
+
642
+ // and when
643
+ const input2 = domQuery ( TEXT_AREA_SELECTOR , container ) ;
644
+ input2 . focus ( ) ;
645
+
646
+ // then
647
+ expect ( input2 . value ) . to . eql ( originalValueOfAnotherServiceTask ) ;
648
+ expect ( getName ( anotherServiceTask ) ) . to . eql ( originalValueOfAnotherServiceTask ) ;
649
+ } ) ;
650
+ } ) ;
651
+
652
+
653
+ describe ( 'text field' , function ( ) {
654
+
655
+ const TEXT_FIELD_SELECTOR = '[name=linkName]' ;
656
+
657
+ it ( 'should trim value' , async function ( ) {
658
+
659
+ // given
660
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
661
+ selection = modeler . get ( 'selection' ) ,
662
+ linkEvent = elementRegistry . get ( 'LinkEvent_1' ) ;
663
+ await act ( ( ) => {
664
+ selection . select ( linkEvent ) ;
665
+ } ) ;
666
+
667
+ // when
668
+ const input = domQuery ( TEXT_FIELD_SELECTOR , container ) ;
669
+ input . focus ( ) ;
670
+ changeInput ( input , ' bar ' ) ;
671
+ input . blur ( ) ;
672
+
673
+ // then
674
+ await waitFor ( ( ) => {
675
+ expect ( getLinkName ( linkEvent ) ) . to . eql ( 'bar' ) ;
676
+ } ) ;
677
+ } ) ;
678
+
679
+
680
+ it ( 'should not propagate input to other element' , async function ( ) {
681
+
682
+ // given
683
+ const elementRegistry = modeler . get ( 'elementRegistry' ) ,
684
+ selection = modeler . get ( 'selection' ) ,
685
+ linkEvent = elementRegistry . get ( 'LinkEvent_1' ) ,
686
+ anotherLinkName = elementRegistry . get ( 'LinkEvent_2' ) ;
687
+ const originalValueOfAnotherLinkEvent = getLinkName ( anotherLinkName ) ;
688
+ await act ( ( ) => {
689
+ selection . select ( linkEvent ) ;
690
+ } ) ;
691
+
692
+ // when
693
+ const input = domQuery ( TEXT_FIELD_SELECTOR , container ) ;
694
+ input . focus ( ) ;
695
+ changeInput ( input , 'newValue' ) ;
696
+ input . blur ( ) ;
697
+
698
+ await act ( ( ) => {
699
+ selection . select ( anotherLinkName ) ;
700
+ } ) ;
701
+
702
+ // and when
703
+ const input2 = domQuery ( TEXT_FIELD_SELECTOR , container ) ;
704
+ input2 . focus ( ) ;
705
+
706
+ // then
707
+ expect ( input2 . value ) . to . eql ( originalValueOfAnotherLinkEvent ) ;
708
+ expect ( getLinkName ( anotherLinkName ) ) . to . eql ( originalValueOfAnotherLinkEvent ) ;
709
+ } ) ;
710
+ } ) ;
711
+ } ) ;
712
+
504
713
505
714
withPropertiesPanel ( '>=0.16' ) ( 'should show error' , async function ( ) {
506
715
@@ -813,6 +1022,7 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
813
1022
} ) ;
814
1023
} ) ;
815
1024
1025
+
816
1026
// then
817
1027
expect ( document . activeElement ) . to . exist ;
818
1028
expect ( document . activeElement . closest ( '.bio-properties-panel-entry' ) ) . to . exist ;
@@ -1223,4 +1433,24 @@ function showEntry(id) {
1223
1433
id
1224
1434
} ) ;
1225
1435
} ) ) ;
1226
- }
1436
+ }
1437
+
1438
+ // helper //////////////////
1439
+
1440
+ function getTaskDefinition ( element ) {
1441
+ const businessObject = getBusinessObject ( element ) ;
1442
+
1443
+ return getExtensionElementsList ( businessObject , 'zeebe:TaskDefinition' ) [ 0 ] ;
1444
+ }
1445
+
1446
+ function getName ( element ) {
1447
+ const businessObject = getBusinessObject ( element ) ;
1448
+
1449
+ return businessObject . get ( 'name' ) ;
1450
+ }
1451
+
1452
+ function getLinkName ( element ) {
1453
+ const businessObject = getBusinessObject ( element ) ;
1454
+
1455
+ return businessObject . get ( 'eventDefinitions' ) [ 0 ] . get ( 'name' ) ;
1456
+ }
0 commit comments