@@ -371,4 +371,84 @@ describe('dnd basics', () => {
371
371
await test . expectItemContentsVisibleAndUnchanged ( 'a' , 'b' , 'bb' ) ;
372
372
} ) ;
373
373
} ) ;
374
+
375
+ describe ( 'special drop positions' , ( ) => {
376
+ describe ( 'reparent upwards' , ( ) => {
377
+ it ( 'doesnt reparent in the on normal item' , async ( ) => {
378
+ const test = await new TestUtil ( ) . renderOpenTree ( ) ;
379
+ await test . startDrag ( 'bbb' ) ;
380
+ await test . dragOver ( 'aac' , 'bottom' , 0 ) ;
381
+ await test . drop ( ) ;
382
+ await test . expectItemContentsUnchanged ( 'a' , 'b' ) ;
383
+ await test . expectItemContents ( 'aa' , [
384
+ 'aaa' ,
385
+ 'aab' ,
386
+ 'aac' ,
387
+ 'bbb' ,
388
+ 'aad' ,
389
+ ] ) ;
390
+ } ) ;
391
+
392
+ it ( 'doesnt reparent in the middle of a subtree' , async ( ) => {
393
+ const test = await new TestUtil ( ) . renderTree ( ) ;
394
+ await test . clickItem ( 'a' ) ;
395
+ await test . clickItem ( 'target-parent' ) ;
396
+ await test . startDrag ( 'target' ) ;
397
+ await test . dragOver ( 'ab' , 'bottom' , 0 ) ;
398
+ await test . drop ( ) ;
399
+ await test . expectItemContentsUnchanged ( 'ab' , 'ac' , 'root' ) ;
400
+ await test . expectItemContents ( 'a' , [ 'aa' , 'ab' , 'target' , 'ac' , 'ad' ] ) ;
401
+ } ) ;
402
+
403
+ it ( 'doesnt reparent at the top of a subtree' , async ( ) => {
404
+ const test = await new TestUtil ( ) . renderOpenTree ( ) ;
405
+ await test . startDrag ( 'bbb' ) ;
406
+ await test . dragOver ( 'aaa' , 'top' , 0 ) ;
407
+ await test . drop ( ) ;
408
+ await test . expectItemContentsUnchanged ( 'a' , 'b' ) ;
409
+ await test . expectItemContents ( 'aa' , [
410
+ 'bbb' ,
411
+ 'aaa' ,
412
+ 'aab' ,
413
+ 'aac' ,
414
+ 'aad' ,
415
+ ] ) ;
416
+ } ) ;
417
+
418
+ it ( 'reparents inner level' , async ( ) => {
419
+ const test = await new TestUtil ( ) . renderOpenTree ( ) ;
420
+ await test . startDrag ( 'bbb' ) ;
421
+ await test . dragOver ( 'add' , 'bottom' , 1 ) ;
422
+ await test . drop ( ) ;
423
+ await test . expectItemContentsUnchanged ( 'ad' , 'b' ) ;
424
+ await test . expectItemContents ( 'a' , [ 'aa' , 'ab' , 'ac' , 'ad' , 'bbb' ] ) ;
425
+ } ) ;
426
+
427
+ it ( 'reparents mid level' , async ( ) => {
428
+ const test = await new TestUtil ( ) . renderOpenTree ( ) ;
429
+ await test . startDrag ( 'bbb' ) ;
430
+ await test . dragOver ( 'add' , 'bottom' , 1 ) ;
431
+ await test . drop ( ) ;
432
+ await test . expectItemContentsUnchanged ( 'ad' , 'b' , 'root' ) ;
433
+ await test . expectItemContents ( 'a' , [ 'aa' , 'ab' , 'ac' , 'ad' , 'bbb' ] ) ;
434
+ } ) ;
435
+
436
+ it ( 'reparents outer level' , async ( ) => {
437
+ const test = await new TestUtil ( ) . renderOpenTree ( ) ;
438
+ await test . startDrag ( 'bbb' ) ;
439
+ await test . dragOver ( 'add' , 'bottom' , 0 ) ;
440
+ await test . drop ( ) ;
441
+ await test . expectItemContentsUnchanged ( 'ad' , 'a' , 'b' ) ;
442
+ await test . expectItemContents ( 'root' , [
443
+ 'target-parent' ,
444
+ 'a' ,
445
+ 'bbb' ,
446
+ 'b' ,
447
+ 'c' ,
448
+ 'deep1' ,
449
+ 'special' ,
450
+ ] ) ;
451
+ } ) ;
452
+ } ) ;
453
+ } ) ;
374
454
} ) ;
0 commit comments