From 0f97714b635174e4eabfbb5a708ffb366bfcadb4 Mon Sep 17 00:00:00 2001 From: caalador Date: Wed, 8 Feb 2017 14:54:57 +0200 Subject: Fix removing and adding a column in grid (#8437) * Added column should also be added to footer (#590) When adding (readding) a column the column should also be added to footer as it will be removed and iterator will request footer for it. * Add test for re-add column (#590) * To lowerCase using Locale * Fixed compilation problem. Too little sleep for a friday evening... --- .../vaadin/tests/components/grid/GridColspans.java | 2 +- .../tests/components/grid/GridColspansTest.java | 38 +++++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) (limited to 'uitest') diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java index ce29ca3d9e..961e44593a 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridColspans.java @@ -85,7 +85,7 @@ public class GridColspans extends AbstractTestUI { if (column != null) { grid.removeColumn(column); } else { - grid.addColumn(Person::getFirstName).setId("firstName"); + grid.addColumn(Person::getFirstName).setId("firstName").setCaption("First name"); } })); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java index 2d0a12187d..27b9e805bd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridColspansTest.java @@ -17,6 +17,7 @@ package com.vaadin.tests.components.grid; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import java.util.Locale; import org.junit.Before; import org.junit.Test; @@ -56,14 +57,35 @@ public class GridColspansTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); assertEquals("Failed initial condition.", "all the stuff", - grid.getHeaderCell(0, 1).getText().toLowerCase()); + grid.getHeaderCell(0, 1).getText().toLowerCase(Locale.ENGLISH)); assertEquals("Failed initial condition.", "first name", - grid.getHeaderCell(2, 1).getText().toLowerCase()); + grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH)); $(ButtonElement.class).caption("Show/Hide firstName").first().click(); assertEquals("Header text changed on column hide.", "all the stuff", - grid.getHeaderCell(0, 1).getText().toLowerCase()); + grid.getHeaderCell(0, 1).getText().toLowerCase(Locale.ENGLISH)); assertEquals("Failed initial condition.", "last name", - grid.getHeaderCell(2, 1).getText().toLowerCase()); + grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH)); + } + + @Test + public void testHideAndReAddFirstCOlumn() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + + assertEquals("Failed initial condition.", "first name", + grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH)); + + $(ButtonElement.class).caption("Show/Hide firstName").first().click(); + + assertEquals("Failed initial condition.", "last name", + grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH)); + + $(ButtonElement.class).caption("Show/Hide firstName").first().click(); + + assertEquals("Failed to find first name in last column", "first name", + grid.getHeaderCell(2, 5).getText().toLowerCase(Locale.ENGLISH)); + } @Test @@ -73,18 +95,18 @@ public class GridColspansTest extends MultiBrowserTest { GridElement grid = $(GridElement.class).first(); GridCellElement headerCell = grid.getHeaderCell(1, 1); assertEquals("Failed initial condition.", "full name", - headerCell.getText().toLowerCase()); + headerCell.getText().toLowerCase(Locale.ENGLISH)); assertEquals("Failed initial condition.", "first name", - grid.getHeaderCell(2, 1).getText().toLowerCase()); + grid.getHeaderCell(2, 1).getText().toLowerCase(Locale.ENGLISH)); $(ButtonElement.class).get(1).click(); headerCell = grid.getHeaderCell(1, 1); assertEquals("Joined Header text not changed on column reorder.", - "misc", headerCell.getText().toLowerCase()); + "misc", headerCell.getText().toLowerCase(Locale.ENGLISH)); assertEquals("Unexpected colspan", "1", headerCell.getAttribute("colspan")); headerCell = grid.getHeaderCell(1, 2); assertEquals("Header text not changed on column reorder", "full name", - headerCell.getText().toLowerCase()); + headerCell.getText().toLowerCase(Locale.ENGLISH)); assertEquals("Unexpected colspan", "2", headerCell.getAttribute("colspan")); -- cgit v1.2.3