-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91de754
commit ff5c995
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
.../main/java/com/vaadin/flow/component/combobox/test/MultiSelectComboBoxKeepFilterPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.vaadin.flow.component.combobox.test; | ||
|
||
import com.vaadin.flow.component.checkbox.Checkbox; | ||
import com.vaadin.flow.component.combobox.MultiSelectComboBox; | ||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.router.Route; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
@Route("vaadin-multi-select-combo-box/keep-filter") | ||
public class MultiSelectComboBoxKeepFilterPage extends Div { | ||
public MultiSelectComboBoxKeepFilterPage() { | ||
MultiSelectComboBox<String> comboBox = new MultiSelectComboBox<>( | ||
"Items"); | ||
List<String> items = IntStream.range(0, 100) | ||
.mapToObj(i -> "Item " + (i + 1)).collect(Collectors.toList()); | ||
comboBox.setItems(items); | ||
|
||
Checkbox keepFilter = new Checkbox("Keep filter"); | ||
keepFilter.setId("keep-filter"); | ||
keepFilter.addValueChangeListener(e -> { | ||
comboBox.setKeepFilter(keepFilter.getValue()); | ||
}); | ||
|
||
add(comboBox, keepFilter); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...rc/test/java/com/vaadin/flow/component/combobox/test/MultiSelectComboBoxKeepFilterIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.vaadin.flow.component.combobox.test; | ||
|
||
import com.vaadin.flow.component.combobox.testbench.MultiSelectComboBoxElement; | ||
import com.vaadin.flow.testutil.TestPath; | ||
import com.vaadin.testbench.TestBenchElement; | ||
import com.vaadin.tests.AbstractComponentIT; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.openqa.selenium.Keys; | ||
|
||
import java.util.List; | ||
|
||
@TestPath("vaadin-multi-select-combo-box/keep-filter") | ||
public class MultiSelectComboBoxKeepFilterIT extends AbstractComponentIT { | ||
private MultiSelectComboBoxElement comboBox; | ||
private TestBenchElement keepFilter; | ||
|
||
@Before | ||
public void init() { | ||
open(); | ||
comboBox = $(MultiSelectComboBoxElement.class).waitForFirst(); | ||
keepFilter = $(TestBenchElement.class).id("keep-filter"); | ||
} | ||
|
||
@Test | ||
public void keepFilterDisabled_clearsFilterAfterSelection() { | ||
comboBox.sendKeys("Item 1"); | ||
comboBox.waitForLoadingFinished(); | ||
List<String> filteredOptions = comboBox.getOptions(); | ||
Assert.assertEquals(12, filteredOptions.size()); | ||
|
||
comboBox.sendKeys(Keys.ENTER); | ||
|
||
Assert.assertEquals("", comboBox.getInputElementValue()); | ||
Assert.assertEquals("", comboBox.getFilter()); | ||
Assert.assertEquals(100, comboBox.getOptions().size()); | ||
} | ||
|
||
@Test | ||
public void keepFilterEnabled_keepsFilterAfterSelection() { | ||
keepFilter.click(); | ||
|
||
comboBox.sendKeys("Item 1"); | ||
comboBox.waitForLoadingFinished(); | ||
List<String> filteredOptions = comboBox.getOptions(); | ||
Assert.assertEquals(12, filteredOptions.size()); | ||
|
||
comboBox.sendKeys(Keys.ENTER); | ||
|
||
Assert.assertEquals("Item 1", comboBox.getInputElementValue()); | ||
Assert.assertEquals("Item 1", comboBox.getFilter()); | ||
Assert.assertEquals(filteredOptions, comboBox.getOptions()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters