diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-08-18 15:39:44 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-08-18 15:39:44 +0300 |
commit | 554f39ad0455623fbb1befc4444e67c809de5c0a (patch) | |
tree | 96ba4702a3ee82031808c15386c530e51f08e0b2 /uitest | |
parent | c46678460325f399c75cd8f00ceb230625524f10 (diff) | |
download | vaadin-framework-554f39ad0455623fbb1befc4444e67c809de5c0a.tar.gz vaadin-framework-554f39ad0455623fbb1befc4444e67c809de5c0a.zip |
Fix focus when Grid editor is saved or cancelled (#9835)
Fixes #9832
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java | 43 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java | 7 |
2 files changed, 44 insertions, 6 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java index d6ee3e16a0..288000ff22 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorBufferedTest.java @@ -81,8 +81,7 @@ public class GridEditorBufferedTest extends GridEditorTest { new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); assertEditorClosed(); - assertEquals("100 changed", - getGridElement().getCell(100, 4).getText()); + assertEquals("100 changed", getGridElement().getCell(100, 4).getText()); } @Test @@ -309,4 +308,44 @@ public class GridEditorBufferedTest extends GridEditorTest { assertEditorOpen(); assertEquals("(2, 0)", getGridElement().getCell(2, 0).getText()); } + + @Test + public void testFocusWhenCancelByKeyboard() { + editRow(5); + getGridElement().getEditor().getField(0).click(); + new Actions(getDriver()).sendKeys(Keys.ESCAPE).perform(); + assertTrue("Focus should be in the Grid", + getFocusedElement().getAttribute("class").contains("v-grid")); + } + + @Test + public void testFocusWhenSaveByKeyboard() { + editRow(5); + getGridElement().getEditor().getField(0).click(); + new Actions(getDriver()).sendKeys(Keys.ENTER).perform(); + assertTrue("Focus should be in the Grid", + getFocusedElement().getAttribute("class").contains("v-grid")); + } + + @Test + public void testFocusWhenSaveByClick() { + editRow(5); + + getGridElement().getEditor() + .findElement(By.className("v-grid-editor-save")).click(); + + assertTrue("Focus should be in the Grid", + getFocusedElement().getAttribute("class").contains("v-grid")); + } + + @Test + public void testFocusWhenCancelByClick() { + editRow(5); + + getGridElement().getEditor() + .findElement(By.className("v-grid-editor-cancel")).click(); + + assertTrue("Focus should be in the Grid", + getFocusedElement().getAttribute("class").contains("v-grid")); + } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java index fdf1b9bba9..bd8d0d1ea9 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/GridEditorTest.java @@ -77,8 +77,8 @@ public abstract class GridEditorTest extends GridBasicsTest { } protected void assertEditorOpen() { - assertTrue("Editor is supposed to be open", - getGridElement().isElementPresent(By.vaadin("#editor"))); + waitUntil(driver -> getGridElement() + .isElementPresent(By.vaadin("#editor"))); } protected void assertEditorClosed() { @@ -197,12 +197,11 @@ public abstract class GridEditorTest extends GridBasicsTest { editorPos == editor.getLocation().getY()); } - @Ignore("Needs programmatic sorting") @Test public void testEditorClosedOnSort() { editRow(5); - selectMenuPath("Component", "State", "Sort by column", "Column 0, ASC"); + selectMenuPath("Component", "Columns", "Column 0", "Sort ASC"); assertEditorClosed(); } |