use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ApplicationsPanelEntryTest method testApplicationPanelEntry.
@Test
public void testApplicationPanelEntry() {
// Test the icon remains the same between edits
editPage.setIcon("icon:bell");
editPage.clickSaveAndView();
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit");
Assert.assertEquals("icon:bell", editPage.getIcon());
ApplicationsPanel panel = ApplicationsPanel.gotoPage();
ViewPage page = panel.clickApplication(getTestClassName());
// Verify we're on the right page!
Assert.assertEquals(getTestClassName(), page.getMetaDataValue("space"));
Assert.assertEquals(getTestMethodName(), page.getMetaDataValue("page"));
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ClassEditorTest method testFieldNameAutoGeneration.
/**
* Tests that fields names are auto-generated properly.
*/
@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 testFieldNameAutoGeneration() {
// Add a class field and set its name to an auto-generated field name for a different type.
ClassFieldEditPane field = editor.addField("Short Text");
field.openConfigPanel();
field.setName("number1");
editor.clickSaveAndContinue();
// Add a new field of the type implied by the name set to the previous field.
field = editor.addField("Number");
field.openConfigPanel();
Assert.assertEquals("number2", field.getName());
// Save and assert both fields have been added.
ViewPage viewer = editor.clickSaveAndView();
Assert.assertTrue(viewer.getContent().contains("Short Text (number1: String)"));
Assert.assertTrue(viewer.getContent().contains("Number (number2: Number)"));
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class ClassEditorTest method testReorderFields.
/**
* Tests that class fields can be reordered.
*/
@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 testReorderFields() {
// Add two class fields.
editor.addField("Date").setPrettyName("Start Date");
editor.addField("Date").setPrettyName("End Date");
// Save and edit the class template in in-line edit mode.
editor.clickSaveAndView();
new ClassSheetPage().clickTemplateLink().edit();
// Assert the order of the form fields.
List<String> fieldNames = new EntryEditPage().getFieldNames();
Assert.assertEquals("date1", fieldNames.get(0));
Assert.assertEquals("date2", fieldNames.get(1));
// Go back to the class editor.
getDriver().navigate().back();
getDriver().navigate().back();
new ViewPage().edit();
editor = new ApplicationClassEditPage();
// Change the order of the class fields.
editor.moveFieldBefore("date2", "date1");
// Save and edit the class template again.
editor.clickSaveAndView();
new ClassSheetPage().clickTemplateLink().edit();
// Assert the order of the form fields.
fieldNames = new EntryEditPage().getFieldNames();
Assert.assertEquals("date2", fieldNames.get(0));
Assert.assertEquals("date1", fieldNames.get(1));
}
use of org.xwiki.test.ui.po.ViewPage 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.ViewPage in project xwiki-platform by xwiki.
the class LanguageTest method checkLanguageTagsArePresent.
/**
* Assert that the given <code>language</code> is present in various attributes and tags on the page
*
* @param language the language to use, should be a valid language, e.g. "en"
*/
private void checkLanguageTagsArePresent(String language) {
WebElement html = getDriver().findElement(By.tagName("html"));
Assert.assertEquals(language, html.getAttribute("lang"));
Assert.assertEquals(language, html.getAttribute("xml:lang"));
ViewPage vp = new ViewPage();
// For retro-compatibility only
Assert.assertEquals(language, vp.getHTMLMetaDataValue("language"));
String content = getDriver().getPageSource();
Assert.assertTrue(content.contains("language=" + language));
}
Aggregations