@@ -79,6 +79,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
79
79
} )
80
80
) ;
81
81
82
+
82
83
it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
83
84
84
85
// given
@@ -163,6 +164,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
163
164
} )
164
165
) ;
165
166
167
+
166
168
it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
167
169
168
170
// given
@@ -223,6 +225,81 @@ describe('provider/zeebe - InputOutputParameter', function() {
223
225
} )
224
226
) ;
225
227
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
+
226
303
} ) ;
227
304
228
305
@@ -247,6 +324,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
247
324
} )
248
325
) ;
249
326
327
+
250
328
it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
251
329
252
330
// given
@@ -331,6 +409,7 @@ describe('provider/zeebe - InputOutputParameter', function() {
331
409
} )
332
410
) ;
333
411
412
+
334
413
it ( 'should display' , inject ( async function ( elementRegistry , selection ) {
335
414
336
415
// given
@@ -391,6 +470,80 @@ describe('provider/zeebe - InputOutputParameter', function() {
391
470
} )
392
471
) ;
393
472
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
+
394
547
} ) ;
395
548
396
549
} ) ;
@@ -410,3 +563,6 @@ function getOutput(element, idx) {
410
563
return ( getOutputParameters ( element ) || [ ] ) [ idx ] ;
411
564
}
412
565
566
+ function nextTick ( ) {
567
+ return new Promise ( resolve => setTimeout ( resolve , 0 ) ) ;
568
+ }
0 commit comments