use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class CreatePageIT method createExistingPageAndSpace.
/**
* Tests that creating a page or a space that already exists displays an error.
*/
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void createExistingPageAndSpace() throws Exception {
// Step 0: Setup the correct environment for the test
EntityReference existingPageReference = getUtil().resolveDocumentReference(getTestClassName() + ".ExistingPage.WebHome");
String existingSpaceName = getTestClassName() + "Existing";
// All these pages are created during this test
getUtil().rest().delete(existingPageReference);
getUtil().rest().deletePage(existingSpaceName, "WebHome");
// create a template to make sure that we have a template to create from
String templateProviderName = TEMPLATE_NAME + "Provider";
String templateContent = "Templates are fun";
String templateTitle = "Funny templates";
createTemplateAndTemplateProvider(templateProviderName, templateContent, templateTitle, false);
// create a page and a space webhome
getUtil().rest().savePage(existingPageReference, "Page that already exists", "Existing page");
getUtil().rest().savePage(new LocalDocumentReference(existingSpaceName, "WebHome"), "Some content", "Existing space");
// Step 1: Create an empty page for a page that already exists
// First we must click on create from a page that already exists as otherwise we won't get the create UI
ViewPage vp = getUtil().gotoPage(existingPageReference);
CreatePagePage createPage = vp.createPage();
createPage.getDocumentPicker().toggleLocationAdvancedEdit();
createPage.getDocumentPicker().setParent(getTestClassName());
createPage.getDocumentPicker().setName("ExistingPage");
String currentURL = getDriver().getCurrentUrl();
createPage.clickCreate();
// make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
// error
assertEquals(currentURL, getDriver().getCurrentUrl());
createPage.waitForErrorMessage();
// Step 2: Create a page from Template for a page that already exists
// restart everything to make sure it's not the error before
vp = getUtil().gotoPage(existingPageReference);
createPage = vp.createPage();
createPage.getDocumentPicker().toggleLocationAdvancedEdit();
createPage.getDocumentPicker().setParent(getTestClassName());
createPage.getDocumentPicker().setName("ExistingPage");
createPage.setTemplate(getTestClassName() + "." + templateProviderName);
currentURL = getDriver().getCurrentUrl();
createPage.clickCreate();
// make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
// error
assertEquals(currentURL, getDriver().getCurrentUrl());
createPage.waitForErrorMessage();
// Step 3: Create a space that already exists
// 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[] { getTestClassName(), "ExistingPage", "WebHome" }, "tocreate=space"));
CreatePagePage createSpace = new CreatePagePage();
// Check that the terminal choice is not displayed in this mode.
assertFalse(createSpace.isTerminalOptionDisplayed());
currentURL = getDriver().getCurrentUrl();
// strip the parameters out of this URL
currentURL = currentURL.substring(0, currentURL.indexOf('?') > 0 ? currentURL.indexOf('?') : currentURL.length());
// Try to create the a space (non-terminal document) that already exist.
createSpace.getDocumentPicker().toggleLocationAdvancedEdit();
createSpace.fillForm(existingSpaceName, "", null, false);
createSpace.clickCreate();
String urlAfterSubmit = getDriver().getCurrentUrl();
urlAfterSubmit = urlAfterSubmit.substring(0, urlAfterSubmit.indexOf('?') > 0 ? urlAfterSubmit.indexOf('?') : urlAfterSubmit.length());
// make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
// error
assertEquals(currentURL, urlAfterSubmit);
createSpace.waitForErrorMessage();
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ImportIT method testImportAsBackup.
@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 testImportAsBackup() {
URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE);
this.sectionPage.attachPackage(fileUrl);
this.sectionPage.selectPackage(BACKUP_PACKAGE);
WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
Assert.assertTrue(importAsBackup.isSelected());
this.sectionPage.importPackage();
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");
// Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
// will race for completion. Let's wait for comments first.
importedPage.openCommentsDocExtraPane();
HistoryPane history = importedPage.openHistoryDocExtraPane();
Assert.assertEquals("JohnDoe", history.getCurrentAuthor());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ImportIT method testImportWhenImportAsBackupIsNotSelected.
@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 testImportWhenImportAsBackupIsNotSelected() {
URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE);
this.sectionPage.attachPackage(fileUrl);
this.sectionPage.selectPackage(BACKUP_PACKAGE);
WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
importAsBackup.click();
Assert.assertFalse(importAsBackup.isSelected());
this.sectionPage.importPackage();
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");
// Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
// will race for completion. Let's wait for comments first.
importedPage.openCommentsDocExtraPane();
HistoryPane history = importedPage.openHistoryDocExtraPane();
Assert.assertEquals("superadmin", history.getCurrentAuthor());
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class CreatePageAndSpaceTest method testCreateUIInteraction.
/**
* Test that the inputs in the create UI are updated, depending on the case.
*/
@Test
public void testCreateUIInteraction() {
// Cleanup of the test space for any leftovers from previous tests.
getUtil().deleteSpace(getTestClassName());
// Create an existent page that will also be the parent of our documents.
String existingPageTitle = "Test Area";
getUtil().createPage(getTestClassName(), "WebHome", "", existingPageTitle);
CreatePagePage createPage = new ViewPage().createPage();
// Check that by default we have an empty title and name and the parent is the current document's space.
assertEquals("", createPage.getDocumentPicker().getTitle());
assertEquals("", createPage.getDocumentPicker().getName());
assertEquals(getTestClassName(), createPage.getDocumentPicker().getParent());
// Check the initial state of the breadcrumb.
createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/");
// Set a new title and check that the page name and the breadcrumb are also updated.
String newTitle = "New Title";
createPage.getDocumentPicker().setTitle(newTitle);
assertEquals(newTitle, createPage.getDocumentPicker().getName());
createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newTitle);
// Set a new page name and check that the breadcrumb is not updated, since we have a title specified.
String newName = "SomeNewName";
createPage.getDocumentPicker().setName(newName);
createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newTitle);
// Clear the title, set a page name and check that the breadcrumb now uses the page name as a fallback.
createPage.getDocumentPicker().setTitle("");
assertEquals("", createPage.getDocumentPicker().getName());
createPage.getDocumentPicker().setName(newName);
createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newName);
// Set a new parent space and check that the breadcrumb is updated.
// Before that, reset the title, just for completeness.
createPage.getDocumentPicker().setTitle(newTitle);
String newSpace = "SomeNewSpace";
createPage.getDocumentPicker().setParent(newSpace);
createPage.waitForLocationPreviewContent("/" + newSpace + "/" + newTitle);
// Set a new parent in nested spaces and check that the breadcrumb is updated.
String newSpaceLevel2 = "Level2";
createPage.getDocumentPicker().setParent(newSpace + "." + newSpaceLevel2);
createPage.waitForLocationPreviewContent("/" + newSpace + "/" + newSpaceLevel2 + "/" + newTitle);
// Clear the parent and check that the breadcrumb is updated, since we are creating a top level document.
createPage.getDocumentPicker().setParent("");
createPage.waitForLocationPreviewContent("/" + newTitle);
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class DeletePageTest method deletePageCanDoRedirect.
/**
* Verify that we can skip the default delete result page and instead redirect to any page we want.
*/
@Test
public void deletePageCanDoRedirect() {
// Set the current page to be any page (doesn't matter if it exists or not)
String pageURL = getUtil().getURL(SPACE_VALUE, PAGE_VALUE + "Whatever");
getUtil().gotoPage(SPACE_VALUE, PAGE_VALUE, DELETE_ACTION, "xredirect=" + pageURL);
ConfirmationPage confirmation = new ConfirmationPage();
confirmation.clickYes();
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"));
}
Aggregations