summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2020-02-13 09:40:12 +0200
committerZhe Sun <31067185+ZheSun88@users.noreply.github.com>2020-02-20 16:23:38 +0200
commit2b0c501a1fe486ed3e1ee64423223dfb9d2f562e (patch)
tree6a1ab467e3e731e4736efc0d19d13acc10491a9e /uitest
parentaec6dcd3824369ddab95af9c0d7245c82a10665c (diff)
downloadvaadin-framework-2b0c501a1fe486ed3e1ee64423223dfb9d2f562e.tar.gz
vaadin-framework-2b0c501a1fe486ed3e1ee64423223dfb9d2f562e.zip
Fix logic of lexicographical comparison of DateField range end (#11885)
* Fix logic of lexicographical comparison of DateField range end Fix logic of lexicographical comparison of DateField range end with large year numbers ( > 9999) Fixes #11881 * Added tests Purpose of dateFieldRangeYearDigitsIncrease() is to test that rangeEnd works correctly on 4 to 5 digits change boundary Purpose of dateFieldRangeYearBigNumbersPopupOpens() is to test that popup opens also when there is more than 4 digits in year * Fixing typo * Add error message * Set the date of the field in test * Fixing
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldBinderCrossValidationTest.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldBinderCrossValidationTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldBinderCrossValidationTest.java
index 77bf68d9a3..efbbf3f999 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldBinderCrossValidationTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldBinderCrossValidationTest.java
@@ -10,6 +10,7 @@ import com.vaadin.testbench.elements.LabelElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
public class DateFieldBinderCrossValidationTest extends SingleBrowserTest {
@@ -37,4 +38,49 @@ public class DateFieldBinderCrossValidationTest extends SingleBrowserTest {
assertEquals("Error message should be null", EXPECTED_NULL_ERROR,
label.getText());
}
+
+ @Test
+ public void dateFieldRangeYearDigitsIncrease() {
+ openTestURL();
+
+ DateFieldElement toField = $(DateFieldElement.class).id("to-field");
+ // This will set the rangeEnd of the fromField
+ WebElement toFieldText = toField.findElement(By.tagName("input"));
+ toFieldText.sendKeys("9999/12/31", Keys.ENTER);
+
+ DateFieldElement fromField = $(DateFieldElement.class).id("from-field");
+ WebElement fromFieldText = fromField.findElement(By.tagName("input"));
+ // Set year to 9999, next year and next month will be on 10000
+ fromFieldText.sendKeys("9999/12/01", Keys.ENTER);
+ fromField.openPopup();
+ waitForElementPresent(By.className("v-datefield-popup"));
+
+ WebElement monthYearLabel = findElement(By.className("v-datefield-calendarpanel-month"));
+
+ // The next month button should be disabled
+ findElement(By.className("v-button-nextmonth")).click();
+ // Test that year has not changed
+ assertTrue("Month label should contain 9999, contains: "+monthYearLabel.getText(),monthYearLabel.getText().contains("9999"));
+
+ // The next year button should be disabled
+ findElement(By.className("v-button-nextyear")).click();
+ // Test that year has not changed
+ assertTrue("Month label should contain 9999, contains: "+monthYearLabel.getText(),monthYearLabel.getText().contains("9999"));
+ }
+
+ @Test
+ public void dateFieldRangeYearBigNumbersPopupOpens() {
+ openTestURL();
+
+ DateFieldElement toField = $(DateFieldElement.class).id("to-field");
+ // This will set the rangeEnd of the fromField
+ WebElement toFieldText = toField.findElement(By.tagName("input"));
+ toFieldText.sendKeys("10000/12/31", Keys.ENTER);
+ DateFieldElement fromField = $(DateFieldElement.class).id("from-field");
+
+ // Test that popup opens
+ fromField.openPopup();
+ waitForElementPresent(By.className("v-datefield-popup"));
+ assertElementPresent(By.className("v-datefield-popup"));
+ }
}