summaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-20 08:54:49 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-10-20 09:54:49 +0300
commit70ba487b622ab13aa39f45cb53507065c180dc56 (patch)
tree8a7736e3382e6e22980f389d341dc9a1e6c94ebc /uitest/src
parent4148d910a556c873477da62f1e31b0e285b8b4d9 (diff)
downloadvaadin-framework-70ba487b622ab13aa39f45cb53507065c180dc56.tar.gz
vaadin-framework-70ba487b622ab13aa39f45cb53507065c180dc56.zip
AbstractDateField: set value after being invalid (#10187)
Fixes #9763 Fixes #9978
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalid.java36
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java11
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalidTest.java76
3 files changed, 114 insertions, 9 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalid.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalid.java
new file mode 100644
index 0000000000..6d7baefb86
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldSetAfterInvalid.java
@@ -0,0 +1,36 @@
+package com.vaadin.tests.components.datefield;
+
+import java.time.LocalDate;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.DateField;
+
+public class DateFieldSetAfterInvalid extends AbstractTestUI {
+
+ @Override
+ protected String getTestDescription() {
+ return "DateField to programatically change the value after having invalid text";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9763;
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ DateField dateField = new DateField();
+ addComponent(dateField);
+
+ Button nowButton = new Button("Today");
+ nowButton.addClickListener(e -> dateField.setValue(LocalDate.now()));
+ addComponent(nowButton);
+
+ Button clearButton = new Button("Clear");
+ clearButton.addClickListener(e -> dateField.clear());
+ addComponent(clearButton);
+ }
+
+}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
index 847a25174a..914c7b490f 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DisabledParentLayout.java
@@ -30,22 +30,15 @@ public class DisabledParentLayout extends AbstractReindeerTestUI {
@Override
protected void setup(VaadinRequest request) {
- VerticalLayout content = new VerticalLayout();
-
- content.setSpacing(true);
- content.setMargin(true);
final VerticalLayout pane = new VerticalLayout();
AbstractLocalDateField dateField = new TestDateField();
pane.addComponent(dateField);
- content.addComponent(pane);
-
Button button = new Button("Test");
button.addClickListener(event -> pane.setEnabled(!pane.isEnabled()));
- content.addComponent(button);
- addComponent(content);
+ addComponents(pane, button);
}
@Override
@@ -55,7 +48,7 @@ public class DisabledParentLayout extends AbstractReindeerTestUI {
@Override
protected Integer getTicketNumber() {
- return 13124;
+ return 4773;
}
}
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);
+ }
+}