Search in sources :

Example 1 with DeletingPage

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

the class DeletePageTest method deleteChildren.

/**
 * Test that when you delete a page and you select "affect children", it delete children properly. It also test
 * the opposite.
 *
 * @since 7.2RC1
 */
@Test
public void deleteChildren() {
    // Initialize the parent
    DocumentReference parentReference = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome");
    ViewPage parentPage = getUtil().createPage(parentReference, "Content", "Parent");
    // Test 1: Try to delete it to make sure we don't have the "affect children" option yet
    ConfirmationPage confirmationPage = parentPage.delete();
    assertFalse(confirmationPage.hasAffectChildrenOption());
    // Initialize the children pages
    final int NB_CHILDREN = 3;
    DocumentReference[] childrenReferences = new DocumentReference[NB_CHILDREN];
    for (int i = 0; i < NB_CHILDREN; ++i) {
        childrenReferences[i] = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName(), "Child_" + (i + 1)), "WebHome");
        getUtil().createPage(childrenReferences[i], "Content", "Child " + (i + 1));
    }
    // Test 2: when you don't select "affect children", the children are not deleted
    parentPage = getUtil().gotoPage(parentReference);
    confirmationPage = parentPage.delete();
    assertTrue(confirmationPage.hasAffectChildrenOption());
    confirmationPage.setAffectChildren(false);
    DeletingPage deletingPage = confirmationPage.confirmDeletePage();
    deletingPage.waitUntilIsTerminated();
    deletingPage.waitUntilSuccessMessage();
    assertEquals("The page has been deleted.", deletingPage.getSuccessMessage());
    // Check the page have been effectively removed
    ViewPage page = getUtil().gotoPage(parentReference);
    assertFalse(page.exists());
    // But not the children
    for (int i = 0; i < NB_CHILDREN; ++i) {
        page = getUtil().gotoPage(childrenReferences[i]);
        assertTrue(page.exists());
    }
    // Test 3: when you select "affect children", the children are deleted too
    parentPage = getUtil().createPage(parentReference, "Content", "Parent");
    confirmationPage = parentPage.delete();
    assertTrue(confirmationPage.hasAffectChildrenOption());
    confirmationPage.setAffectChildren(true);
    deletingPage = confirmationPage.confirmDeletePage();
    deletingPage.waitUntilIsTerminated();
    deletingPage.waitUntilSuccessMessage();
    // Check the page have been effectively removed
    page = getUtil().gotoPage(parentReference);
    assertFalse(page.exists());
    // And also the children
    for (int i = 0; i < NB_CHILDREN; ++i) {
        page = getUtil().gotoPage(childrenReferences[i]);
        assertFalse(page.exists());
    }
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 2 with DeletingPage

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

the class DeletePageTest method deleteOkWhenConfirming.

@Test
public void deleteOkWhenConfirming() {
    ConfirmationPage confirmationPage = this.viewPage.delete();
    // This tests for regression of XWIKI-1388
    assertNotNull("The interface should not show the user as logged out while deleting page", confirmationPage.getCurrentUser());
    confirmationPage.clickYes();
    DeletingPage deletingPage = new DeletingPage();
    deletingPage.waitUntilIsTerminated();
    // Note: it's better to wait instead of using isSuccess() since there could be some timeframe between
    // the hiding of the progress UI and the display of the success message.
    deletingPage.waitUntilSuccessMessage();
    assertEquals(CONFIRMATION, deletingPage.getSuccessMessage());
    DeletePageOutcomePage deleteOutcome = deletingPage.getDeletePageOutcomePage();
    assertEquals(LOGGED_USERNAME, deleteOutcome.getPageDeleter());
    assertEquals(DOCUMENT_NOT_FOUND, deleteOutcome.getMessage());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) DeletePageOutcomePage(org.xwiki.test.ui.po.DeletePageOutcomePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 3 with DeletingPage

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

the class DeletePageTest method deleteTerminalAndNonTerminalPages.

/**
 * Verify that when you delete a terminal and a non terminal page sharing the same location, both deleted versions
 * are present in the recycle bin list when you hit the location afterwards.
 * @see: "XWIKI-12563: Cannot restore a terminal page from its location"
 * @since 7.2RC1
 */
@Test
public void deleteTerminalAndNonTerminalPages() {
    DocumentReference terminalPageRef = new DocumentReference("xwiki", Arrays.asList(getTestClassName()), getTestMethodName());
    DocumentReference nonTerminalPageRef = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome");
    // Clean up.
    getUtil().deletePage(terminalPageRef);
    getUtil().deletePage(nonTerminalPageRef);
    // Create the non terminal page.
    ViewPage nonTerminalPage = getUtil().createPage(nonTerminalPageRef, "Content", "Title");
    // Delete it
    nonTerminalPage.delete().clickYes();
    DeletingPage deletingPage = new DeletingPage();
    deletingPage.waitUntilIsTerminated();
    // Look at the recycle bin
    DeletePageOutcomePage deletePageOutcomePage = deletingPage.getDeletePageOutcomePage();
    assertFalse(deletePageOutcomePage.hasTerminalPagesInRecycleBin());
    // Create the terminal page.
    ViewPage terminalPage = getUtil().createPage(terminalPageRef, "Content", "Title");
    // Delete it
    terminalPage.delete().clickYes();
    deletingPage.waitUntilIsTerminated();
    // Look at the recycle bin
    deletePageOutcomePage = deletingPage.getDeletePageOutcomePage();
    assertTrue(deletePageOutcomePage.hasTerminalPagesInRecycleBin());
    // Delete both version in the recycle bin
    deletePageOutcomePage.clickDeletePage();
    deletePageOutcomePage.clickDeleteTerminalPage();
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DeletePageOutcomePage(org.xwiki.test.ui.po.DeletePageOutcomePage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 4 with DeletingPage

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

the class RestoreDeletedPageTest method restore.

/**
 * @see "XWIKI-9421: Attachment version is incremented when a document is restored from recycle bin"
 */
@Test
public void restore() throws Exception {
    // Clean up.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    // Create a new page.
    ViewPage page = getUtil().createPage(getTestClassName(), getTestMethodName(), "Once upon a time..", "A story");
    // Add an attachment.
    page.openAttachmentsDocExtraPane().setFileToUpload(getClass().getResource("/SmallAttachment.txt").getPath());
    // Delete the page.
    page.delete().clickYes();
    DeletingPage deletingPage = new DeletingPage();
    deletingPage.waitUntilIsTerminated();
    // Restore the page.
    page = deletingPage.getDeletePageOutcomePage().clickRestore();
    // Check the page title and content.
    assertEquals("A story", page.getDocumentTitle());
    assertEquals("Once upon a time..", page.getContent());
    // Check document version/history.
    HistoryPane historyPane = page.openHistoryDocExtraPane();
    assertEquals("2.1", historyPane.getCurrentVersion());
    // Check the attachment.
    AttachmentsPane attachmentsPane = page.openAttachmentsDocExtraPane();
    assertEquals(1, attachmentsPane.getNumberOfAttachments());
    assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("SmallAttachment.txt"));
    // Check the attachment content.
    attachmentsPane.getAttachmentLink("SmallAttachment.txt").click();
    Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 5 with DeletingPage

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

the class OfficeImporterTest method deletePageWithChildren.

/**
 * Delete a page with all its children.
 *
 * @param pageToDelete the page to delete
 */
private void deletePageWithChildren(ViewPage pageToDelete) {
    ConfirmationPage confirmationPage = pageToDelete.delete();
    if (confirmationPage.hasAffectChildrenOption()) {
        confirmationPage.setAffectChildren(true);
    }
    DeletingPage deletingPage = confirmationPage.confirmDeletePage();
    deletingPage.waitUntilIsTerminated();
    assertTrue(deletingPage.isSuccess());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage)

Aggregations

DeletingPage (org.xwiki.test.ui.po.DeletingPage)5 Test (org.junit.Test)4 AbstractTest (org.xwiki.test.ui.AbstractTest)4 ConfirmationPage (org.xwiki.test.ui.po.ConfirmationPage)3 ViewPage (org.xwiki.test.ui.po.ViewPage)3 DocumentReference (org.xwiki.model.reference.DocumentReference)2 DeletePageOutcomePage (org.xwiki.test.ui.po.DeletePageOutcomePage)2 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 HistoryPane (org.xwiki.test.ui.po.HistoryPane)1