@@ -551,6 +551,67 @@ def test_copy_page(self):
551
551
552
552
self .assertEqual (Page .objects .drafts ().count () - count , 3 )
553
553
554
+ def test_copy_page_to_explicit_position (self ):
555
+ """
556
+ User should be able to copy a single page and paste it
557
+ in a specific location on another page tree.
558
+ """
559
+ superuser = self .get_superuser ()
560
+ parent = create_page ("parent" , "nav_playground.html" , "en" , published = True )
561
+ child_0001 = create_page ("child-0001" , "nav_playground.html" , "en" , published = True , parent = parent )
562
+ child_0002 = create_page ("child-0002" , "nav_playground.html" , "en" , published = True , parent = parent )
563
+ child_0004 = create_page ("child-0004" , "nav_playground.html" , "en" , published = True , parent = parent )
564
+ child_0003 = create_page ("child-0003" , "nav_playground.html" , "en" , published = True )
565
+
566
+ with self .login_user_context (superuser ):
567
+ child_0003 = self .copy_page (child_0003 , parent , position = 2 )
568
+
569
+ tree = (
570
+ (parent , '0001' ),
571
<
8000
td data-grid-cell-id="diff-4f8ee28fcf66d51c8ea90594450db4eaa52e069a2ad1786b5b66f8e6d36f899e-553-571-2" data-line-anchor="diff-4f8ee28fcf66d51c8ea90594450db4eaa52e069a2ad1786b5b66f8e6d36f899eR571" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionLine-bgColor, var(--diffBlob-addition-bgColor-line));padding-right:24px" tabindex="-1" valign="top" class="focusable-grid-cell diff-text-cell right-side-diff-cell left-side">+ (child_0001 , '00010001' ),
572
+ (child_0002 , '00010002' ),
573
+ (child_0003 , '00010003' ),
574
+ (child_0004 , '00010004' ),
575
+ )
576
+
577
+ for page , path in tree :
578
+ self .assertEqual (self .reload (page .node ).path , path )
579
+
580
+ def test_copy_page_tree_to_explicit_position (self ):
581
+ """
582
+ User should be able to copy a page with descendants and paste it
583
+ in a specific location on another page tree.
584
+ """
585
+ superuser = self .get_superuser ()
586
+ parent = create_page ("parent" , "nav_playground.html" , "en" , published = True )
587
+ child_0001 = create_page ("child-0001" , "nav_playground.html" , "en" , published = True , parent = parent )
588
+ child_0002 = create_page ("child-0002" , "nav_playground.html" , "en" , published = True , parent = parent )
589
+ child_0004 = create_page ("child-0004" , "nav_playground.html" , "en" , published = True , parent = parent )
590
+ child_0003 = create_page ("child-0003" , "nav_playground.html" , "en" , published = True )
591
+ create_page ("child-00030001" , "nav_playground.html" , "en" , published = True , parent = child_0003 )
592
+ create_page ("child-00030002" , "nav_playground.html" , "en" , published = True , parent = child_0003 )
593
+ create_page ("child-00030003" , "nav_playground.html" , "en" , published = True , parent = child_0003 )
594
+
595
+ with self .login_user_context (superuser ):
596
+ child_0003 = self .copy_page (child_0003 , parent , position = 2 )
597
+ child_00030001 = child_0003 .node .get_children ()[0 ].page
598
+ child_00030002 = child_0003 .node .get_children ()[1 ].page
599
+ child_00030003 = child_0003 .node .get_children ()[2 ].page
600
+
601
+ tree = (
602
+ (parent , '0001' ),
603
+ (child_0001 , '00010001' ),
604
+ (child_0002 , '00010002' ),
605
+ (child_0003 , '00010003' ),
606
+ (child_00030001 , '000100030001' ),
607
+ (child_00030002 , '000100030002' ),
608
+ (child_00030003 , '000100030003' ),
609
+ (child_0004 , '00010004' ),
610
+ )
611
+
612
+ for page , path in tree :
613
+ self .assertEqual (self .reload (page .node ).path , path )
614
+
554
615
def test_copy_self_page (self ):
555
616
"""
556
617
Test that a page can be copied via the admin
0 commit comments