Search in sources :

Example 1 with FormElement

use of org.xwiki.test.ui.po.FormElement 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 2 with FormElement

use of org.xwiki.test.ui.po.FormElement 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 3 with FormElement

use of org.xwiki.test.ui.po.FormElement 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 4 with FormElement

use of org.xwiki.test.ui.po.FormElement 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)

Example 5 with FormElement

use of org.xwiki.test.ui.po.FormElement in project xwiki-platform by xwiki.

the class EditObjectsTest method testChangeListMultipleSelect.

/**
 * Prove that a list can be changed from relational storage to plain storage and back without database corruption.
 * XWIKI-299 test
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeListMultipleSelect() {
    // 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", "StaticList");
    StaticListClassEditElement slcee = cep.getStaticListClassEditElement("prop");
    slcee.setMultiSelect(false);
    slcee.setValues("choice 1|choice 2|choice 3|choice 4|choice 5");
    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"), "choice 3");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: choice 3", vp.getContent());
    // Change list to a multiple select.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setMultiSelect(true);
    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"), "choice 3");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "choice 4");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: choice 3 choice 4", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) StaticListClassEditElement(org.xwiki.test.ui.po.editor.StaticListClassEditElement) 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

FormElement (org.xwiki.test.ui.po.FormElement)9 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)9 Test (org.junit.Test)8 ViewPage (org.xwiki.test.ui.po.ViewPage)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)6 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 TimeoutException (org.openqa.selenium.TimeoutException)1 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)1 TaggablePage (org.xwiki.tag.test.po.TaggablePage)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 CommentsTab (org.xwiki.test.ui.po.CommentsTab)1 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)1