* Removing code causing the trouble Removing code that was apparently not needed in previous fix and caused regression Fixes: https://github.com/vaadin/framework/issues/11895 * Added feature to test UI * Added test case * Adding missing import * Fixing test UI * Enable DateFieldtags/8.11.0.alpha1
public void renderCalendar(boolean updateDate) { | public void renderCalendar(boolean updateDate) { | ||||
if (parent instanceof VAbstractPopupCalendar | if (parent instanceof VAbstractPopupCalendar | ||||
&& !((VAbstractPopupCalendar) parent).popup.isShowing()) { | && !((VAbstractPopupCalendar) parent).popup.isShowing()) { | ||||
if (getDate() == null) { | |||||
// no date set, cannot pre-render yet | |||||
return; | |||||
} | |||||
// a popup that isn't open cannot possibly need a focus change event | // a popup that isn't open cannot possibly need a focus change event | ||||
updateDate = false; | updateDate = false; | ||||
} | } |
dateField.setRangeEnd(LocalDate.of(2020, 1, 1)); | dateField.setRangeEnd(LocalDate.of(2020, 1, 1)); | ||||
}); | }); | ||||
Button resetValueButton = new Button("Reset value"); | |||||
resetValueButton.setId("resetValue"); | |||||
resetValueButton.addClickListener(event -> { | |||||
dateField.setValue(LocalDate.now()); | |||||
}); | |||||
addComponent(dateField); | addComponent(dateField); | ||||
addComponent(dateReadOnlySwitch); | addComponent(dateReadOnlySwitch); | ||||
addComponent(addRangeButton); | addComponent(addRangeButton); | ||||
addComponent(resetValueButton); | |||||
} | } | ||||
@Override | @Override |
import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
import org.openqa.selenium.By; | |||||
import com.vaadin.testbench.elements.ButtonElement; | import com.vaadin.testbench.elements.ButtonElement; | ||||
import com.vaadin.testbench.elements.DateFieldElement; | import com.vaadin.testbench.elements.DateFieldElement; | ||||
assertEquals("Unexpected date change.", "1/19", df.getValue()); | assertEquals("Unexpected date change.", "1/19", df.getValue()); | ||||
} | } | ||||
@Test | |||||
public void testPopupOpenWithDateNotInRange() { | |||||
openTestURL(); | |||||
DateFieldElement df = $(DateFieldElement.class).first(); | |||||
// switch read-only state | |||||
$(ButtonElement.class).id("readOnly").click(); | |||||
// set value before range | |||||
$(ButtonElement.class).id("resetValue").click(); | |||||
// add range, previously set date is not in range | |||||
$(ButtonElement.class).id("addRange").click(); | |||||
// Test that popup still opens | |||||
df.openPopup(); | |||||
waitForElementPresent(By.className("v-datefield-popup")); | |||||
assertElementPresent(By.className("v-datefield-popup")); | |||||
} | |||||
} | } |