Search in sources :

Example 26 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 27 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 28 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 29 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 30 with ViewPage

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

the class SpacesTest method spacesMacro.

@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void spacesMacro() {
    // Create a page with special characters in space name
    // See XE-1228: Broken links displayed in the Spaces widget if a space name contains a colon
    // See XE-1298: Spaces macro doesn't list spaces that contain a colon in their name
    String spaceName = getTestClassName() + ":" + getTestMethodName() + "&";
    String referenceEscapedSpaceName = getTestClassName() + "\\:" + getTestMethodName() + "&";
    // Make sure the new space's WebHome page doesn't exist.
    getUtil().deletePage(spaceName, "WebHome");
    // Create the new space using the UI and verify it leads to the space home page being edited.
    SpacesMacroPage macroPage = SpacesMacroPage.gotoPage();
    macroPage.getSpacesMacroPane().createSpace(spaceName).clickCreate();
    WikiEditPage editPage = new WikiEditPage();
    // Verify that space creation uses the space name as the space home page's title
    assertEquals(spaceName, editPage.getDocumentTitle());
    // Verify that the space created is correct by looking at the generate metadata in the HTML header
    // (they contain the space reference amongst other data).
    // Note: the value will be escaped since it is the space reference, not the space name.
    assertEquals(referenceEscapedSpaceName, editPage.getMetaDataValue("space"));
    // Go back to the Spaces Macro page and verify that the link to space index works
    // First, save the space's home page
    editPage.clickSaveAndContinue();
    macroPage = SpacesMacroPage.gotoPage();
    macroPage.getSpacesMacroPane().clickSpaceIndex(referenceEscapedSpaceName);
    // Assert the content of the space index live table.
    LiveTableElement spaceIndexLiveTable = new SpaceIndexPage().getLiveTable();
    spaceIndexLiveTable.waitUntilReady();
    assertEquals(1, spaceIndexLiveTable.getRowCount());
    assertTrue(spaceIndexLiveTable.hasRow("Page", "WebHome"));
    assertTrue(spaceIndexLiveTable.hasRow("Space", referenceEscapedSpaceName));
    // Go back to the Spaces Macro page and this time verify that the link to the space home page works
    macroPage = SpacesMacroPage.gotoPage();
    ViewPage spaceHomePage = macroPage.getSpacesMacroPane().clickSpaceHome(referenceEscapedSpaceName);
    assertEquals(spaceName, spaceHomePage.getDocumentTitle());
}
Also used : LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) SpacesMacroPage(org.xwiki.index.test.po.SpacesMacroPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) SpaceIndexPage(org.xwiki.index.test.po.SpaceIndexPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

ViewPage (org.xwiki.test.ui.po.ViewPage)93 Test (org.junit.Test)75 AbstractTest (org.xwiki.test.ui.AbstractTest)41 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)26 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)18 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)11 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)8 FormElement (org.xwiki.test.ui.po.FormElement)7 HistoryPane (org.xwiki.test.ui.po.HistoryPane)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WebElement (org.openqa.selenium.WebElement)6 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)6 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)6 URL (java.net.URL)5 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)5 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)5 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)5