use of org.xwiki.test.ui.po.editor.ObjectEditPage in project xwiki-platform by xwiki.
the class CompareVersionsTest method setUp.
@Before
public void setUp() throws Exception {
String pageName = "PageWithManyVersions";
// Check if the test page exists.
testPage = getUtil().gotoPage(getTestClassName(), pageName);
if (testPage.exists()) {
// TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
// view mode) is fixed.
testPage.waitForDocExtraPaneActive("comments");
// versions of the test page.
return;
}
// Since this test also verifies diffs when the parent/child relationship is modified, use this mode (which
// isn't the default) for testing purpose. Also note that in the "reference" mode there's no diff to display
// when the document is moved to a different parent since it means changing the identity of the document for
// now and thus changing it means getting a new document.
getUtil().setHierarchyMode("parentchild");
getDriver().navigate().refresh();
// Create the test page.
testPage = getUtil().createPage(getTestClassName(), pageName, "one\ntwo\nthree", "Test");
// Change the content and the meta data.
WikiEditPage wikiEditPage = testPage.editWiki();
wikiEditPage.setContent("one\n**two**\nfour");
wikiEditPage.setTitle("Compare verSions test");
wikiEditPage.setParent("Sandbox.WebHome");
wikiEditPage.setEditComment("Changed content and meta data.");
wikiEditPage.clickSaveAndContinue();
wikiEditPage.setTitle("Compare versions test");
wikiEditPage.setMinorEdit(true);
wikiEditPage.setEditComment("Fix typo in title.");
wikiEditPage.clickSaveAndContinue();
// Add objects.
ObjectEditPage objectEditPage = wikiEditPage.editObjects();
FormElement form = objectEditPage.addObject("XWiki.JavaScriptExtension");
Map<String, String> assignment = new HashMap<String, String>();
assignment.put("XWiki.JavaScriptExtension_0_name", "JavaScript code");
assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = bob;\nbob = tmp;");
assignment.put("XWiki.JavaScriptExtension_0_use", "onDemand");
form.fillFieldsByName(assignment);
objectEditPage.clickSaveAndContinue();
assignment.put("XWiki.JavaScriptExtension_0_name", "Code snippet");
assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = 2 * bob;\nbob = tmp;");
form.fillFieldsByName(assignment);
objectEditPage.clickSaveAndContinue();
// Create class.
ClassEditPage classEditPage = objectEditPage.editClass();
classEditPage.addProperty("age", "Number");
classEditPage.addProperty("color", "String");
classEditPage.getNumberClassEditElement("age").setNumberType("integer");
classEditPage.clickSaveAndContinue();
classEditPage.deleteProperty("color");
testPage = classEditPage.clickSaveAndView();
// Add tags.
TaggablePage taggablePage = new TaggablePage();
AddTagsPane addTagsPane = taggablePage.addTags();
addTagsPane.setTags("foo,bar");
addTagsPane.add();
taggablePage.removeTag("foo");
// Attach files.
AttachmentsPane attachmentsPane = testPage.openAttachmentsDocExtraPane();
// TODO: Update this code when we (re)add support for uploading multiple files at once.
for (String fileName : new String[] { "SmallAttachment.txt", "SmallAttachment2.txt", "SmallAttachment.txt" }) {
attachmentsPane.setFileToUpload(this.getClass().getResource('/' + fileName).getPath());
attachmentsPane.waitForUploadToFinish(fileName);
attachmentsPane.clickHideProgress();
}
attachmentsPane.deleteAttachmentByFileByName("SmallAttachment2.txt");
// Add comments.
getUtil().createUserAndLogin("Alice", "ecila");
testPage = getUtil().gotoPage(getTestClassName(), pageName);
CommentsTab commentsTab = testPage.openCommentsDocExtraPane();
commentsTab.postComment("first line\nsecond line", true);
commentsTab.editCommentByID(0, "first line\nline in between\nsecond line");
commentsTab.replyToCommentByID(0, "this is a reply");
commentsTab.deleteCommentByID(1);
}
use of org.xwiki.test.ui.po.editor.ObjectEditPage in project xwiki-platform by xwiki.
the class EditClassTest method testAddProperty.
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testAddProperty() {
// We verify that we can click on Edit Class from View Page (we need to test this at
// least once to ensure the UI works).
getUtil().gotoPage("Test", "EditObjectsTestClass", "view", "spaceRedirect=false");
ClassEditPage cep = new ViewPage().editClass();
// Create a class with a string property
cep.addProperty("prop", "String");
cep.clickSaveAndView();
// Create object page
ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", "this is the content: {{velocity}}$doc.display('prop'){{/velocity}}", getTestMethodName());
// Add an object of the class created
ObjectEditPage oep = vp.editObjects();
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "testing value");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: testing value", vp.getContent());
}
use of org.xwiki.test.ui.po.editor.ObjectEditPage in project xwiki-platform by xwiki.
the class EditClassTest method testDeleteProperty.
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testDeleteProperty() {
// Create a class with two string properties
getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop1", "String");
getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop2", "String");
// Create object page
ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", "this is the content: {{velocity}}$doc.display('prop1')/$doc.display('prop2')/" + "$!doc.getObject('Test.EditObjectsTestClass').getProperty('prop1').value{{/velocity}}", getTestMethodName());
// Add an object of the class created
ObjectEditPage oep = vp.editObjects();
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop1"), "testing value 1");
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop2"), "testing value 2");
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: testing value 1/testing value 2/testing value 1", vp.getContent());
// Delete the first property from the class
ClassEditPage cep = getUtil().editClass("Test", "EditObjectsTestClass");
cep.deleteProperty("prop1");
cep.clickSaveAndView();
vp = getUtil().gotoPage("Test", "EditObjectsTestObject");
Assert.assertEquals("this is the content: /testing value 2/testing value 1", vp.getContent());
oep = vp.editObjects();
Assert.assertNotNull(getDriver().findElement(By.className("deprecatedProperties")));
Assert.assertNotNull(getDriver().findElement(By.cssSelector(".deprecatedProperties label")));
Assert.assertEquals("prop1:", getDriver().findElement(By.cssSelector(".deprecatedProperties label")).getText());
// Remove deprecated properties
oep.removeAllDeprecatedProperties();
vp = oep.clickSaveAndView();
Assert.assertEquals("this is the content: /testing value 2/", vp.getContent());
}
use of org.xwiki.test.ui.po.editor.ObjectEditPage in project xwiki-platform by xwiki.
the class TestUtils method setPropertyInXWikiPreferences.
/**
* Add and set a property into XWiki.XWikiPreferences. Create XWiki.XWikiPreferences if it does not exist.
*
* @param propertyName name of the property to set
* @param propertyType the type of the property to add
* @param value value to set to the property
* @since 7.2M2
*/
public void setPropertyInXWikiPreferences(String propertyName, String propertyType, Object value) {
addClassProperty("XWiki", "XWikiPreferences", propertyName, propertyType);
gotoPage("XWiki", "XWikiPreferences", "edit", "editor", "object");
ObjectEditPage objectEditPage = new ObjectEditPage();
if (objectEditPage.hasObject("XWiki.XWikiPreferences")) {
updateObject("XWiki", "XWikiPreferences", "XWiki.XWikiPreferences", 0, propertyName, value);
} else {
addObject("XWiki", "XWikiPreferences", "XWiki.XWikiPreferences", propertyName, value);
}
}
use of org.xwiki.test.ui.po.editor.ObjectEditPage 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());
}
Aggregations