diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-02-26 15:49:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-26 15:49:47 +0200 |
commit | d336bfa5bf20b8187f498a9f41c04d706bbe2a28 (patch) | |
tree | 509c4bd77394a71dfa810ba40b3157538cd1fc55 /uitest/src | |
parent | 551177326f6ae8c4ddd7d5b3ab3bb3311304cc0a (diff) | |
download | vaadin-framework-d336bfa5bf20b8187f498a9f41c04d706bbe2a28.tar.gz vaadin-framework-d336bfa5bf20b8187f498a9f41c04d706bbe2a28.zip |
Merged column headers should work within declarative Grid. (#12206)
- null check to prevent NPE from the merged column headers
- convert to internal columnIds for merge handling
- use correct cell in merge handling
- switch away from streams in merge handling for easier readability
- regression test
Fixes: #10464
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeGrid.java | 65 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/declarative/DeclarativeGridTest.java | 19 |
2 files changed, 84 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeGrid.java b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeGrid.java new file mode 100644 index 0000000000..082d99b309 --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/declarative/DeclarativeGrid.java @@ -0,0 +1,65 @@ +package com.vaadin.tests.declarative; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import java.io.ByteArrayInputStream; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.declarative.Design; +import com.vaadin.ui.declarative.DesignContext; + +public class DeclarativeGrid extends AbstractTestUI { + + private String design = "" + // + " <vaadin-grid>\n" + // + " <table>\n" + // + " <colgroup>\n" + // + " <col column-id=\"project\" sortable=\"false\">\n" + // + " <col column-id=\"status\" sortable=\"false\">\n" + // + " <col column-id=\"date\" sortable=\"false\">\n" + // + " </colgroup>\n" + // + " <thead>\n" + // + " <tr default>\n" + // + " <th plain-text column-ids=\"project,status\" " + // + " colspan=\"2\">Project and Status</th>\n" + // + " <th plain-text column-ids=\"date\">Date</th>\n" + // + " </tr>\n" + // + " </thead>\n" + // + " <tbody>\n" + // + " <tr item=\"project1\">\n" + // + " <td>Customer Project 1</td>\n" + // + " <td>OK</td>\n" + // + " <td>2020-12-31</td>\n" + // + " </tr>\n" + // + " <tr item=\"project2\">\n" + // + " <td>Customer Project 2</td>\n" + // + " <td>OK</td>\n" + // + " <td>2020-07-02</td>\n" + // + " </tr>\n" + // + " <tr item=\"project3\">\n" + // + " <td>Customer Project 3</td>\n" + // + " <td>OK</td>\n" + // + " <td>2019-10-01</td>\n" + // + " </tr>\n" + // + " </tbody>\n" + // + " </table>\n" + // + " </vaadin-grid>"; + + @Override + protected void setup(VaadinRequest request) { + DesignContext dc = Design + .read(new ByteArrayInputStream(design.getBytes(UTF_8)), null); + addComponent(dc.getRootComponent()); + } + + @Override + protected Integer getTicketNumber() { + return 10464; + } + + @Override + protected String getTestDescription() { + return "Merged column header should not cause an exception."; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/declarative/DeclarativeGridTest.java b/uitest/src/test/java/com/vaadin/tests/declarative/DeclarativeGridTest.java new file mode 100644 index 0000000000..5babbae75b --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/declarative/DeclarativeGridTest.java @@ -0,0 +1,19 @@ +package com.vaadin.tests.declarative; + +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class DeclarativeGridTest extends MultiBrowserTest { + + @Test + public void testMergedHeaderCell() { + openTestURL(); + waitForElementPresent(By.className("v-label")); + // ensure the grid gets loaded and has the merged header + GridElement grid = $(GridElement.class).first(); + grid.getHeaderCellByCaption("Project and Status"); + } +} |