Search in sources :

Example 1 with StaticListItemsEditor

use of org.xwiki.appwithinminutes.test.po.StaticListItemsEditor in project xwiki-platform by xwiki.

the class StaticListClassFieldTest method testItemsEditor.

/**
 * Tests the ability to add, edit and remove list items.
 */
@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 testItemsEditor() {
    // Add a new static list field.
    StaticListClassFieldEditPane staticListField = new StaticListClassFieldEditPane(editor.addField("Static List").getName());
    // Open the configuration panel and edit the list items.
    staticListField.openConfigPanel();
    StaticListItemsEditor itemsEditor = staticListField.getItemsEditor();
    // Remove the second option.
    itemsEditor.remove("value2");
    // Add two new items.
    itemsEditor.add("foo", "bar");
    // Leave the value empty for the second item: it should fall back on the label.
    itemsEditor.add("", "XWiki");
    // Change the label of the last added item.
    itemsEditor.setLabel("XWiki", "XWiki Enterprise");
    // Move the last item before the first.
    itemsEditor.moveBefore("XWiki", "value1");
    Assert.assertEquals(4, itemsEditor.size());
    // Enable multiple selection and change display type to 'select' to check the value of the size property.
    staticListField.getDisplayTypeSelect().selectByVisibleText("select");
    staticListField.getMultipleSelectionCheckBox().click();
    Assert.assertEquals("4", staticListField.getSizeInput().getAttribute("value"));
    // Apply configuration changes and assert the result.
    staticListField.closeConfigPanel();
    // The initial second item was removed.
    Assert.assertNull(staticListField.getItemByValue("value2"));
    // We should have a new item with value "XWiki".
    staticListField.getItemByValue("XWiki").click();
    // Assert the order of the items.
    staticListField.getItemByValue("value1").click();
    Assert.assertEquals(Arrays.asList("XWiki", "value1"), staticListField.getDefaultSelectedValues());
}
Also used : StaticListClassFieldEditPane(org.xwiki.appwithinminutes.test.po.StaticListClassFieldEditPane) StaticListItemsEditor(org.xwiki.appwithinminutes.test.po.StaticListItemsEditor) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 StaticListClassFieldEditPane (org.xwiki.appwithinminutes.test.po.StaticListClassFieldEditPane)1 StaticListItemsEditor (org.xwiki.appwithinminutes.test.po.StaticListItemsEditor)1 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)1