Browse Source

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>
tags/7.7.25
Anna Koskinen 3 years ago
parent
commit
898e8e793a
No account linked to committer's email address

BIN
uitest/reference-screenshots/ResponsiveStylesTest-testValoMenuResponsiveHover_ANY_Chrome__collapsedMenu.png View File


+ 2
- 1
uitest/src/main/java/com/vaadin/tests/widgetset/client/grid/GridDataChangeHandlerWidget.java View File

@@ -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() {

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/VerifyBrowserVersionTest.java View File

@@ -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();

+ 24
- 14
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopenTest.java View File

@@ -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();
}
}

+ 1
- 0
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/client/GridDetailsClientTest.java View File

@@ -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);

+ 3
- 1
uitest/src/test/java/com/vaadin/tests/components/grid/basicfeatures/escalator/EscalatorSpacerTest.java View File

@@ -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);

+ 15
- 4
uitest/src/test/java/com/vaadin/tests/components/tree/TreeItemDoubleClickTest.java View File

@@ -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) {

+ 36
- 25
uitest/src/test/java/com/vaadin/tests/components/ui/TextAreaEventPropagationTest.java View File

@@ -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));
}
}

Loading…
Cancel
Save