diff options
author | Ilia Motornyi <elmot@vaadin.com> | 2018-09-05 17:30:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-05 17:30:23 +0300 |
commit | a958be0aebd8ece258c45c6fb8947c1ff52b11fb (patch) | |
tree | ab00c697749e9329ca665ed12ed63275b12592df | |
parent | 12d504328c7a948dc953f522b879d7c831bf36c0 (diff) | |
download | vaadin-framework-a958be0aebd8ece258c45c6fb8947c1ff52b11fb.tar.gz vaadin-framework-a958be0aebd8ece258c45c6fb8947c1ff52b11fb.zip |
7.7 fix upload test (#11162)
Restore InterruptUploadTest functionality, fix TextChangeEventsTest
Fixes #11161
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java | 13 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java | 30 |
2 files changed, 32 insertions, 11 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java index c000d37d0d..3f3c77379a 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/TextChangeEventsTest.java @@ -7,6 +7,8 @@ import com.vaadin.testbench.elements.TextAreaElement; import com.vaadin.testbench.elements.TextFieldElement; import com.vaadin.tests.tb3.SingleBrowserTest; +import static org.junit.Assert.assertTrue; + public class TextChangeEventsTest extends SingleBrowserTest { @Test @@ -43,16 +45,15 @@ public class TextChangeEventsTest extends SingleBrowserTest { TextFieldElement tfEager = $(TextFieldElement.class).caption("Eager") .first(); tfEager.sendKeys("abc"); - Assert.assertEquals( - "2. Text change event for Eager, text content currently:'abc' Cursor at index:3", - getLogRow(0)); + assertTrue(getLogRow(0).contains( + "Text change event for Eager, text content currently:'abc' Cursor at index:3")); TextFieldElement tfTimeout = $(TextFieldElement.class) .caption("Timeout 3s").first(); tfTimeout.sendKeys("abc"); - Assert.assertEquals( - "3. Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3", - getLogRow(0)); + assertTrue(getLogRow(0).contains( + "Text change event for Timeout 3s, text content currently:'abc' Cursor at index:3")); + getLogRow(0); } } diff --git a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java index 2e7891699e..a26e8bec5f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/upload/InterruptUploadTest.java @@ -1,6 +1,7 @@ package com.vaadin.tests.components.upload; import com.vaadin.testbench.elements.LabelElement; +import com.vaadin.testbench.elements.WindowElement; import com.vaadin.tests.tb3.MultiBrowserTest; import com.vaadin.tests.util.LoremIpsum; import org.junit.Test; @@ -20,25 +21,44 @@ import static org.junit.Assert.assertTrue; public class InterruptUploadTest extends MultiBrowserTest { + private static final String EXPECTED_COUNTER_TEXT = " (counting interrupted at "; + @Test public void testInterruptUpload() throws Exception { openTestURL(); File tempFile = createTempFile(); - // Schedule upload cancel in a second - ((JavascriptExecutor)getDriver()).executeScript("setTimeout( function () {window.document.querySelector(\".v-window .v-button\").click()},2000)"); + scheduleUploadCancel(); fillPathToUploadInput(tempFile.getPath()); // Wait for 3 seconds until everything is done. Thread.sleep(3000); - String expected = " (counting interrupted at "; String actual = $(LabelElement.class).caption("Line breaks counted") .first().getText(); assertTrue("Line break count note does not match expected (was: " - + actual + ")", actual.contains(expected)); + + actual + ")", actual.contains(EXPECTED_COUNTER_TEXT)); + + $(WindowElement.class).first() + .findElement(By.className("v-window-closebox")).click(); + waitForElementNotPresent(By.className("v-window")); + + // Check if second upload happens + tempFile = createTempFile(); + scheduleUploadCancel(); + fillPathToUploadInput(tempFile.getPath()); + + actual = $(LabelElement.class).caption("Line breaks counted").first() + .getText(); + assertTrue("Line break count note does not match expected (was: " + + actual + ")", actual.contains(EXPECTED_COUNTER_TEXT)); + } + private void scheduleUploadCancel() { + // Schedule upload cancel in 2 seconds + ((JavascriptExecutor) getDriver()).executeScript( + "setTimeout( function () {window.document.querySelector(\".v-window .v-button\").click()},2000)"); } /** @@ -93,4 +113,4 @@ public class InterruptUploadTest extends MultiBrowserTest { } } -}
\ No newline at end of file +} |