@@ -79,6 +79,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
7979 } )
8080 ) ;
8181
82+
8283 it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
8384
8485 // given
@@ -163,6 +164,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
163164 } )
164165 ) ;
165166
167+
166168 it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
167169
168170 // given
@@ -223,6 +225,81 @@ describe('provider/zeebe - InputOutputParameter', function() {
223225 } )
224226 ) ;
225227
228+
229+ describe ( 'integration' , function ( ) {
230+
231+ // Test for undo/redo integration with newly created input/output parameters
232+ // cf. https://github.com/bpmn-io/bpmn-js-properties-panel/issues/981
233+ it ( 'should undo' ,
234+ inject ( async function ( elementRegistry , selection , commandStack ) {
235+
236+ // given
237+ const serviceTask = elementRegistry . get ( 'ServiceTask_empty' ) ;
238+
239+ await act ( ( ) => {
240+ selection . select ( serviceTask ) ;
241+ } ) ;
242+
243+ const inputGroup = getGroup ( container , 'inputs' ) ;
244+ const addEntry = domQuery ( '.bio-properties-panel-add-entry' , inputGroup ) ;
245+
246+ await act ( ( ) => {
247+ addEntry . click ( ) ;
248+ } ) ;
249+
250+ const sourceInput = domQuery ( '[name=ServiceTask_empty-input-0-source] [role="textbox"]' , inputGroup ) ;
251+ await setEditorValue ( sourceInput , 'newValue' ) ;
252+
253+ // assume
254+ expect ( getInput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
255+
256+ // when
257+ commandStack . undo ( ) ;
258+ await nextTick ( ) ; // propagate value to editor and await change handler
259+
260+ // then
261+ expect ( getInput ( serviceTask , 0 ) . get ( 'source' ) ) . to . be . undefined ;
262+ } )
263+ ) ;
264+
265+
266+ it ( 'should redo' ,
267+ inject ( async function ( elementRegistry , selection , commandStack ) {
268+
269+ // given
270+ const serviceTask = elementRegistry . get ( 'ServiceTask_empty' ) ;
271+
272+ await act ( ( ) => {
273+ selection . select ( serviceTask ) ;
274+ } ) ;
275+
276+ const inputGroup = getGroup ( container , 'inputs' ) ;
277+ const addEntry = domQuery ( '.bio-properties-panel-add-entry' , inputGroup ) ;
278+
279+ await act ( ( ) => {
280+ addEntry . click ( ) ;
281+ } ) ;
282+
283+ const sourceInput = domQuery ( '[name=ServiceTask_empty-input-0-source] [role="textbox"]' , inputGroup ) ;
284+
285+ await setEditorValue ( sourceInput , 'newValue' ) ;
286+
287+ // assume
288+ expect ( getInput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
289+
290+ // when
291+ commandStack . undo ( ) ;
292+ await nextTick ( ) ;
293+ commandStack . redo ( ) ;
294+ await nextTick ( ) ;
295+
296+ // then
297+ expect ( getInput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
298+
299+ } )
300+ ) ;
301+ } ) ;
302+
226303 } ) ;
227304
228305
@@ -247,6 +324,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
247324 } )
248325 ) ;
249326
327+
250328 it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
251329
252330 // given
@@ -331,6 +409,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
331409 } )
332410 ) ;
333411
412+
334413 it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
335414
336415 // given
@@ -391,6 +470,80 @@ describe('provider/zeebe - InputOutputParameter', function() {
391470 } )
392471 ) ;
393472
473+
474+ describe ( 'integration' , function ( ) {
475+
476+ // Test for undo/redo integration with newly created input/output parameters
477+ // Cf. https://github.com/bpmn-io/bpmn-js-properties-panel/issues/981
478+ it ( 'should undo' ,
479+ inject ( async function ( elementRegistry , selection , commandStack ) {
480+
481+ // given
482+ const serviceTask = elementRegistry . get ( 'ServiceTask_empty' ) ;
483+
484+ await act ( ( ) => {
485+ selection . select ( serviceTask ) ;
486+ } ) ;
487+
488+ const outputGroup = getGroup ( container , 'outputs' ) ;
489+ const addEntry = domQuery ( '.bio-properties-panel-add-entry' , outputGroup ) ;
490+
491+ await act ( ( ) => {
492+ addEntry . click ( ) ;
493+ } ) ;
494+
495+ const sourceInput = domQuery ( '[name=ServiceTask_empty-output-0-source] [role="textbox"]' , outputGroup ) ;
496+ await setEditorValue ( sourceInput , 'newValue' ) ;
497+
498+ // assume
499+ expect ( getOutput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
500+
501+ // when
502+ commandStack . undo ( ) ;
503+ await nextTick ( ) ; // propagate value to editor and await change handler
504+
505+ // then
506+ expect ( getOutput ( serviceTask , 0 ) . get ( 'source' ) ) . to . be . undefined ;
507+ } )
508+ ) ;
509+
510+
511+ it ( 'should redo' ,
512+ inject ( async function ( elementRegistry , selection , commandStack ) {
513+
514+ // given
515+ const serviceTask = elementRegistry . get ( 'ServiceTask_empty' ) ;
516+
517+ await act ( ( ) => {
518+ selection . select ( serviceTask ) ;
519+ } ) ;
520+
521+ const outputGroup = getGroup ( container , 'outputs' ) ;
522+ const addEntry = domQuery ( '.bio-properties-panel-add-entry' , outputGroup ) ;
523+
524+ await act ( ( ) => {
525+ addEntry . click ( ) ;
526+ } ) ;
527+
528+ const sourceInput = domQuery ( '[name=ServiceTask_empty-output-0-source] [role="textbox"]' , outputGroup ) ;
529+ await setEditorValue ( sourceInput , 'newValue' ) ;
530+
531+ // assume
532+ expect ( getOutput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
533+
534+ // when
535+ commandStack . undo ( ) ;
536+ await nextTick ( ) ;
537+ commandStack . redo ( ) ;
538+ await nextTick ( ) ;
539+
540+ // then
541+ expect ( getOutput ( serviceTask , 0 ) . get ( 'source' ) ) . to . eql ( '=newValue' ) ;
542+
543+ } )
544+ ) ;
545+ } ) ;
546+
394547 } ) ;
395548
396549} ) ;
@@ -410,3 +563,6 @@ function getOutput(element, idx) {
410563 return ( getOutputParameters ( element ) || [ ] ) [ idx ] ;
411564}
412565
566+ function nextTick ( ) {
567+ return new Promise ( resolve => setTimeout ( resolve , 0 ) ) ;
568+ }
0 commit comments