diff options
author | cuong-phan <39257573+cuong-phan@users.noreply.github.com> | 2019-05-20 15:00:38 +0300 |
---|---|---|
committer | Sun Zhe <31067185+ZheSun88@users.noreply.github.com> | 2019-05-20 15:00:38 +0300 |
commit | 543a842e673f74b4053bcd22d1603bc3a84e6534 (patch) | |
tree | bfec61a0043cd3bf3600728a5de46883f62f1cc3 /uitest | |
parent | 994f39b9ed46519ca3bfdc8914291e364e44694f (diff) | |
download | vaadin-framework-543a842e673f74b4053bcd22d1603bc3a84e6534.tar.gz vaadin-framework-543a842e673f74b4053bcd22d1603bc3a84e6534.zip |
Fix Grid reordering when there are hidden columns
* Fix grid column reordering
Fix grid column reordering when there are hidden columns and footerRow.join
* Add test
Diffstat (limited to 'uitest')
2 files changed, 110 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooter.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooter.java new file mode 100644 index 0000000000..5d3527ea0a --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooter.java @@ -0,0 +1,76 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.data.provider.DataProvider; +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.components.grid.FooterCell; +import com.vaadin.ui.components.grid.FooterRow; + +import java.util.ArrayList; +import java.util.List; + +public class GridReorderHiddenColumnsJoinedFooter extends AbstractTestUI { + @Override + protected void setup(VaadinRequest request) { + getLayout().setSpacing(true); + + Grid<String> grid = createGrid(); + + addComponents(grid); + } + + private Grid<String> createGrid() { + Grid<String> grid = new Grid<>(); + grid.addColumn(t -> t + "1").setId("col1").setCaption("caption1") + .setHidable(true); + grid.addColumn(t -> t + "2").setId("col2").setCaption("caption2") + .setHidable(true); + grid.addColumn(t -> t + "3").setId("col3").setCaption("caption3") + .setHidable(true); + grid.addColumn(t -> t + "4").setId("col4").setCaption("caption4") + .setHidable(true); + grid.addColumn(t -> t + "5").setId("col5").setCaption("caption5") + .setHidable(true); + grid.addColumn(t -> t + "6").setId("col6").setCaption("caption6") + .setHidable(true); + grid.addColumn(t -> t + "7").setId("col7").setCaption("caption7") + .setHidable(true); + grid.addColumn(t -> t + "8").setId("col8").setCaption("caption8") + .setHidable(true); + + grid.setColumnReorderingAllowed(true); + grid.setSizeFull(); + + // join FooterRow together + FooterRow footerRow = grid.appendFooterRow(); + Grid.Column[] columns = grid.getColumns().toArray(new Grid.Column[0]); + FooterCell footerCell = footerRow.join(columns); + footerCell.setText("test"); + + // hide columns + grid.getColumn("col2").setHidden(true); + grid.getColumn("col4").setHidden(true); + grid.getColumn("col5").setHidden(true); + grid.getColumn("col6").setHidden(true); + + List<String> items = new ArrayList<>(); + items.add("content"); + ListDataProvider<String> dataProvider = DataProvider + .ofCollection(items); + grid.setDataProvider(dataProvider); + return grid; + } + + @Override + protected Integer getTicketNumber() { + return 11478; + } + + @Override + protected String getTestDescription() { + return "Column reordering with hidden columns and joined footer should not " + + "be blocked by hidden columns."; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooterTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooterTest.java new file mode 100644 index 0000000000..bae0808280 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridReorderHiddenColumnsJoinedFooterTest.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.components.grid; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.interactions.Actions; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +public class GridReorderHiddenColumnsJoinedFooterTest extends MultiBrowserTest { + @Test + public void test() { + openTestURL(); + + GridElement grid = $(GridElement.class).get(0); + GridElement.GridCellElement headerCell1 = grid + .getHeaderCellByCaption("caption1"); + GridElement.GridCellElement headerCell8 = grid + .getHeaderCellByCaption("caption8"); + + assertThat(grid.getHeaderCell(0, 0), is(headerCell1)); + + new Actions(getDriver()).clickAndHold(headerCell1) + .moveToElement(headerCell8, 2, 0).release().perform(); + + waitForElementNotPresent(By.className("dragged-column-header")); + + assertThat(grid.getHeaderCell(0, 0), not(is(headerCell1))); + assertThat(grid.getHeaderCell(0, 0).getText(), is("caption3")); + } +} |