Search in sources :

Example 6 with FormElement

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

the class EditObjectsTest method testChangeMultiselectProperty.

/**
 * Tests that XWIKI-1621 remains fixed.
 */
@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 testChangeMultiselectProperty() {
    // Create a class with a database list property set to return all documents
    ClassEditPage cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.addProperty("prop", "DBList");
    cep.getDatabaseListClassEditElement("prop").setHibernateQuery("select doc.fullName from XWikiDocument doc where doc.space = 'Test'");
    cep.clickSaveAndView();
    // Create a second page to hold the Object and set its content
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an object of the class created and set the value to be the test page
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestClass");
    oep.clickSaveAndView();
    // Set multiselect to true
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getDatabaseListClassEditElement("prop").setMultiSelect(true);
    cep.clickSaveAndView();
    // Select a second document in the DB list select field.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestObject");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content", 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) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 7 with FormElement

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

the class EditObjectsTest method testChangeListTypeRelationalStorage.

/**
 * Prove that a list can be changed from relational storage to plain storage and back without database corruption.
 * XWIKI-1621: Changing parameters of list properties fails
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeListTypeRelationalStorage() {
    // 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(true);
    slcee.setDisplayType(StaticListClassEditElement.DisplayType.INPUT);
    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"), "this|that|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: this that other", vp.getContent());
    // Change list to relational storage.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setRelationalStorage(true);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Make sure we can still edit the object.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: this other", vp.getContent());
    // Change list to non-relational storage.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setRelationalStorage(false);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Make sure we can still edit the object.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "that|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: that other", 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)

Example 8 with FormElement

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

the class EditObjectsTest method testObjectAddAndRemove.

@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 testObjectAddAndRemove() {
    ObjectEditPage oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    FormElement object = oep.addObject("XWiki.XWikiUsers");
    object.setFieldValue(By.id("XWiki.XWikiUsers_0_first_name"), "John");
    // Add another object
    FormElement object2 = oep.addObject("XWiki.XWikiUsers");
    // Check that the unsaved value from the first object wasn't lost
    Assert.assertEquals("John", object.getFieldValue(By.id("XWiki.XWikiUsers_0_first_name")));
    // Check that the value from the second object is unset
    Assert.assertEquals("", object2.getFieldValue(By.id("XWiki.XWikiUsers_1_first_name")));
    // Delete the second object
    oep.deleteObject("XWiki.XWikiUsers", 1);
    // Let's save the form and check that changes were persisted.
    oep = oep.clickSaveAndView().editObjects();
    List<ObjectEditPane> xwikiUsersForms = oep.getObjectsOfClass("XWiki.XWikiUsers");
    Assert.assertEquals(1, xwikiUsersForms.size());
    Assert.assertEquals("John", xwikiUsersForms.get(0).getFieldValue(By.id("XWiki.XWikiUsers_0_first_name")));
}
Also used : ObjectEditPane(org.xwiki.test.ui.po.editor.ObjectEditPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) FormElement(org.xwiki.test.ui.po.FormElement) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 9 with FormElement

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

the class SkinxTest method testJavascriptExtension.

/**
 * https://jira.xwiki.org/browse/XWIKI-7913
 */
@Test
public void testJavascriptExtension() {
    // Create a doc
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "SkinxTest");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an XWikiGroups object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("XWiki.JavaScriptExtension");
    objectForm.setFieldValue(By.id("XWiki.JavaScriptExtension_0_code"), SCRIPT);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("always");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    waitForScriptResult();
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("currentPage");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on the current page.");
    } catch (TimeoutException e) {
    }
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("onDemand");
    oep.clickSaveAndView();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on demand.");
    } catch (TimeoutException e) {
    }
}
Also used : 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) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

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