-
Notifications
You must be signed in to change notification settings - Fork 727
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Grid details rows get a full refresh when a column is sorted. (#…
- Loading branch information
Showing
3 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
uitest/src/main/java/com/vaadin/tests/components/grid/GridOpenDetailsSort.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,42 @@ | ||
package com.vaadin.tests.components.grid; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.vaadin.data.provider.ListDataProvider; | ||
import com.vaadin.server.VaadinRequest; | ||
import com.vaadin.tests.components.AbstractTestUI; | ||
import com.vaadin.ui.Grid; | ||
import com.vaadin.ui.Label; | ||
|
||
public class GridOpenDetailsSort extends AbstractTestUI { | ||
|
||
@Override | ||
protected void setup(VaadinRequest request) { | ||
Grid<String> testGrid = new Grid<>(); | ||
|
||
testGrid.addColumn(item -> item).setCaption("column").setId("column"); | ||
|
||
List<String> list = new ArrayList<>(); | ||
list.add("row3"); | ||
list.add("row2"); | ||
list.add("row1"); | ||
ListDataProvider<String> dataProvider = new ListDataProvider<>(list); | ||
|
||
testGrid.setDataProvider(dataProvider); | ||
testGrid.setDetailsGenerator(item -> new Label("details - " + item)); | ||
list.forEach(item -> testGrid.setDetailsVisible(item, true)); | ||
|
||
addComponent(testGrid); | ||
} | ||
|
||
@Override | ||
protected Integer getTicketNumber() { | ||
return 12341; | ||
} | ||
|
||
@Override | ||
protected String getTestDescription() { | ||
return "Already open details rows shouldn't break when the Grid is sorted."; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
uitest/src/test/java/com/vaadin/tests/components/grid/GridOpenDetailsSortTest.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,44 @@ | ||
package com.vaadin.tests.components.grid; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebElement; | ||
|
||
import com.vaadin.testbench.elements.GridElement; | ||
import com.vaadin.tests.tb3.MultiBrowserTest; | ||
|
||
public class GridOpenDetailsSortTest extends MultiBrowserTest { | ||
|
||
@Test | ||
public void sort() { | ||
openTestURL(); | ||
GridElement grid = $(GridElement.class).first(); | ||
assertRow(grid, 0, "row3"); | ||
assertDetails(); | ||
|
||
grid.getHeaderCell(0, 0).click(); | ||
assertTrue("First column should be sorted ascending", | ||
grid.getHeaderCell(0, 0).getAttribute("class") | ||
.contains("sort-asc")); | ||
assertRow(grid, 0, "row1"); | ||
assertDetails(); | ||
} | ||
|
||
private void assertRow(GridElement grid, int row, String value) { | ||
assertEquals(String.valueOf(value), grid.getCell(row, 0).getText()); | ||
} | ||
|
||
private void assertDetails() { | ||
List<WebElement> details = findElements(By.className("v-grid-spacer")); | ||
assertEquals("Unexpected amount of details,", 3, details.size()); | ||
for (WebElement detail : details) { | ||
assertEquals("Unexpected detail contents,", 1, | ||
detail.findElements(By.className("v-label")).size()); | ||
} | ||
} | ||
} |