diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-12-28 14:15:50 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-12-28 14:15:50 +0200 |
commit | 14efb0c7dba1d20a2dabd01c4fa0ac952c928be4 (patch) | |
tree | f33d5f62d52901561708d586d5226fa1a023f92d /uitest | |
parent | 81b05dd2c6fa20e6d1906da40ac323729374f64c (diff) | |
download | vaadin-framework-14efb0c7dba1d20a2dabd01c4fa0ac952c928be4.tar.gz vaadin-framework-14efb0c7dba1d20a2dabd01c4fa0ac952c928be4.zip |
Add keyboard shortcut to save grid editor in buffered mode (#16842)
Change-Id: I4f542d166e15a63f12f8033aec4ef7b95578df71
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java | 84 |
1 files changed, 63 insertions, 21 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java index 69e2a09bc9..8340c40b4b 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridEditorBufferedTest.java @@ -29,6 +29,7 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.shared.ui.grid.GridConstants; +import com.vaadin.testbench.TestBenchElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridEditorElement; import com.vaadin.testbench.elements.NotificationElement; @@ -42,6 +43,52 @@ public class GridEditorBufferedTest extends GridEditorTest { } @Test + public void testKeyboardSave() { + selectMenuPath(EDIT_ITEM_100); + + WebElement textField = getEditorWidgets().get(0); + + textField.click(); + // without this, the click in the middle of the field might not be after + // the old text on some browsers + new Actions(getDriver()).sendKeys(Keys.END).perform(); + + textField.sendKeys(" changed"); + + // Save from keyboard + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + assertEditorClosed(); + assertEquals("(100, 0) changed", getGridElement().getCell(100, 0) + .getText()); + } + + @Test + public void testKeyboardSaveWithInvalidEdition() { + makeInvalidEdition(); + + GridEditorElement editor = getGridElement().getEditor(); + TestBenchElement field = editor.getField(7); + + field.click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + + assertEditorOpen(); + assertEquals("Column 7: Could not convert value to Integer", + editor.getErrorMessage()); + assertTrue("Field 7 should have been marked with an error after error", + editor.isFieldErrorMarked(7)); + + editor.cancel(); + + selectMenuPath(EDIT_ITEM_100); + assertFalse("Exception should not exist", + isElementPresent(NotificationElement.class)); + assertEquals("There should be no editor error message", null, + getGridElement().getEditor().getErrorMessage()); + } + + @Test public void testSave() { selectMenuPath(EDIT_ITEM_100); @@ -84,18 +131,9 @@ public class GridEditorBufferedTest extends GridEditorTest { @Test public void testInvalidEdition() { - selectMenuPath(EDIT_ITEM_5); - assertFalse(logContainsText("Exception occured, java.lang.IllegalStateException")); + makeInvalidEdition(); GridEditorElement editor = getGridElement().getEditor(); - - assertFalse( - "Field 7 should not have been marked with an error before error", - editor.isFieldErrorMarked(7)); - - WebElement intField = editor.getField(7); - intField.clear(); - intField.sendKeys("banana phone"); editor.save(); assertEquals("Column 7: Could not convert value to Integer", @@ -111,6 +149,21 @@ public class GridEditorBufferedTest extends GridEditorTest { getGridElement().getEditor().getErrorMessage()); } + private void makeInvalidEdition() { + selectMenuPath(EDIT_ITEM_5); + assertFalse(logContainsText("Exception occured, java.lang.IllegalStateException")); + + GridEditorElement editor = getGridElement().getEditor(); + + assertFalse( + "Field 7 should not have been marked with an error before error", + editor.isFieldErrorMarked(7)); + + WebElement intField = editor.getField(7); + intField.clear(); + intField.sendKeys("banana phone"); + } + @Test public void testEditorInDisabledGrid() { int originalScrollPos = getGridVerticalScrollPos(); @@ -232,17 +285,6 @@ public class GridEditorBufferedTest extends GridEditorTest { } @Test - public void testKeyboardOpeningDisabledWhenOpen() { - selectMenuPath(EDIT_ITEM_5); - - new Actions(getDriver()).click(getGridElement().getCell(4, 0)) - .sendKeys(Keys.ENTER).perform(); - - assertEquals("Editor should still edit row 5", "(5, 0)", - getEditorWidgets().get(0).getAttribute("value")); - } - - @Test public void testProgrammaticOpeningDisabledWhenOpen() { selectMenuPath(EDIT_ITEM_5); assertEditorOpen(); |