summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2018-07-02 15:43:02 +0300
committerGitHub <noreply@github.com>2018-07-02 15:43:02 +0300
commitaa5546133d5f93a465f36c93b14e7c9d87f4c0c5 (patch)
tree7870eb28fd21445ab3f56fa56355f924907eca16 /uitest
parent879caf3691074ce001d25d56c46df9b94bcc2f46 (diff)
downloadvaadin-framework-aa5546133d5f93a465f36c93b14e7c9d87f4c0c5.tar.gz
vaadin-framework-aa5546133d5f93a465f36c93b14e7c9d87f4c0c5.zip
Fix expanding an added TreeGrid node (#11018)
Fixes #9997
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAdd.java43
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAddTest.java29
2 files changed, 72 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAdd.java b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAdd.java
new file mode 100644
index 0000000000..a86e8cbc6c
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAdd.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components.treegrid;
+
+import com.vaadin.data.TreeData;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.TreeGrid;
+
+public class TreeGridExpandOnAdd extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TreeGrid<Item> tree = new TreeGrid<>(Item.class);
+ Button button = new Button("Add new item", e -> addItem(tree));
+ addComponents(tree, button);
+ }
+
+ private void addItem(TreeGrid<Item> tree) {
+ Item parent = new Item("Parent");
+ Item child = new Item("Child");
+
+ TreeData<Item> treeData = tree.getTreeData();
+ treeData.addItem(null, parent);
+ treeData.addItem(parent, child);
+
+ tree.getDataProvider().refreshAll();
+
+ tree.expand(parent);
+ }
+
+ public static class Item {
+ private String name;
+
+ public Item(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAddTest.java b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAddTest.java
new file mode 100644
index 0000000000..00908a71e6
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/treegrid/TreeGridExpandOnAddTest.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.components.treegrid;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.TreeGridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TreeGridExpandOnAddTest extends SingleBrowserTest {
+
+ @Test
+ public void testNoException() {
+ setDebug(true);
+ openTestURL();
+
+ $(ButtonElement.class).first().click();
+
+ TreeGridElement treeGrid = $(TreeGridElement.class).first();
+ assertEquals("Parent node not added", "Parent",
+ treeGrid.getCell(0, 0).getText());
+ assertEquals("Child node not added", "Child",
+ treeGrid.getCell(1, 0).getText());
+
+ assertNoErrorNotifications();
+ }
+
+}