Search in sources :

Example 1 with RenamePage

use of org.xwiki.test.ui.po.RenamePage in project xwiki-platform by xwiki.

the class RenamePageTest method convertNestedPageToTerminalPage.

// Convert a nested page to a terminal page
@Test
public void convertNestedPageToTerminalPage() throws Exception {
    // Clean-up: delete the pages that will be used in this test
    getUtil().rest().deletePage("1", "2");
    getUtil().rest().delete(getUtil().resolveDocumentReference("1.2.WebHome"));
    // Create 1.2.WebHome
    getUtil().createPage(Arrays.asList("1", "2"), "WebHome", "", "");
    // Go to 1.2.WebHome to start the test
    getUtil().gotoPage(Arrays.asList("1", "2"), "WebHome", "", "");
    ViewPage vp = new ViewPage();
    // Go to the Rename page view for 1.2.WebHome and check the Terminal checkbox. We also need to uncheck the Auto
    // Redirect checkbox so the page 1.2.WebHome will not appear as existing after the Rename operation.
    RenamePage renamePage = vp.rename();
    renamePage.setTerminal(true);
    renamePage.setAutoRedirect(false);
    renamePage.clickRenameButton().waitUntilFinished();
    // Test if 1.2.WebHome has been renamed to 1.2 (1.2.WebHome doesn't exist while 1.2 exists)
    assertTrue("Page 1.2 doesn't exist!", getUtil().pageExists(Arrays.asList("1"), "2"));
    assertFalse("Page 1.2.WebHome exists!", getUtil().pageExists(Arrays.asList("1", "2"), "WebHome"));
}
Also used : RenamePage(org.xwiki.test.ui.po.RenamePage) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 2 with RenamePage

use of org.xwiki.test.ui.po.RenamePage in project xwiki-platform by xwiki.

the class RenamePageTest method renamePageCheckConfirmationPreserveChildrenUpdateLinksSetAutoRedirect.

// Rename a page with children, update the backlinks and test the Auto Redirect feature
@Test
public void renamePageCheckConfirmationPreserveChildrenUpdateLinksSetAutoRedirect() throws Exception {
    // Clean-up: delete the pages that will be used in this test
    getUtil().rest().deletePage("My", "Page");
    getUtil().rest().delete(getUtil().resolveDocumentReference("1.2.WebHome"));
    getUtil().rest().delete(getUtil().resolveDocumentReference("1.2.3.WebHome"));
    getUtil().rest().delete(getUtil().resolveDocumentReference("A.B.2.WebHome"));
    getUtil().rest().delete(getUtil().resolveDocumentReference("A.B.2.3.WebHome"));
    // Create the needed pages
    getUtil().createPage(Arrays.asList("1", "2"), "WebHome", "", "");
    getUtil().createPage(Arrays.asList("1", "2", "3"), "WebHome", "", "");
    // We set the content to "[[1.2.WebHome]]" to test the "Update Links" feature
    getUtil().createPage("My", "Page", "[[1.2.WebHome]]", "");
    // Go to 1.2.WebHome to start the test
    getUtil().gotoPage(Arrays.asList("1", "2"), "WebHome", "", "");
    ViewPage vp = new ViewPage();
    // Go to the Rename page view for 1.2.WebHome.
    RenamePage renamePage = vp.rename();
    // Check the "Preserve Children", "Update Links" & "Auto Redirect" checkboxes.
    renamePage.setPreserveChildren(true);
    renamePage.setUpdateLinks(true);
    renamePage.setAutoRedirect(true);
    // Set the new parent as "A.B"
    renamePage.getDocumentPicker().setParent("A.B");
    CopyOrRenameStatusPage renameStatusPage = renamePage.clickRenameButton().waitUntilFinished();
    // Check successful Rename confirmation
    assertEquals(RENAME_SUCCESSFUL, renameStatusPage.getInfoMessage());
    // Test the Rename operation: we need to have 2.WebHome and 2.3.WebHome under A.B
    assertTrue("Page A.B.2.WebHome doesn't exist!", getUtil().pageExists(Arrays.asList("A", "B", "2"), "WebHome"));
    assertTrue("Page A.B.2.3.WebHome doesn't exist!", getUtil().pageExists(Arrays.asList("A", "B", "2", "3"), "WebHome"));
    // Test the Auto Redirect: when visiting the original pages you need to be redirected to the new locations
    getUtil().gotoPage(Arrays.asList("1", "2"), "WebHome", "view", "");
    assertEquals("/A/B/2", vp.getBreadcrumbContent());
    getUtil().gotoPage(Arrays.asList("1", "2", "3"), "WebHome", "view", "");
    assertEquals("/A/B/2/3", vp.getBreadcrumbContent());
    // Test the Update Links feature: the content of the page needs to point to the new location
    assertEquals("[[A.B.2.WebHome]]", getUtil().gotoPage("My", "Page").editWiki().getContent());
}
Also used : CopyOrRenameStatusPage(org.xwiki.test.ui.po.CopyOrRenameStatusPage) RenamePage(org.xwiki.test.ui.po.RenamePage) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 AbstractTest (org.xwiki.test.ui.AbstractTest)2 RenamePage (org.xwiki.test.ui.po.RenamePage)2 ViewPage (org.xwiki.test.ui.po.ViewPage)2 CopyOrRenameStatusPage (org.xwiki.test.ui.po.CopyOrRenameStatusPage)1