Search in sources :

Example 61 with ViewPage

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

the class CreatePageAndSpaceTest method createSpaceAndPage.

@Test
public void createSpaceAndPage() {
    // Test 1:  Test Space creation when on an existing page (i.e. the space creation UI will open to ask for the
    // space name.
    // Clean up before the test starts
    // Note that we introduce a special character to verify we support non-ASCII characters in page and space names
    String existingPageName = getTestMethodName() + "\u0219";
    String spaceName = getTestClassName() + "\u0219";
    getUtil().deleteSpace(spaceName);
    getUtil().deletePage(spaceName, existingPageName);
    // Create the page that's supposed to exist.
    getUtil().createPage(spaceName, existingPageName, "Dummy", "Dummy Title");
    // Since the Flamingo skin no longer supports creating a space from the UI, trigger the Space creation UI
    // by using directly the direct action URL for it.
    getUtil().gotoPage(getUtil().getURL("create", new String[] { spaceName, existingPageName }, "tocreate=space"));
    CreatePagePage cpp = new CreatePagePage();
    EditPage editSpaceWebhomePage = cpp.createPage("", spaceName);
    assertEquals(spaceName, editSpaceWebhomePage.getMetaDataValue("space"));
    assertEquals("WebHome", editSpaceWebhomePage.getMetaDataValue("page"));
    // The parent is the current document from where the space was created.
    assertEquals(spaceName + "." + existingPageName, editSpaceWebhomePage.getParent());
    // and the title the name of the space
    assertEquals(spaceName, editSpaceWebhomePage.getDocumentTitle());
    // Test 2:  Test Space creation when on an non-existing page (i.e. the create action will lead to editing the
    // current document - No space name will be asked).
    // Since the Flamingo skin no longer supports creating a space from the UI, trigger the Space creation UI
    // by using directly the direct action URL for it. This time on a non-exsiting page.
    getUtil().gotoPage(getUtil().getURL("create", new String[] { spaceName, "NonExistingPage" }, "tocreate=space&type=blank"));
    EditPage editPage = new EditPage();
    assertEquals(spaceName, editPage.getMetaDataValue("space"));
    assertEquals("NonExistingPage", editPage.getMetaDataValue("page"));
    // The default parent is the home page of the current wiki (XWIKI-7572).
    assertEquals("Main.WebHome", editPage.getParent());
    // and the title the name of the space
    assertEquals("NonExistingPage", editPage.getDocumentTitle());
    // Test 3:  Test Terminal Page creation when on an existing page (i.e. the space creation UI will open to ask
    // for the space + page names.
    // Note that we introduce a special character to verify we support non-ASCII characters in page names
    String newPageName = getTestMethodName() + "2" + "\u0219";
    getUtil().deletePage(spaceName, newPageName);
    // Navigate to an existing page before clicking on the Add button
    ViewPage vp = getUtil().gotoPage(spaceName, existingPageName);
    cpp = vp.createPage();
    editPage = cpp.createPage(spaceName, newPageName, true);
    // Verify the title field
    assertEquals(newPageName, editPage.getDocumentTitle());
    // Verify the document name in the metadata
    assertEquals(newPageName, editPage.getMetaDataValue("page"));
    // Save the page to verify it can be saved with a non-ascii name
    ViewPage savedPage = editPage.clickSaveAndView();
    assertEquals(newPageName, savedPage.getMetaDataValue("page"));
}
Also used : CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) ViewPage(org.xwiki.test.ui.po.ViewPage) EditPage(org.xwiki.test.ui.po.editor.EditPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 62 with ViewPage

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

the class CreatePageNestedDocumentsTest method createNestedDocumentsFromURL.

@Test
public void createNestedDocumentsFromURL() {
    // Create and assert each nested document.
    for (DocumentReference pageReference : nestedDocuments) {
        // Navigate from URL to the page in view mode, using the no-WebHome URL, e.g. /A instead of /A/WebHome
        SpaceReference spaceReference = pageReference.getLastSpaceReference();
        ViewPage viewPage = getUtil().gotoPage(spaceReference);
        // It should not exist and we will create it.
        assertFalse(String.format("Document [%s] already exists", pageReference), viewPage.exists());
        new DocumentDoesNotExistPage().clickEditThisPageToCreate();
        new CreatePagePage().clickCreate();
        EditPage editPage = new EditPage();
        viewPage = editPage.clickSaveAndView();
        // Check that we created the right page
        assertCreatedNestedDocument(pageReference, viewPage);
    }
}
Also used : DocumentDoesNotExistPage(org.xwiki.test.ui.po.DocumentDoesNotExistPage) SpaceReference(org.xwiki.model.reference.SpaceReference) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) ViewPage(org.xwiki.test.ui.po.ViewPage) EditPage(org.xwiki.test.ui.po.editor.EditPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 63 with ViewPage

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

the class CreatePageNestedDocumentsTest method createNestedDocumentsFromUI.

@Test
public void createNestedDocumentsFromUI() {
    // Create the homepage if it does not exist and start the test from there.
    DocumentReference homepage = new DocumentReference("xwiki", "Main", "WebHome");
    ViewPage viewPage = getUtil().createPage(homepage, "", "Home Page");
    // Create and assert each nested document.
    for (DocumentReference pageReference : nestedDocuments) {
        SpaceReference spaceReference = pageReference.getLastSpaceReference();
        // Click the create button from the previous page.
        CreatePagePage createPage = viewPage.createPage();
        // Determine the values to fill in the form.
        WikiReference wikiReference = spaceReference.getWikiReference();
        EntityReference localParentSpaceReference = spaceReference.removeParent(wikiReference).getParent();
        String spaceReferenceString = getUtil().serializeReference(localParentSpaceReference);
        String pageName = spaceReference.getName();
        // Fill in the form and submit it, using the space name as title.
        EditPage editPage = createPage.createPage(pageName, spaceReferenceString, null, false);
        // Save the page.
        viewPage = editPage.clickSaveAndView();
        // Check that we created the right page
        assertCreatedNestedDocument(pageReference, viewPage);
    }
}
Also used : SpaceReference(org.xwiki.model.reference.SpaceReference) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) EntityReference(org.xwiki.model.reference.EntityReference) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiReference(org.xwiki.model.reference.WikiReference) EditPage(org.xwiki.test.ui.po.editor.EditPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 64 with ViewPage

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

the class DeletePageTest method deletePageCanSkipConfirmationAndDoARedirect.

/**
 * Verify that we can delete a page without showing the confirmation dialog box and that we can redirect to any page
 * we want when the delete is done.
 */
@Test
public void deletePageCanSkipConfirmationAndDoARedirect() {
    String pageURL = getUtil().getURL(SPACE_VALUE, PAGE_VALUE + "Whatever");
    getUtil().gotoPage(SPACE_VALUE, PAGE_VALUE, DELETE_ACTION, "confirm=1&xredirect=" + pageURL);
    ViewPage vp = new ViewPage();
    // Since the page PAGE_VALUE + "Whatever" doesn't exist the View Action will redirect to the Nested Document
    // SPACE_VALUE + "." + PAGE_VALUE + "Whatever + ".WebHome".
    assertEquals(SPACE_VALUE + "." + PAGE_VALUE + "Whatever", vp.getMetaDataValue("space"));
    assertEquals("WebHome", vp.getMetaDataValue("page"));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 65 with ViewPage

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

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