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