Search in sources :

Example 1 with CopyOrRenameStatusPage

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

the class CopyPageTest method testCopyOverwritePage.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testCopyOverwritePage() throws Exception {
    String sourceSpaceName = getTestClassName();
    String sourcePageName = getTestMethodName();
    String targetSpaceName = getTestClassName() + "Copy";
    String targetPageName = getTestMethodName() + "Copy";
    // Delete page that may already exist
    getUtil().rest().deletePage(sourceSpaceName, sourcePageName);
    getUtil().rest().deletePage(targetSpaceName, targetPageName);
    // Create a new page that will be overwritten.
    getUtil().rest().savePage(new LocalDocumentReference(targetSpaceName, targetPageName), OVERWRITTEN_PAGE_CONTENT, targetPageName);
    // Create a new page that will be copied.
    ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName);
    // Click on Copy from the Page top menu.
    viewPage.copy();
    CopyPage copyPage = new CopyPage();
    // Fill the target destination the page to be copied to.
    DocumentPicker documentPicker = copyPage.getDocumentPicker();
    documentPicker.setTitle(targetPageName);
    documentPicker.browseDocuments();
    DocumentPickerModal documentPickerModal = new DocumentPickerModal();
    documentPickerModal.waitForDocumentSelected(sourceSpaceName, "WebHome").selectDocument(targetSpaceName, "WebHome");
    documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName));
    Assert.assertEquals(targetSpaceName, copyPage.getTargetSpaceName());
    // Click copy button
    CopyOverwritePromptPage copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    // Check overwrite warning
    Assert.assertEquals(OVERWRITE_PROMPT1 + targetSpaceName + '.' + targetPageName + OVERWRITE_PROMPT2, copyOverwritePrompt.getWarningMessage());
    // Cancel the copy
    viewPage = copyOverwritePrompt.clickCancelButton();
    // Verify that we have been sent back to the original page
    Assert.assertEquals(sourcePageName, viewPage.getDocumentTitle());
    // Click on Copy from the Page top menu.
    viewPage.copy();
    copyPage = new CopyPage();
    // Fill the target destination the page to be copied to.
    copyPage.getDocumentPicker().toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
    // Click copy button
    copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    // Click change target
    copyOverwritePrompt.clickChangeTargetButton();
    copyPage = new CopyPage();
    // Check the source document
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getSourcePageName());
    // Check the default target document.
    documentPicker = copyPage.getDocumentPicker();
    Assert.assertEquals(sourcePageName, documentPicker.getTitle());
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getTargetPageName());
    // Fill the target destination the page to be copied to.
    documentPicker.setTitle("My copy").toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
    // Copy and confirm overwrite
    copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    CopyOrRenameStatusPage copyStatusPage = copyOverwritePrompt.clickCopyButton().waitUntilFinished();
    // Check successful copy confirmation
    Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage());
    viewPage = copyStatusPage.gotoNewPage();
    // Verify that the title of the copy has been updated (independent from the name of the copy).
    Assert.assertEquals("My copy", viewPage.getDocumentTitle());
    Assert.assertEquals(PAGE_CONTENT, viewPage.getContent());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) CopyOrRenameStatusPage(org.xwiki.test.ui.po.CopyOrRenameStatusPage) CopyPage(org.xwiki.index.test.po.CopyPage) DocumentPickerModal(org.xwiki.index.tree.test.po.DocumentPickerModal) CopyOverwritePromptPage(org.xwiki.test.ui.po.CopyOverwritePromptPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentPicker(org.xwiki.test.ui.po.DocumentPicker) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 2 with CopyOrRenameStatusPage

use of org.xwiki.test.ui.po.CopyOrRenameStatusPage 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)

Example 3 with CopyOrRenameStatusPage

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

the class CopyPageTest method testCopyPage.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testCopyPage() throws Exception {
    String sourceSpaceName = getTestClassName();
    String sourcePageName = getTestMethodName();
    String targetSpaceName = getTestClassName() + "Copy";
    String targetPageName = getTestMethodName() + "Copy";
    // Delete page that may already exist
    getUtil().rest().deletePage(sourceSpaceName, sourcePageName);
    getUtil().rest().deletePage(targetSpaceName, targetPageName);
    // Create a new page that will be copied.
    ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName);
    // Add an attachment to verify that it's version is not incremented in the target document (XWIKI-8157).
    // FIXME: Remove the following wait when XWIKI-6688 is fixed.
    viewPage.waitForDocExtraPaneActive("comments");
    AttachmentsPane attachmentsPane = viewPage.openAttachmentsDocExtraPane();
    attachmentsPane.setFileToUpload(getClass().getResource("/image.gif").getPath());
    attachmentsPane.waitForUploadToFinish("image.gif");
    Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif"));
    // Click on Copy from the Page top menu.
    viewPage.copy();
    CopyPage copyPage = new CopyPage();
    // Check the source document
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getSourcePageName());
    // Check the default target document.
    DocumentPicker documentPicker = copyPage.getDocumentPicker();
    Assert.assertEquals(sourcePageName, documentPicker.getTitle());
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getTargetPageName());
    // Fill the target destination the page to be copied to.
    documentPicker.setTitle(targetPageName);
    // The target page name is updated based on the entered title.
    Assert.assertEquals(targetPageName, copyPage.getTargetPageName());
    documentPicker.waitForLocation(Arrays.asList("", sourceSpaceName, targetPageName));
    // Select a new parent document.
    documentPicker.toggleLocationAdvancedEdit().setParent(targetSpaceName);
    documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName));
    // Click copy button
    CopyOrRenameStatusPage copyStatusPage = copyPage.clickCopyButton().waitUntilFinished();
    // Check successful copy confirmation
    Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage());
    viewPage = copyStatusPage.gotoNewPage();
    Assert.assertEquals(Arrays.asList("", targetSpaceName, targetPageName), viewPage.getBreadcrumb().getPath());
    // Verify that the copied title is modified to be the new page name since it was set to be the page name
    // originally.
    Assert.assertEquals(targetPageName, viewPage.getDocumentTitle());
    Assert.assertEquals(PAGE_CONTENT, viewPage.getContent());
    // Verify the attachment version is the same (XWIKI-8157).
    // FIXME: Remove the following wait when XWIKI-6688 is fixed.
    viewPage.waitForDocExtraPaneActive("comments");
    attachmentsPane = viewPage.openAttachmentsDocExtraPane();
    Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif"));
}
Also used : CopyOrRenameStatusPage(org.xwiki.test.ui.po.CopyOrRenameStatusPage) CopyPage(org.xwiki.index.test.po.CopyPage) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentPicker(org.xwiki.test.ui.po.DocumentPicker) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Aggregations

Test (org.junit.Test)3 CopyOrRenameStatusPage (org.xwiki.test.ui.po.CopyOrRenameStatusPage)3 ViewPage (org.xwiki.test.ui.po.ViewPage)3 CopyPage (org.xwiki.index.test.po.CopyPage)2 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)2 DocumentPicker (org.xwiki.test.ui.po.DocumentPicker)2 DocumentPickerModal (org.xwiki.index.tree.test.po.DocumentPickerModal)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 AbstractTest (org.xwiki.test.ui.AbstractTest)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 CopyOverwritePromptPage (org.xwiki.test.ui.po.CopyOverwritePromptPage)1 RenamePage (org.xwiki.test.ui.po.RenamePage)1