diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2020-03-26 15:13:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-26 15:13:14 +0200 |
commit | d58be4ef41c484241ed739d22a73b5a29b57e824 (patch) | |
tree | 2e1d4054e0aa83dd90f0ccdb142810737cc636cc /uitest | |
parent | 76291c6ff3bf9b54118e0f03b02cf62c7c897a20 (diff) | |
download | vaadin-framework-d58be4ef41c484241ed739d22a73b5a29b57e824.tar.gz vaadin-framework-d58be4ef41c484241ed739d22a73b5a29b57e824.zip |
Fix an issue with frozen column count and unhiding. (#11929) (#11932)8.10.3
* Fix an issue with frozen column count and unhiding.
Unhiding logic should take into account that there can be hidden frozen
columns that are not the column currently getting shown.
Diffstat (limited to 'uitest')
2 files changed, 78 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozen.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozen.java new file mode 100644 index 0000000000..e0b65ff8d3 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozen.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Component; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Label; + +public class GridUnhideColumnsWithFrozen extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Grid<Integer> grid = new Grid<>(); + for (int i = 0; i < 15; i++) { + String columnId = String.valueOf(i); + Grid.Column<Integer, Component> column = addColumn(grid, columnId); + column.setHidable(true); + if (i == 3 || i == 4) { + column.setHidden(true); + } + column.setCaption(columnId); + column.setId(columnId); + } + grid.setFrozenColumnCount(4); + grid.setItems(0); + addComponent(grid); + } + + private Grid.Column<Integer, Component> addColumn(Grid<Integer> grid, + String columnId) { + return grid.addComponentColumn(i -> new Label(columnId)); + } + + @Override + protected String getTestDescription() { + return "Columns 0-3 have been set frozen, unhiding column 4 before column 3" + + " should not make column 4 frozen."; + } + +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozenTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozenTest.java new file mode 100644 index 0000000000..061e1d20e1 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozenTest.java @@ -0,0 +1,38 @@ +package com.vaadin.tests.components.grid; + +import static org.junit.Assert.assertEquals; + +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.SingleBrowserTest; + +public class GridUnhideColumnsWithFrozenTest extends SingleBrowserTest { + + @Test + public void visibleFrozenColumnCount() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + List<WebElement> frozen = grid.getHeader() + .findElements(By.className("frozen")); + assertEquals("Unexpected frozen column count before unhiding", 3, + frozen.size()); + + grid.findElement(By.className("v-grid-sidebar-button")).click(); + List<WebElement> hidden = findElement( + By.className("v-grid-sidebar-content")) + .findElements(By.className("hidden")); + assertEquals("Unexpected amount of hidden columns", 2, hidden.size()); + assertEquals("Unexpected hidden column", "4", hidden.get(1).getText()); + hidden.get(1).click(); + + frozen = grid.getHeader().findElements(By.className("frozen")); + assertEquals("Unexpected frozen column count after unhiding", 3, + frozen.size()); + } +} |