Search in sources :

Example 6 with ObjectEditPage

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);
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) HashMap(java.util.HashMap) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) CommentsTab(org.xwiki.test.ui.po.CommentsTab) TaggablePage(org.xwiki.tag.test.po.TaggablePage) AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Before(org.junit.Before)

Example 7 with ObjectEditPage

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());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 8 with ObjectEditPage

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());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 9 with ObjectEditPage

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);
    }
}
Also used : ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage)

Example 10 with ObjectEditPage

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());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Aggregations

ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)21 Test (org.junit.Test)15 ViewPage (org.xwiki.test.ui.po.ViewPage)11 FormElement (org.xwiki.test.ui.po.FormElement)9 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)9 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)8 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)6 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)4 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)3 HashMap (java.util.HashMap)2 AbstractTest (org.xwiki.test.ui.AbstractTest)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)1 MimeMessage (javax.mail.internet.MimeMessage)1 Before (org.junit.Before)1 TimeoutException (org.openqa.selenium.TimeoutException)1 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)1 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)1 LongTextClassFieldEditPane (org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane)1