Search in sources :

Example 6 with CreatePagePage

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

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

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

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

the class OfficeImporterTest method importFile.

/**
 * Import an office file in the wiki.
 *
 * @param fileName name of the file to import (the file should be located in test /resources/ folder)
 * @param splitByHeadings either the option splitByHeadings should be use or not
 * @return the result page
 */
private ViewPage importFile(String fileName, boolean splitByHeadings) {
    ViewPage page = getUtil().gotoPage(new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome"));
    CreatePagePage createPage = page.createPage();
    createPage.setType("office");
    createPage.clickCreate();
    OfficeImporterPage officeImporterPage = new OfficeImporterPage();
    officeImporterPage.setFile(new File(getClass().getResource(fileName).getPath()));
    officeImporterPage.setFilterStyle(true);
    officeImporterPage.setSplitDocument(splitByHeadings);
    OfficeImporterResultPage officeImporterResultPage = officeImporterPage.clickImport();
    assertEquals("Conversion succeeded. You can view the result, or you can Go back to convert another document.", officeImporterResultPage.getMessage());
    return officeImporterResultPage.viewResult();
}
Also used : CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) OfficeImporterPage(org.xwiki.officeimporter.test.po.OfficeImporterPage) OfficeImporterResultPage(org.xwiki.officeimporter.test.po.OfficeImporterResultPage) ViewPage(org.xwiki.test.ui.po.ViewPage) File(java.io.File) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 10 with CreatePagePage

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

the class NewPagePanelTest method testCreatePageFromPanel.

/**
 * Tests if a new page can be created using the create page panel.
 */
@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 testCreatePageFromPanel() {
    NewPagePanel newPagePanel = NewPagePanel.gotoPage();
    CreatePagePage createPagePage = newPagePanel.createPage(getTestClassName(), getTestMethodName());
    createPagePage.clickCreate();
    WikiEditPage editPage = new WikiEditPage();
    Assert.assertEquals(getTestMethodName(), editPage.getDocumentTitle());
    Assert.assertEquals("WebHome", editPage.getMetaDataValue("page"));
    Assert.assertEquals(getTestClassName() + "." + getTestMethodName(), editPage.getMetaDataValue("space"));
}
Also used : NewPagePanel(org.xwiki.panels.test.po.NewPagePanel) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)10 Test (org.junit.Test)9 AbstractTest (org.xwiki.test.ui.AbstractTest)9 ViewPage (org.xwiki.test.ui.po.ViewPage)8 EditPage (org.xwiki.test.ui.po.editor.EditPage)5 DocumentReference (org.xwiki.model.reference.DocumentReference)4 EntityReference (org.xwiki.model.reference.EntityReference)3 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)3 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)3 SpaceReference (org.xwiki.model.reference.SpaceReference)2 OfficeImporterPage (org.xwiki.officeimporter.test.po.OfficeImporterPage)2 DocumentDoesNotExistPage (org.xwiki.test.ui.po.DocumentDoesNotExistPage)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 WebElement (org.openqa.selenium.WebElement)1 TemplateProviderInlinePage (org.xwiki.administration.test.po.TemplateProviderInlinePage)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 WikiReference (org.xwiki.model.reference.WikiReference)1 OfficeImporterResultPage (org.xwiki.officeimporter.test.po.OfficeImporterResultPage)1 NewPagePanel (org.xwiki.panels.test.po.NewPagePanel)1