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"));
}
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);
}
}
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);
}
}
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();
}
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"));
}
Aggregations