/** Tests that creating a space works fine. */ @Test @IgnoreBrowser( value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146") public void testCreateSpace() { // create a random space String space = this.getClass().getSimpleName() + ((int) (Math.random() * 1000)); getUtil().deletePage(space, "WebHome"); // start creating a space HomePage homePage = HomePage.gotoPage(); CreateSpacePage createSpace = homePage.createSpace(); WYSIWYGEditPage editSpaceWebhomePage = createSpace.createSpace(space); // expect wysiwyg edit mode for the webhome of the space Assert.assertTrue(getUtil().isInWYSIWYGEditMode()); Assert.assertEquals(space, editSpaceWebhomePage.getMetaDataValue("space")); Assert.assertEquals("WebHome", editSpaceWebhomePage.getMetaDataValue("page")); // The default parent is the home page of the current wiki (XWIKI-7572). Assert.assertEquals("Main.WebHome", editSpaceWebhomePage.getParent()); // and the title the name of the space Assert.assertEquals(space, editSpaceWebhomePage.getDocumentTitle()); }
/** Tests that creating a page or a space that already exists displays an error. */ @Test @IgnoreBrowser( value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146") public void testCreateExistingPage() { String space = this.getClass().getSimpleName(); // 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"; createTemplate(templateProviderName, templateContent, templateTitle, false); // create a page and a space webhome String existingPageName = "ExistingPage"; getUtil().createPage(space, existingPageName, "Page that already exists", "Existing page"); String existingSpace = this.getClass().getSimpleName() + ((int) (Math.random() * 1000)); getUtil().createPage(existingSpace, "WebHome", "{{spaceindex /}}", "New random space"); // 1/ create an empty page that already exists HomePage homePage = HomePage.gotoPage(); CreatePagePage createPage = homePage.createPage(); createPage.setSpace(space); createPage.setPage(existingPageName); createPage.setTerminalPage(true); 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 Assert.assertEquals(currentURL, getDriver().getCurrentUrl()); createPage.waitForErrorMessage(); // 2/ create a page from template that already exists // restart everything to make sure it's not the error before homePage = HomePage.gotoPage(); createPage = homePage.createPage(); createPage.setSpace(space); createPage.setPage(existingPageName); createPage.setTemplate(space + "." + templateProviderName); createPage.setTerminalPage(true); 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 Assert.assertEquals(currentURL, getDriver().getCurrentUrl()); createPage.waitForErrorMessage(); // 3/ create a space that already exists homePage = HomePage.gotoPage(); CreateSpacePage createSpace = homePage.createSpace(); currentURL = getDriver().getCurrentUrl(); // strip the parameters out of this URL currentURL = currentURL.substring( 0, currentURL.indexOf('?') > 0 ? currentURL.indexOf('?') : currentURL.length()); createSpace.createSpace(existingSpace); 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 Assert.assertEquals(currentURL, urlAfterSubmit); Assert.assertTrue(createSpace.hasError()); }