diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2021-03-16 09:45:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-16 09:45:15 +0200 |
commit | 898e8e793a450953ae15b41f93c58e958948bc04 (patch) | |
tree | 0bda104a7c01ceadab99d1aff757f7fe4839eb89 | |
parent | c92423b04d14e339e0146f247525eb5d2864048c (diff) | |
download | vaadin-framework-898e8e793a450953ae15b41f93c58e958948bc04.tar.gz vaadin-framework-898e8e793a450953ae15b41f93c58e958948bc04.zip |
Test fixes and tweaks (#12239)
- Properly init client-side data in GridDataChangeHandlerTest
- Update Chrome version
- Separate and refactor ComboboxMenuBarAutoopenTest test cases to match
test description
- Update screenshot for ResponsiveStylesTest
- Refactor TextAreaEventPropagationTest to better match expected
behavior
- Add delay to GridDetailsClientTest and EscalatorSpacerTest for
stability
- Add delay and retries to TreeItemDoubleClickTest for stability
Co-authored-by: Teemu Suo-Anttila <teemusa@vaadin.com>
8 files changed, 82 insertions, 46 deletions
diff --git a/uitest/reference-screenshots/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png b/uitest/reference-screenshots/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png Binary files differindex 608ac63b8a..215a5cc52c 100644 --- a/uitest/reference-screenshots/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png +++ b/uitest/reference-screenshots/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png diff --git a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridDataChangeHandlerWidget.java b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridDataChangeHandlerWidget.java index 0d68c385c4..055fad260a 100644 --- a/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridDataChangeHandlerWidget.java +++ b/uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridDataChangeHandlerWidget.java @@ -65,6 +65,8 @@ public class GridDataChangeHandlerWidget extends Composite { public RemoteDelayedDataSource(List<String> datasource) { super(); rows = datasource; + // Make Grid request not exceed actual size. + resetDataAndSize(rows.size()); } @Override @@ -86,7 +88,6 @@ public class GridDataChangeHandlerWidget extends Composite { public Object getRowKey(String row) { return row; } - } public GridDataChangeHandlerWidget() { diff --git a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java index ec3fb525a3..a7c7b38006 100644 --- a/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java +++ b/uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java @@ -25,7 +25,7 @@ public class VerifyBrowserVersionTest extends MultiBrowserTest { // Chrome version does not necessarily match the desired version // because of auto updates... browserIdentifier = getExpectedUserAgentString( - getDesiredCapabilities()) + "88"; + getDesiredCapabilities()) + "89"; } else { browserIdentifier = getExpectedUserAgentString(desiredCapabilities) + desiredCapabilities.getVersion(); diff --git a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java index bdb47da998..3fb5203580 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.combobox; -import org.junit.Assert; +import static org.junit.Assert.assertFalse; + import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @@ -9,6 +10,7 @@ import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.elements.MenuBarElement; import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.tb3.newelements.ComboBoxElement; +import com.vaadin.ui.Notification.Type; /** * Test that checks whether Combobox popup is closed on click to autoopen @@ -20,24 +22,32 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { @Test public void closeComboboxPopupOnClickToMenuBar() { - setDebug(true); openTestURL(); openPopup(); MenuBarElement menuBar = selectMenuBar(); menuBar.click(); - Assert.assertFalse("Combobox popup items are visible", + assertFalse("Combobox popup items are visible", isElementPresent(By.className("gwt-MenuItem"))); + } + + @Test + public void closeComboboxPopupOnClickToMenuBarItem() { + openTestURL(); openPopup(); - menuBar = selectMenuBar(); + // hover over menubar to open WebElement menuBarItem = findElement( By.className("v-menubar-menuitem-caption")); - Actions actions = new Actions(getDriver()); - actions.moveToElement(menuBarItem).build().perform(); - menuBar.click(); - Assert.assertFalse("Combobox popup items are visible", + moveToElement(menuBarItem); + + // click submenu item + findElements(By.className("v-menubar-menuitem-caption")).get(1).click(); + assertElementPresent(By.className( + "v-Notification-" + Type.HUMANIZED_MESSAGE.getStyle())); + + assertFalse("Combobox popup items are visible", isElementPresent(By.className("gwt-MenuItem"))); } @@ -47,20 +57,20 @@ public class ComboboxMenuBarAutoopenTest extends MultiBrowserTest { combobox.openPopup(); combobox.focus(); - Actions actions = new Actions(getDriver()); - actions.moveToElement( - getDriver().findElement(By.className("gwt-MenuItem"))).build() - .perform(); + moveToElement(findElement(By.className("gwt-MenuItem"))); } private MenuBarElement selectMenuBar() { MenuBarElement menuBar = $(MenuBarElement.class).first(); menuBar.focus(); - Actions actions = new Actions(getDriver()); - actions.moveToElement(menuBar).build().perform(); + moveToElement(menuBar); return menuBar; } + private void moveToElement(WebElement target) { + Actions actions = new Actions(driver); + actions.moveToElement(target).build().perform(); + } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridDetailsClientTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridDetailsClientTest.java index fb2baf4e69..e99d6053d7 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridDetailsClientTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridDetailsClientTest.java @@ -79,6 +79,7 @@ public class GridDetailsClientTest extends GridBasicClientFeaturesTest { selectMenuPath(SET_GENERATOR); toggleDetailsFor(100); + waitForElementPresent(By.className("gwt-Button")); // scroll a bit beyond so we see below. getGridElement().scrollToRow(101); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java index 28ad3fbdb1..a360cc5128 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java @@ -406,10 +406,12 @@ public class EscalatorSpacerTest extends EscalatorBasicClientFeaturesTest { } @Test - public void spacersAreInCorrectDomPositionAfterScroll() { + public void spacersAreInCorrectDomPositionAfterScroll() + throws InterruptedException { selectMenuPath(FEATURES, SPACERS, ROW_1, SET_100PX); scrollVerticallyTo(32); // roughly one row's worth + sleep(100); WebElement tbody = getEscalator().findElement(By.tagName("tbody")); WebElement spacer = getChild(tbody, 1); diff --git a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java index 0684fc638a..36bb118064 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java @@ -17,13 +17,24 @@ public class TreeItemDoubleClickTest extends MultiBrowserTest { openTestURL(); String caption = "Tree Item 2"; doubleClick(getTreeNodeByCaption(caption)); - assertLogText("Double Click " + caption); + try { + assertLogText("Double Click " + caption); + } catch (AssertionError e) { + // double click is flaky, try again + doubleClick(getTreeNodeByCaption(caption)); + assertLogText("Double Click " + caption); + } changeImmediate(); caption = "Tree Item 3"; doubleClick(getTreeNodeByCaption(caption)); - assertLogText("Double Click " + caption); + try { + assertLogText("Double Click " + caption); + } catch (AssertionError e) { + doubleClick(getTreeNodeByCaption(caption)); + assertLogText("Double Click " + caption); + } } private void changeImmediate() { @@ -36,9 +47,9 @@ public class TreeItemDoubleClickTest extends MultiBrowserTest { .findElement(By.xpath("//span[text() = '" + caption + "']")); } - private void doubleClick(WebElement element) { + private void doubleClick(WebElement element) throws InterruptedException { new Actions(getDriver()).doubleClick(element).build().perform(); - + sleep(100); } private void assertLogText(String text) { diff --git a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java index 6c5513e17d..4bc34801dd 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java @@ -1,16 +1,17 @@ package com.vaadin.tests.components.ui; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.junit.Test; import org.openqa.selenium.Keys; -import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.MultiBrowserTest; -import static org.junit.Assert.assertEquals; - /** * Tests that the TextArea widget correctly stops ENTER events from propagating. * @@ -21,14 +22,17 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { @Test public void textAreaEnterEventPropagation() throws InterruptedException { openTestURL(); - WebElement textArea = $(TextAreaElement.class).first(); + TextAreaElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); builder.click(textArea); - builder.sendKeys(textArea, "first line asdf"); - builder.sendKeys(Keys.ENTER); - builder.sendKeys(textArea, "second line jkl;"); + builder.sendKeys(textArea, "first line asdf", Keys.ENTER, + "second line jkl;"); builder.perform(); + waitUntilLoadingIndicatorNotVisible(); + String text = textArea.getValue(); + assertEquals("Unexpected text area content,", + "first line asdf\nsecond line jkl;", text); // Should not have triggered shortcut assertEquals(" ", getLogRow(0)); } @@ -37,48 +41,55 @@ public class TextAreaEventPropagationTest extends MultiBrowserTest { public void testTextAreaEscapeEventPropagation() throws InterruptedException { openTestURL(); - WebElement textArea = $(TextAreaElement.class).first(); + TextAreaElement textArea = $(TextAreaElement.class).first(); Actions builder = new Actions(driver); builder.click(textArea); - builder.sendKeys(textArea, "first line asdf"); - builder.sendKeys(Keys.ESCAPE); - builder.sendKeys(textArea, "second line jkl;"); + builder.sendKeys(textArea, "first line asdf", Keys.ESCAPE, + "second line jkl;"); builder.perform(); + waitUntilLoadingIndicatorNotVisible(); + String text = textArea.getValue(); + // sendKeys is erratic and can eat some letters after escape, so only + // test that beginning and end are present + assertTrue("Unexpected text area content: " + text, + text.startsWith("first line asdf")); + assertTrue("Unexpected text area content: " + text, + text.endsWith("nd line jkl;")); + assertFalse("Unexpected text area content: " + text, + text.contains("\n")); assertEquals("1. Escape button pressed", getLogRow(0)); } @Test - public void testTextFieldEscapeEventPropagation() throws InterruptedException { + public void testTextFieldEscapeEventPropagation() { openTestURL(); - WebElement textField = $(TextFieldElement.class).first(); + TextFieldElement textField = $(TextFieldElement.class).first(); Actions builder2 = new Actions(driver); builder2.click(textField); - builder2.sendKeys("third line"); - builder2.sendKeys(Keys.ENTER); - sleep(100); - builder2.sendKeys(Keys.ESCAPE); - sleep(100); + builder2.sendKeys(textField, "third line", Keys.ESCAPE); builder2.perform(); - sleep(100); + waitUntilLoadingIndicatorNotVisible(); - assertEquals("1. Enter button pressed", getLogRow(1)); - assertEquals("2. Escape button pressed", getLogRow(0)); + String text = textField.getValue(); + assertEquals("Unexpected text field content,", "third line", text); + assertEquals("1. Escape button pressed", getLogRow(0)); } @Test public void testTextFieldEnterEventPropagation() { openTestURL(); - WebElement textField = $(TextFieldElement.class).first(); + TextFieldElement textField = $(TextFieldElement.class).first(); Actions builder2 = new Actions(driver); builder2.click(textField); - builder2.sendKeys("third line"); - builder2.sendKeys(Keys.ENTER); - + builder2.sendKeys(textField, "third line", Keys.ENTER); builder2.perform(); + waitUntilLoadingIndicatorNotVisible(); + String text = textField.getValue(); + assertEquals("Unexpected text field content,", "third line", text); assertEquals("1. Enter button pressed", getLogRow(0)); } } |