diff options
author | Leif Åstrand <leif@vaadin.com> | 2015-02-06 11:34:20 +0200 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2015-02-06 12:39:28 +0200 |
commit | 276797fad8642c68b2201f3752d025a231519e8f (patch) | |
tree | 497f302f4458ba1256ada33fb9d2e1e60f4a62f0 /uitest | |
parent | ece89116e15c56f3f61aa92c581ab06ce0cd7393 (diff) | |
download | vaadin-framework-276797fad8642c68b2201f3752d025a231519e8f.tar.gz vaadin-framework-276797fad8642c68b2201f3752d025a231519e8f.zip |
Show editor save error (#16602)
Change-Id: I2727a9fabef4291798e97495c2df86b077387cbb
Diffstat (limited to 'uitest')
4 files changed, 39 insertions, 10 deletions
diff --git a/uitest/src/com/vaadin/testbench/elements/GridElement.java b/uitest/src/com/vaadin/testbench/elements/GridElement.java index 5d85de4eb6..e04140a3e0 100644 --- a/uitest/src/com/vaadin/testbench/elements/GridElement.java +++ b/uitest/src/com/vaadin/testbench/elements/GridElement.java @@ -129,6 +129,22 @@ public class GridElement extends AbstractComponentElement { public void cancel() { findElement(By.className("v-grid-editor-cancel")).click(); } + + /** + * Gets the error message text, or <code>null</code> if no message is + * present. + */ + public String getErrorMessage() { + WebElement messageWrapper = findElement(By + .className("v-grid-editor-message")); + List<WebElement> divs = messageWrapper.findElements(By + .tagName("div")); + if (divs.isEmpty()) { + return null; + } else { + return divs.get(0).getText(); + } + } } /** diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java index 2d8c9eb763..04f5e1558d 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/client/GridEditorClientTest.java @@ -33,6 +33,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.shared.ui.grid.GridConstants; +import com.vaadin.testbench.elements.GridElement.GridEditorElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicClientFeaturesTest; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; @@ -199,13 +200,23 @@ public class GridEditorClientTest extends GridBasicClientFeaturesTest { public void testErrorField() { selectMenuPath(EDIT_ROW_5); + GridEditorElement editor = getGridElement().getEditor(); + assertTrue("No errors should be present", - getEditor().findElements(By.className("error")).isEmpty()); + editor.findElements(By.className("error")).isEmpty()); + assertEquals("No error message should be present", null, + editor.getErrorMessage()); + selectMenuPath("Component", "Editor", "Toggle second editor error"); getSaveButton().click(); - assertEquals("Unexpected amount of error fields", 1, getEditor() + assertEquals("Unexpected amount of error fields", 1, editor .findElements(By.className("error")).size()); + assertEquals( + "Unexpedted error message", + "Syntethic fail of editor in column 2. " + + "This message is so long that it doesn't fit into its box", + editor.getErrorMessage()); } protected WebElement getSaveButton() { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java index e1567b4286..f37a94358a 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorTest.java @@ -38,7 +38,6 @@ import com.vaadin.testbench.elements.GridElement.GridEditorElement; import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeatures; import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; -import com.vaadin.tests.tb3.newelements.FixedNotificationElement; public class GridEditorTest extends GridBasicFeaturesTest { @@ -220,10 +219,9 @@ public class GridEditorTest extends GridBasicFeaturesTest { intField.clear(); intField.sendKeys("banana phone"); editor.save(); - FixedNotificationElement n = $(FixedNotificationElement.class).first(); + assertEquals("Column 7: Could not convert value to Integer", - n.getCaption()); - n.close(); + editor.getErrorMessage()); assertTrue("Field 7 should have been marked with an error after error", editor.isFieldErrorMarked(7)); editor.cancel(); @@ -231,6 +229,8 @@ public class GridEditorTest extends GridBasicFeaturesTest { selectMenuPath(EDIT_ITEM_100); assertFalse("Exception should not exist", isElementPresent(NotificationElement.class)); + assertEquals("There should be no editor error message", null, + editor.getErrorMessage()); } @Test diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java index 7509054957..232a3a780e 100644 --- a/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java +++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java @@ -125,9 +125,11 @@ public class GridBasicClientFeaturesWidget extends @Override public void save(EditorRequest<List<Data>> request) { if (secondEditorError) { - log.setText("Syntethic fail of editor in column 2"); - request.failure(Collections.<Column<?, List<Data>>> singleton(grid - .getColumn(2))); + request.failure( + "Syntethic fail of editor in column 2. " + + "This message is so long that it doesn't fit into its box", + Collections.<Column<?, List<Data>>> singleton(grid + .getColumn(2))); return; } try { @@ -153,7 +155,7 @@ public class GridBasicClientFeaturesWidget extends request.success(); } catch (Exception e) { Logger.getLogger(getClass().getName()).warning(e.toString()); - request.failure(null); + request.failure(null, null); } } |