* Request data update before client response * fix the accidental commit * add tests fixes #11320tags/8.6.3
@@ -530,6 +530,7 @@ public class DataCommunicator<T> extends AbstractExtension { | |||
public void reset() { | |||
// Only needed if a full reset is not pending. | |||
if (!reset) { | |||
beforeClientResponse(true); | |||
// Soft reset through client-side re-request. | |||
getClientRpc().reset(getDataProviderSize()); | |||
} |
@@ -1,9 +1,5 @@ | |||
package com.vaadin.data.provider; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.concurrent.Future; | |||
@@ -25,6 +21,9 @@ import com.vaadin.ui.UI; | |||
import elemental.json.Json; | |||
import elemental.json.JsonArray; | |||
import elemental.json.JsonObject; | |||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertTrue; | |||
/** | |||
* @author Vaadin Ltd | |||
@@ -303,7 +302,7 @@ public class DataCommunicatorTest { | |||
// Mark communicator clean | |||
ui.getConnectorTracker().markClean(communicator); | |||
assertTrue("Communicator should be marked for hard reset", | |||
assertFalse("Communicator should not be marked for hard reset", | |||
communicator.reset); | |||
assertFalse("DataCommunicator should not be marked as dirty", | |||
ui.getConnectorTracker().isDirty(communicator)); |
@@ -0,0 +1,51 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
import java.util.Optional; | |||
import com.vaadin.annotations.Widgetset; | |||
import com.vaadin.data.provider.DataProvider; | |||
import com.vaadin.server.VaadinRequest; | |||
import com.vaadin.tests.components.AbstractTestUI; | |||
import com.vaadin.tests.widgetset.TestingWidgetSet; | |||
import com.vaadin.ui.Button; | |||
import com.vaadin.ui.ComboBox; | |||
import com.vaadin.ui.Label; | |||
@Widgetset(TestingWidgetSet.NAME) | |||
public class ComboBoxItemSize extends AbstractTestUI { | |||
@Override | |||
protected void setup(VaadinRequest request) { | |||
List<String> items = new ArrayList<>(Arrays.asList("blue", "red", | |||
"green", "purple", "grey", "orange")); | |||
ComboBox<String> comboBox = new ComboBox<>(); | |||
comboBox.setId("combobox"); | |||
comboBox.setPageLength(0); | |||
comboBox.setItems(items); | |||
DataProvider<String, ?> dataProvider = comboBox.getDataProvider(); | |||
comboBox.setNewItemProvider(value -> { | |||
items.add(value); | |||
dataProvider.refreshAll(); | |||
return Optional.ofNullable(value); | |||
}); | |||
Button button = new Button("get value"); | |||
Label label = new Label("value of combobox"); | |||
button.addClickListener(event -> label | |||
.setValue("combobox value " + comboBox.getValue())); | |||
Button reset = new Button("reset"); | |||
reset.addClickListener(event -> { | |||
items.clear(); | |||
items.addAll(Arrays.asList("blue", "red", "green", "purple", "grey", | |||
"orange")); | |||
dataProvider.refreshAll(); | |||
comboBox.setValue(null); | |||
}); | |||
addComponents(comboBox, button, label, reset); | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
package com.vaadin.tests.components.combobox; | |||
import org.junit.Test; | |||
import org.openqa.selenium.Keys; | |||
import org.openqa.selenium.interactions.Actions; | |||
import com.vaadin.testbench.By; | |||
import com.vaadin.testbench.elements.ComboBoxElement; | |||
import com.vaadin.tests.tb3.SingleBrowserTest; | |||
import static org.junit.Assert.assertEquals; | |||
public class ComboBoxItemSizeTest extends SingleBrowserTest { | |||
ComboBoxElement comboBoxElement; | |||
@Test | |||
public void comboBoxItemSizeDisplayCorrectly() { | |||
openTestURL(); | |||
comboBoxElement = $(ComboBoxElement.class).id("combobox"); | |||
// initial item size include the empty option | |||
assertItemSizeInPopup(7); | |||
comboBoxElement.clear(); | |||
sendKeysToInput("black"); | |||
assertItemSizeInPopup(8); | |||
} | |||
private void assertItemSizeInPopup(int expectedSize) { | |||
comboBoxElement.findElement(By.className("v-filterselect-button")) | |||
.click(); | |||
waitForElementPresent(By.className("v-filterselect-suggestpopup")); | |||
int itemSize = findElement(By.className("v-filterselect-suggestmenu")) | |||
.findElements(By.tagName("span")).size(); | |||
assertEquals("There should be " + expectedSize + "items in the popup.", | |||
expectedSize, itemSize); | |||
} | |||
private void sendKeysToInput(CharSequence... keys) { | |||
// ensure mouse is located over the ComboBox to avoid hover issues | |||
new Actions(getDriver()).moveToElement(comboBoxElement).perform(); | |||
comboBoxElement.sendKeys(keys); | |||
comboBoxElement.sendKeys(Keys.ENTER); | |||
waitForElementNotPresent(By.className("v-filterselect-suggestpopup")); | |||
} | |||
} |