Search in sources :

Example 6 with ClassEditPage

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

Example 7 with ClassEditPage

use of org.xwiki.test.ui.po.editor.ClassEditPage 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 8 with ClassEditPage

use of org.xwiki.test.ui.po.editor.ClassEditPage 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 9 with ClassEditPage

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

the class EditObjectsTest method testPropertyDisplayersForNewObjects.

/**
 * @see <a href="https://jira.xwiki.org/browse/XWIKI-9061">XWIKI-9061</a>: Property displayers don't work in the
 *      object editor for objects that have just been added
 */
@Test
public void testPropertyDisplayersForNewObjects() throws Exception {
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    // Create a class with two properties: a date and a list of users.
    ClassEditPage classEditor = ClassEditPage.gotoPage(getTestClassName(), getTestMethodName());
    classEditor.addProperty("date", "Date");
    classEditor.addProperty("author", "Users");
    // Add an object of this class and set its properties.
    String className = getTestClassName() + "." + getTestMethodName();
    ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName());
    ObjectEditPane object = objectEditor.addObject(className);
    object.openDatePicker("date").setDay("15");
    object.getUserPicker("author").sendKeys("ad").waitForSuggestions().select("Admin");
    // Save, edit again and check the values.
    object = objectEditor.clickSaveAndView().editObjects().getObjectsOfClass(className).get(0);
    Assert.assertEquals("15", object.openDatePicker("date").getDay());
    Assert.assertEquals("Administrator", object.getUserPicker("author").waitToLoad().getAcceptedSuggestions().get(0).getName());
}
Also used : ObjectEditPane(org.xwiki.test.ui.po.editor.ObjectEditPane) ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) Test(org.junit.Test)

Example 10 with ClassEditPage

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

the class PreviewTest method previewWithSheet.

/**
 * @see "XWIKI-9527: Sheets are not applied on preview action if the document is new"
 */
@Test
public void previewWithSheet() throws Exception {
    // Create the class.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Class");
    ClassEditPage classEditor = ClassEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class");
    classEditor.addProperty("color", "String");
    // Create the sheet.
    getUtil().rest().savePage(new LocalDocumentReference(getTestClassName(), getTestMethodName() + "Sheet"), "{{velocity}}$doc.display('color'){{/velocity}}", "");
    // Bind the class to the sheet.
    ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class");
    ObjectEditPane objectEditPane = objectEditor.addObject("XWiki.ClassSheetBinding");
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("sheet"), getTestClassName() + "." + getTestMethodName() + "Sheet");
    objectEditor.clickSaveAndContinue();
    // Create the template.
    String classFullName = getTestClassName() + "." + getTestMethodName() + "Class";
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Template");
    objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Template");
    objectEditPane = objectEditor.addObject(classFullName);
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "red");
    objectEditor.clickSaveAndContinue();
    // Create the test instance.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "template=" + getTestClassName() + "." + getTestMethodName() + "Template");
    objectEditPane = new ObjectEditPane(new InlinePage().getForm(), classFullName, 0);
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "green");
    // Test the preview when the page is not yet saved.
    PreviewableEditPage editPage = new PreviewableEditPage();
    PreviewEditPage previewPage = editPage.clickPreview();
    assertEquals("green", previewPage.getContent());
    // Test the preview after the page is saved.
    previewPage.clickBackToEdit().clickSaveAndView().editInline().clickPreview();
    assertEquals("green", previewPage.getContent());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) ObjectEditPane(org.xwiki.test.ui.po.editor.ObjectEditPane) PreviewableEditPage(org.xwiki.test.ui.po.editor.PreviewableEditPage) ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) PreviewEditPage(org.xwiki.test.ui.po.editor.PreviewEditPage) InlinePage(org.xwiki.test.ui.po.InlinePage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) Test(org.junit.Test)

Aggregations

ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)11 Test (org.junit.Test)10 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)9 FormElement (org.xwiki.test.ui.po.FormElement)7 ViewPage (org.xwiki.test.ui.po.ViewPage)7 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)5 InlinePage (org.xwiki.test.ui.po.InlinePage)2 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)1 TaggablePage (org.xwiki.tag.test.po.TaggablePage)1 AbstractTest (org.xwiki.test.ui.AbstractTest)1 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 CommentsTab (org.xwiki.test.ui.po.CommentsTab)1 PreviewEditPage (org.xwiki.test.ui.po.editor.PreviewEditPage)1