-
Notifications
You must be signed in to change notification settings - Fork 728
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 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.
- Loading branch information
Showing
3 changed files
with
81 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
40 changes: 40 additions & 0 deletions
40
uitest/src/main/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozen.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,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."; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
uitest/src/test/java/com/vaadin/tests/components/grid/GridUnhideColumnsWithFrozenTest.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,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()); | ||
} | ||
} |