use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class SpacesTest method spacesMacro.
@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 spacesMacro() {
// Create a page with special characters in space name
// See XE-1228: Broken links displayed in the Spaces widget if a space name contains a colon
// See XE-1298: Spaces macro doesn't list spaces that contain a colon in their name
String spaceName = getTestClassName() + ":" + getTestMethodName() + "&";
String referenceEscapedSpaceName = getTestClassName() + "\\:" + getTestMethodName() + "&";
// Make sure the new space's WebHome page doesn't exist.
getUtil().deletePage(spaceName, "WebHome");
// Create the new space using the UI and verify it leads to the space home page being edited.
SpacesMacroPage macroPage = SpacesMacroPage.gotoPage();
macroPage.getSpacesMacroPane().createSpace(spaceName).clickCreate();
WikiEditPage editPage = new WikiEditPage();
// Verify that space creation uses the space name as the space home page's title
assertEquals(spaceName, editPage.getDocumentTitle());
// Verify that the space created is correct by looking at the generate metadata in the HTML header
// (they contain the space reference amongst other data).
// Note: the value will be escaped since it is the space reference, not the space name.
assertEquals(referenceEscapedSpaceName, editPage.getMetaDataValue("space"));
// Go back to the Spaces Macro page and verify that the link to space index works
// First, save the space's home page
editPage.clickSaveAndContinue();
macroPage = SpacesMacroPage.gotoPage();
macroPage.getSpacesMacroPane().clickSpaceIndex(referenceEscapedSpaceName);
// Assert the content of the space index live table.
LiveTableElement spaceIndexLiveTable = new SpaceIndexPage().getLiveTable();
spaceIndexLiveTable.waitUntilReady();
assertEquals(1, spaceIndexLiveTable.getRowCount());
assertTrue(spaceIndexLiveTable.hasRow("Page", "WebHome"));
assertTrue(spaceIndexLiveTable.hasRow("Space", referenceEscapedSpaceName));
// Go back to the Spaces Macro page and this time verify that the link to the space home page works
macroPage = SpacesMacroPage.gotoPage();
ViewPage spaceHomePage = macroPage.getSpacesMacroPane().clickSpaceHome(referenceEscapedSpaceName);
assertEquals(spaceName, spaceHomePage.getDocumentTitle());
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class DocumentFieldsTest method titleAndContent.
@Test
public void titleAndContent() {
// Create a new application.
String appName = RandomStringUtils.randomAlphabetic(6);
ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
appCreatePage.setApplicationName(appName);
appCreatePage.waitForApplicationNamePreview();
ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
// Add a standard field.
ClassFieldEditPane numberField = classEditPage.addField("Number");
// Add the Title and Content fields.
ClassFieldEditPane titleField = classEditPage.addField("Title");
ClassFieldEditPane contentField = classEditPage.addField("Content");
// Change the default field pretty names.
// See XWIKI-9154: The application live table uses the standard 'Page title' heading instead of the pretty name
// set for the Title field
titleField.setPrettyName("My Title");
contentField.setPrettyName("My Content");
// Set the default values that will be saved in the template.
numberField.setDefaultValue("13");
String defaultTitle = "Enter title here";
titleField.setDefaultValue(defaultTitle);
String defaultContent = "Enter content here";
contentField.setDefaultValue(defaultContent);
// Add live table columns for Title and Content.
ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
homeEditPage.addLiveTableColumn("My Title");
homeEditPage.addLiveTableColumn("My Content");
// Add an application entry.
EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
entryNamePane.setName("Test");
EntryEditPage entryEditPage = entryNamePane.clickAdd();
Assert.assertEquals("13", entryEditPage.getValue("number1"));
// The page name is used as the default value for the title field.
Assert.assertEquals("Test", entryEditPage.getDocumentTitle());
Assert.assertEquals("Test", entryEditPage.getTitle());
entryEditPage.setTitle("Foo");
Assert.assertEquals(defaultContent, entryEditPage.getContent());
entryEditPage.setContent("Bar");
// Check that the title and the content of the entry have been updated.
ViewPage entryViewPage = entryEditPage.clickSaveAndView();
Assert.assertEquals("Foo", entryViewPage.getDocumentTitle());
Assert.assertTrue(entryViewPage.getContent().contains("Bar"));
entryViewPage.clickBreadcrumbLink(appName);
// Check the entries live table.
LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
liveTable.waitUntilReady();
Assert.assertEquals(1, liveTable.getRowCount());
Assert.assertTrue(liveTable.hasRow("My Title", "Foo"));
Assert.assertTrue(liveTable.hasRow("My Content", "Bar"));
// Check that the title and the content of the class have not been changed.
getUtil().gotoPage(new LocalDocumentReference(Arrays.asList(appName, "Code"), appName + "Class"), "edit", "editor=wiki");
WikiEditPage editPage = new WikiEditPage();
Assert.assertEquals(appName + " Class", editPage.getTitle());
Assert.assertEquals("", editPage.getContent());
// Now edit the class and check if the default values for title and content are taken from the template.
editPage.editInline();
Assert.assertEquals(defaultTitle, new ClassFieldEditPane("title1").getDefaultValue());
Assert.assertEquals(defaultContent, new ClassFieldEditPane("content1").getDefaultValue());
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class VersionTest method testRollbackToFirstVersion.
@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 testRollbackToFirstVersion() throws Exception {
getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
// Create first version of the page
ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
// Adds second version
WikiEditPage wikiEditPage = vp.editWiki();
wikiEditPage.setContent(CONTENT2);
wikiEditPage.clickSaveAndView();
// TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
// view mode) is fixed.
vp.waitForDocExtraPaneActive("comments");
// Verify that we can rollback to the first version
HistoryPane historyTab = vp.openHistoryDocExtraPane();
vp = historyTab.rollbackToVersion("1.1");
// Rollback doesn't wait...
// Wait for the comment tab to be selected since we're currently on the history tab and rolling
// back is going to load a new page and make the focus active on the comments tab.
vp.waitForDocExtraPaneActive("comments");
Assert.assertEquals("First version of Content", vp.getContent());
historyTab = vp.openHistoryDocExtraPane();
Assert.assertEquals("Rollback to version 1.1", historyTab.getCurrentVersionComment());
Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class EditObjectsTest method testChangeNumberType.
/**
* Tests that XWIKI-2214 remains fixed.
*/
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeNumberType() {
// Create class page
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass");
wep.setContent("this is the content");
ViewPage vp = wep.clickSaveAndView();
// Add class
ClassEditPage cep = vp.editClass();
cep.addProperty("prop", "Number");
cep.getNumberClassEditElement("prop").setNumberType("integer");
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Create object page
wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}");
vp = wep.clickSaveAndView();
// Add object
ObjectEditPage oep = vp.editObjects();
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "3");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: 3", vp.getContent());
// Change number to double type
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.getNumberClassEditElement("prop").setNumberType("double");
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Verify conversion
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "2.5");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: 2.5", vp.getContent());
// Change number to long type
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
cep.getNumberClassEditElement("prop").setNumberType("long");
vp = cep.clickSaveAndView();
Assert.assertEquals("this is the content", vp.getContent());
// Verify conversion
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: 2", vp.getContent());
}
use of org.xwiki.test.ui.po.editor.WikiEditPage in project xwiki-platform by xwiki.
the class SectionTest method testSectionSaveDoesNotOverwriteTheWholeContentWhenSyntax20.
/**
* Verify section save does not override the whole document content (xwiki/2.0).
* See XWIKI-4033: When saving after section edit entire page is overwritten.
*/
@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 testSectionSaveDoesNotOverwriteTheWholeContentWhenSyntax20() {
ViewPage vp = createTestPages("xwiki/2.0");
vp.editSection(4).editWiki().clickSaveAndView();
WikiEditPage wep = vp.editWiki();
Assert.assertEquals("= Section1 = Content1 = Section2 = Content2 == Section3 == Content3 " + "{{include document=\"Test.SectionEditingIncluded\"/}} = Section7 = Content7", wep.getContent());
}
Aggregations