diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-20 08:54:49 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-10-20 09:54:49 +0300 |
commit | 70ba487b622ab13aa39f45cb53507065c180dc56 (patch) | |
tree | 8a7736e3382e6e22980f389d341dc9a1e6c94ebc /uitest/src/test | |
parent | 4148d910a556c873477da62f1e31b0e285b8b4d9 (diff) | |
download | vaadin-framework-70ba487b622ab13aa39f45cb53507065c180dc56.tar.gz vaadin-framework-70ba487b622ab13aa39f45cb53507065c180dc56.zip |
AbstractDateField: set value after being invalid (#10187)
Fixes #9763
Fixes #9978
Diffstat (limited to 'uitest/src/test')
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalidTest.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalidTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalidTest.java new file mode 100644 index 0000000000..5e25c55cc6 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalidTest.java @@ -0,0 +1,76 @@ +package com.vaadin.tests.components.datefield; + +import static java.time.temporal.ChronoUnit.DAYS; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDate; + +import org.junit.Test; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.DateFieldElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class DateFieldSetAfterInvalidTest extends MultiBrowserTest { + + private static final org.openqa.selenium.By ERROR_INDICATOR_BY = By + .className("v-errorindicator"); + + private static String INVALID_TEXT = "abc"; + + @Test + public void setValueAfterBeingInvalid() { + openTestURL(); + + DateFieldElement dateField = $(DateFieldElement.class).first(); + dateField.setDate(LocalDate.now().minus(5, DAYS)); + assertNoErrorIndicator(); + + dateField.setValue(dateField.getValue() + INVALID_TEXT); + assertErrorIndicator(); + + $(ButtonElement.class).caption("Today").first().click(); + + assertFalse(dateField.getValue().endsWith(INVALID_TEXT)); + assertNoErrorIndicator(); + } + + @Test + public void clearAfterBeingInvalid() { + openTestURL(); + + DateFieldElement dateField = $(DateFieldElement.class).first(); + dateField.setDate(LocalDate.now().minus(5, DAYS)); + assertNoErrorIndicator(); + + dateField.setValue(dateField.getValue() + INVALID_TEXT); + assertErrorIndicator(); + + $(ButtonElement.class).caption("Clear").first().click(); + + assertTrue(dateField.getValue().isEmpty()); + assertNoErrorIndicator(); + + dateField.setValue(INVALID_TEXT); + assertErrorIndicator(); + } + + @Test + public void invalidTypedText() { + openTestURL(); + + DateFieldElement dateField = $(DateFieldElement.class).first(); + dateField.setValue(INVALID_TEXT); + assertErrorIndicator(); + } + + private void assertErrorIndicator() { + assertElementPresent(ERROR_INDICATOR_BY); + } + + private void assertNoErrorIndicator() { + assertElementNotPresent(ERROR_INDICATOR_BY); + } +} |