aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2020-02-13 09:40:12 +0200
committerGitHub <noreply@github.com>2020-02-13 09:40:12 +0200
commit73db19b6529bf172c3ef484dec0472f3c046fc30 (patch)
treeb740c7c9b632590d2519833984b1a2a138f3a317 /uitest
parentab3d346c56d8ffee70d1b2b6757ec0fd68d270e1 (diff)
downloadvaadin-framework-73db19b6529bf172c3ef484dec0472f3c046fc30.tar.gz
vaadin-framework-73db19b6529bf172c3ef484dec0472f3c046fc30.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"));
+ }
}