aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/components/grid
diff options
context:
space:
mode:
authorPekka Hyvönen <pekka@vaadin.com>2015-03-19 16:23:12 +0200
committerPekka Hyvönen <pekka@vaadin.com>2015-03-20 16:02:57 +0200
commitaa1150e22ec2412ab999cb35cb6a0f98a32d7f88 (patch)
tree546c070bd4ed73eec439aab337664b1fc0b87d36 /uitest/src/com/vaadin/tests/components/grid
parent27e0595fdb784891eda15a7b02f899d5d358b0d1 (diff)
downloadvaadin-framework-aa1150e22ec2412ab999cb35cb6a0f98a32d7f88.tar.gz
vaadin-framework-aa1150e22ec2412ab999cb35cb6a0f98a32d7f88.zip
Fixes several issues with hidden columns in Grid (#17023)
Makes sure that hidden columns are taken into account when calculating indices. This is because escalator doesn't know about hidden columns, thus need to convert cell indices to actual column indices in quite many places. Change-Id: I4c0f3097938ee9340a1922464e12ad7261084ecb
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/grid')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java149
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java24
2 files changed, 168 insertions, 5 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java
index 87af43af12..aca7689a0a 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnHidingTest.java
@@ -27,8 +27,11 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import com.vaadin.testbench.elements.GridElement.GridCellElement;
import com.vaadin.testbench.parallel.TestCategory;
@TestCategory("grid")
@@ -403,10 +406,9 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest {
verifyColumnHidingTogglesOrder(4, 3, 1, 0);
}
- // know issue, will be fixed in next patch
@Test
- @Ignore
- public void testColumnHidingAndReorder_reorderingOverHiddenColumns_orderIsKept() {
+ public void testColumnHidingAndReorder_reorderingOverHiddenColumn_orderIsKept() {
+ selectMenuPath("Component", "State", "Width", "1000px");
toggleColumnReorder();
toggleHideColumnAPI(0);
assertColumnHeaderOrder(1, 2, 3, 4, 5);
@@ -416,6 +418,142 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest {
toggleHideColumnAPI(0);
assertColumnHeaderOrder(0, 2, 1, 3, 4, 5);
+
+ toggleHideColumnAPI(1);
+ assertColumnHeaderOrder(0, 2, 3, 4, 5);
+
+ // right side of hidden column
+ dragAndDropColumnHeader(0, 0, 2, 5);
+ assertColumnHeaderOrder(2, 0, 3, 4, 5);
+
+ toggleHideColumnAPI(1);
+ assertColumnHeaderOrder(2, 1, 0, 3, 4, 5);
+
+ toggleHideColumnAPI(0);
+ assertColumnHeaderOrder(2, 1, 3, 4, 5);
+
+ // left side of hidden column
+ dragAndDropColumnHeader(0, 0, 1, 100);
+ assertColumnHeaderOrder(1, 2, 3, 4, 5);
+
+ toggleHideColumnAPI(0);
+ assertColumnHeaderOrder(1, 0, 2, 3, 4, 5);
+ }
+
+ @Test
+ public void testColumnHidingAndReorder_reorderingWithMultipleHiddenColumns_works() {
+ selectMenuPath("Component", "State", "Width", "1000px");
+ toggleColumnReorder();
+ toggleHideColumnAPI(2);
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ dragAndDropDefaultColumnHeader(0, 2, 5);
+ assertColumnHeaderOrder(1, 0, 4, 5, 6);
+
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(1, 3, 0, 4, 5, 6);
+
+ toggleHideColumnAPI(2);
+ assertColumnHeaderOrder(1, 2, 3, 0, 4, 5, 6);
+
+ toggleHideColumnAPI(0);
+ toggleHideColumnAPI(4);
+ assertColumnHeaderOrder(1, 2, 3, 5, 6);
+
+ dragAndDropDefaultColumnHeader(4, 3, 2);
+ assertColumnHeaderOrder(1, 2, 3, 6, 5);
+
+ dragAndDropDefaultColumnHeader(4, 2, 100);
+ assertColumnHeaderOrder(1, 2, 3, 5, 6);
+
+ toggleHideColumnAPI(0);
+ assertColumnHeaderOrder(1, 2, 3, 0, 5, 6);
+
+ toggleHideColumnAPI(4);
+ assertColumnHeaderOrder(1, 2, 3, 0, 4, 5, 6);
+ }
+
+ @Test
+ public void testReorderingHiddenColumns_movingHiddenColumn_indexIsUpdated() {
+ selectMenuPath("Component", "State", "Width", "1000px");
+ toggleHideColumnAPI(2);
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ moveColumnLeft(3);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(0, 1, 3, 4, 5, 6);
+ toggleHideColumnAPI(2);
+ assertColumnHeaderOrder(0, 1, 3, 2, 4, 5, 6);
+
+ toggleHideColumnAPI(2);
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ moveColumnLeft(2);
+ moveColumnLeft(2);
+ moveColumnLeft(2);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ toggleHideColumnAPI(2);
+ assertColumnHeaderOrder(2, 0, 1, 4, 5, 6);
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(2, 0, 1, 3, 4, 5, 6);
+ }
+
+ // keyboard actions not working in client side test case?
+ @Test
+ @Ignore
+ public void testNavigationWithHiddenColumns_navigatingOverHiddenColumn_goesToNextVisibleColumn() {
+ selectMenuPath("Component", "State", "Width", "1000px");
+ toggleHideColumnAPI(2);
+ toggleHideColumnAPI(3);
+ assertColumnHeaderOrder(0, 1, 4, 5, 6);
+
+ getGridElement().getCell(2, 4).click();
+ GridCellElement cell = getGridElement().getCell(2, 4);
+ assertTrue(cell.isFocused());
+
+ new Actions(getDriver()).sendKeys(Keys.ARROW_LEFT);
+ cell = getGridElement().getCell(2, 1);
+ assertTrue(cell.isFocused());
+
+ new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
+ cell = getGridElement().getCell(2, 4);
+ assertTrue(cell.isFocused());
+ }
+
+ @Test
+ public void testNavigationWithHiddenColumns_hiddenFirstAndLastColumn_keepsNavigation() {
+ selectMenuPath("Component", "State", "Width", "1000px");
+ toggleHideColumnAPI(0);
+ assertColumnHeaderOrder(1, 2, 3, 4, 5, 6);
+
+ getGridElement().getCell(2, 1).click();
+ assertTrue(getGridElement().getCell(2, 1).isFocused());
+
+ new Actions(getDriver()).sendKeys(Keys.ARROW_LEFT);
+ GridCellElement cell = getGridElement().getCell(2, 1);
+ assertTrue(cell.isFocused());
+
+ scrollGridHorizontallyTo(10000);
+
+ //
+ getGridElement().getHeaderCell(0, 9).click();
+ cell = getGridElement().getHeaderCell(0, 9);
+ assertTrue(cell.isFocused());
+ toggleHideColumnAPI(10);
+ toggleHideColumnAPI(11);
+
+ new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
+ new Actions(getDriver()).sendKeys(Keys.ARROW_RIGHT);
+ toggleHideColumnAPI(10);
+ toggleHideColumnAPI(11);
+ cell = getGridElement().getHeaderCell(0, 9);
+ assertTrue(cell.isFocused());
}
private void verifyColumnHidingTogglesOrder(int... indices) {
@@ -487,6 +625,11 @@ public class GridColumnHidingTest extends GridBasicClientFeaturesTest {
getSidebarOpenButton().click();
}
+ private void moveColumnLeft(int index) {
+ selectMenuPath("Component", "Columns", "Column " + index,
+ "Move column left");
+ }
+
private void toggleHidableColumnAPI(int columnIndex) {
selectMenuPath("Component", "Columns", "Column " + columnIndex,
"Hidable");
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
index a79a954faa..84f3f9a62f 100644
--- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridColumnReorderTest.java
@@ -29,7 +29,6 @@ import com.vaadin.testbench.parallel.TestCategory;
/**
*
- * @since
* @author Vaadin Ltd
*/
@TestCategory("grid")
@@ -180,6 +179,27 @@ public class GridColumnReorderTest extends GridBasicClientFeaturesTest {
}
@Test
+ public void testColumnReorderWithHiddenColumn_draggingFocusedCellColumnOverHiddenColumn_focusIsKeptOnCell() {
+ // given
+ toggleColumnReorder();
+ selectMenuPath("Component", "Columns", "Column 1", "Hidden");
+ focusCell(2, 2);
+ assertFocusedCell(2, 2);
+
+ // when
+ dragAndDropDefaultColumnHeader(1, 0, 10);
+
+ // then
+ assertFocusedCell(2, 2);
+
+ // when
+ dragAndDropDefaultColumnHeader(0, 2, 10);
+
+ // then
+ assertFocusedCell(2, 2);
+ }
+
+ @Test
public void testColumnReorder_dragColumnFromRightToLeftOfFocusedCellColumn_focusIsKept() {
// given
toggleColumnReorder();
@@ -339,7 +359,7 @@ public class GridColumnReorderTest extends GridBasicClientFeaturesTest {
selectMenuPath("Component", "Header", "Row 2", "Join columns 3, 4, 5");
dragAndDropColumnHeader(0, 0, 4, 100);
scrollGridHorizontallyTo(0);
- dragAndDropColumnHeader(0, 1, 4, 80);
+ dragAndDropColumnHeader(0, 1, 4, 100);
scrollGridHorizontallyTo(0);
selectMenuPath("Component", "Header", "Row 3", "Join columns 1, 2");
assertColumnHeaderOrder(1, 3, 4, 5, 2);