@@ -12,7 +12,8 @@ import {
12
12
insertCoreStyles ,
13
13
insertBpmnStyles ,
14
14
withPropertiesPanel ,
15
- enableLogging
15
+ enableLogging ,
16
+ getBpmnJS
16
17
} from 'test/TestHelper' ;
17
18
18
19
import {
@@ -697,9 +698,9 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
697
698
// then
698
699
expect ( spy ) . to . have . been . calledOnce ;
699
700
expect ( spy ) . to . have . been . calledWith ( sinon . match ( { layout : newLayout } ) ) ;
700
-
701
701
} ) ;
702
702
703
+
703
704
describe ( 'event emitting' , function ( ) {
704
705
705
706
it ( 'should emit <propertiesPanel.attach>' , async function ( ) {
@@ -920,14 +921,10 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
920
921
selection . select ( elementRegistry . get ( 'ServiceTask_1' ) ) ;
921
922
} ) ;
922
923
923
- const openPopupBtn = getOpenFeelPopup ( 'ServiceTask_1-input-0-source' , container ) ;
924
-
925
924
// when
926
- await act ( ( ) => {
927
- openPopupBtn . click ( ) ;
928
- } ) ;
925
+ await triggerPopupOpen ( 'ServiceTask_1-input-0-source' , container ) ;
929
926
930
- const feelPopup = getFeelPopup ( container ) ;
927
+ const feelPopup = getFeelPopupElement ( container ) ;
931
928
932
929
// then
933
930
expect ( feelPopup ) . to . exist ;
@@ -966,18 +963,21 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
966
963
// given
967
964
const spy = sinon . spy ( ) ;
968
965
969
- const openPopupBtn = getOpenFeelPopup ( 'ServiceTask_1-input-0-source' , container ) ;
970
-
971
966
const eventBus = modeler . get ( 'eventBus' ) ;
972
967
968
+ // assume
969
+ eventBus . fire ( 'propertiesPanel.showEntry' , {
970
+ id : 'ServiceTask_1-input-0-source'
971
+ } ) ;
972
+
973
973
eventBus . on ( 'feelPopup.opened' , spy ) ;
974
974
975
975
// when
976
- await act ( ( ) => {
977
- openPopupBtn . click ( ) ;
978
- } ) ;
976
+ await triggerPopupOpen ( 'ServiceTask_1-input-0-source' , container ) ;
979
977
980
978
// then
979
+ expect ( getFeelPopupElement ( container ) ) . to . exist ;
980
+
981
981
expect ( spy ) . to . have . been . calledOnce ;
982
982
} ) ;
983
983
@@ -987,23 +987,19 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
987
987
// given
988
988
const spy = sinon . spy ( ) ;
989
989
990
- const openPopupBtn = getOpenFeelPopup ( 'ServiceTask_1-input-0-source' , container ) ;
991
-
992
990
const eventBus = modeler . get ( 'eventBus' ) ;
993
991
994
992
eventBus . on ( 'feelPopup.closed' , spy ) ;
995
993
996
- await act ( ( ) => {
997
- openPopupBtn . click ( ) ;
998
- } ) ;
994
+ // assume
995
+ await showEntry ( 'ServiceTask_1-input-0-source' ) ;
996
+
997
+ await triggerPopupOpen ( 'ServiceTask_1-input-0-source' , container ) ;
999
998
1000
999
// assume
1001
- expect ( getFeelPopup ( container ) ) . to . exist ;
1000
+ expect ( getFeelPopupElement ( container ) ) . to . exist ;
1002
1001
1003
- await act ( ( ) => {
1004
- const closeBtn = domQuery ( '.bio-properties-panel-feel-popup__close-btn' , container ) ;
1005
- closeBtn . click ( ) ;
1006
- } ) ;
1002
+ await triggerPopupClose ( container ) ;
1007
1003
1008
1004
// then
1009
1005
expect ( spy ) . to . have . been . calledOnce ;
@@ -1025,7 +1021,7 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
1025
1021
} ) ;
1026
1022
1027
1023
// then
1028
- expect ( getFeelPopup ( container ) ) . to . exist ;
1024
+ expect ( getFeelPopupElement ( container ) ) . to . exist ;
1029
1025
} ) ;
1030
1026
1031
1027
@@ -1043,15 +1039,15 @@ describe('<BpmnPropertiesPanelRenderer>', function() {
1043
1039
} ) ;
1044
1040
1045
1041
// assume
1046
- expect ( getFeelPopup ( container ) ) . to . exist ;
1042
+ expect ( getFeelPopupElement ( container ) ) . to . exist ;
1047
1043
1048
1044
// when
1049
1045
await act ( ( ) => {
1050
1046
feelPopup . close ( ) ;
1051
1047
} ) ;
1052
1048
1053
1049
// then
1054
- expect ( getFeelPopup ( container ) ) . to . not . exist ;
1050
+ expect ( getFeelPopupElement ( container ) ) . to . not . exist ;
1055
1051
} ) ;
1056
1052
1057
1053
@@ -1169,10 +1165,31 @@ function getHeaderName(container) {
1169
1165
return domQuery ( '.bio-properties-panel-header-label' , container ) . innerText ;
1170
1166
}
1171
1167
1172
- function getFeelPopup ( container ) {
1168
+ function getFeelPopupElement ( container ) {
1173
1169
return domQuery ( '.bio-properties-panel-feel-popup' , container ) ;
1174
1170
}
1175
1171
1176
- function getOpenFeelPopup ( id , container ) {
1177
- return container . querySelector ( `[data-entry-id="${ id } "] .bio-properties-panel-open-feel-popup` ) ;
1172
+ function triggerPopupOpen ( id , container ) {
1173
+ const openButton = container . querySelector ( `[data-entry-id="${ id } "] .bio-properties-panel-open-feel-popup` ) ;
1174
+
1175
+ expect ( openButton , `<${ id } > popup open el` ) . to . exist ;
1176
+
1177
+ return act ( ( ) => openButton . click ( ) ) ;
1178
+ }
1179
+
1180
+ function triggerPopupClose ( container ) {
1181
+ const closeButton = domQuery ( '.bio-properties-panel-feel-popup__close-btn' , container ) ;
1182
+
1183
+ expect ( closeButton , 'popup close button' ) . to . exist ;
1184
+
1185
+ return act ( ( ) => closeButton . click ( ) ) ;
1178
1186
}
1187
+
1188
+ function showEntry ( id ) {
1189
+
1190
+ return act ( ( ) => getBpmnJS ( ) . invoke ( eventBus => {
1191
+ eventBus . fire ( 'propertiesPanel.showEntry' , {
1192
+ id
1193
+ } ) ;
1194
+ } ) ) ;
1195
+ }
0 commit comments