From 2b0c501a1fe486ed3e1ee64423223dfb9d2f562e Mon Sep 17 00:00:00 2001 From: Tatu Lund Date: Thu, 13 Feb 2020 09:40:12 +0200 Subject: 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 --- .../DateFieldBinderCrossValidationTest.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'uitest') 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")); + } } -- cgit v1.2.3