-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
UITestJUnit testing the UIJUnit testing the UI
Description
There is no api to trigger the customValueSetListener when setAllowCustomValue is true.
Code to test
@Route("combobox")
public class ComboBoxView extends VerticalLayout {
private List<String> items = new ArrayList<>(Arrays.asList("Chrome", "Edge", "Firefox", "Safari"));
public ComboBoxView () {
TextField textField = new TextField();
ComboBox<String> comboBox = new ComboBox<>("Browser");
comboBox.setAllowCustomValue(true);
comboBox.addCustomValueSetListener(e -> {
String customValue = e.getDetail();
items.add(customValue);
comboBox.setItems(items);
comboBox.setValue(customValue);
textField.setValue(comboBox.getValue());
});
add(textField, comboBox);
comboBox.setItems(items);
comboBox.setHelperText("Select or type a browser");
}
}
Test code
@Test
public void allowCustomTest() {
navigate(ComboBoxView .class);
TextField textField = $(TextField.class).first();
ComboBox<String> comboBox = $(ComboBox.class).first();
comboBox.setValue("Other");
assertEquals("Other", textField.getValue());
}
Error : The test case fails as the listenerer was not called and TextField value is empty
Expected Outcome: The customValueSetListener should be invoked.
Metadata
Metadata
Assignees
Labels
UITestJUnit testing the UIJUnit testing the UI
Type
Projects
Status
Maybe