Skip to content

Commit

Permalink
revert to using selectByText TB API
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Aug 15, 2022
1 parent 7a0470d commit 9d81d02
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.junit.Assert;
import org.junit.Before;
import org.openqa.selenium.Keys;

import com.vaadin.flow.component.timepicker.testbench.TimePickerElement;
import com.vaadin.tests.AbstractComponentIT;
Expand Down Expand Up @@ -33,10 +32,4 @@ protected void assertServerValid(boolean expected) {
var actual = $("div").id(SERVER_VALIDITY_STATE).getText();
Assert.assertEquals(String.valueOf(expected), actual);
}

protected void commitInputValue(String value) {
field.sendKeys(Keys.META, "A"); // Select All
field.sendKeys(Keys.BACK_SPACE);
field.sendKeys(value, Keys.ENTER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public void required_triggerInputBlur_assertValidity() {
public void required_changeInputValue_assertValidity() {
$("button").id(REQUIRED_BUTTON).click();

commitInputValue("12:00");
field.selectByText("12:00");
assertServerValid(true);
assertClientValid(true);

commitInputValue("");
field.selectByText("");
assertServerValid(false);
assertClientValid(false);
}
Expand All @@ -72,15 +72,15 @@ public void required_changeInputValue_assertValidity() {
public void min_changeInputValue_assertValidity() {
$("input").id(MIN_INPUT).sendKeys("11:00", Keys.ENTER);

commitInputValue("10:00");
field.selectByText("10:00");
assertClientValid(false);
assertServerValid(false);

commitInputValue("11:00");
field.selectByText("11:00");
assertClientValid(true);
assertServerValid(true);

commitInputValue("12:00");
field.selectByText("12:00");
assertClientValid(true);
assertServerValid(true);
}
Expand All @@ -89,30 +89,30 @@ public void min_changeInputValue_assertValidity() {
public void max_changeInputValue_assertValidity() {
$("input").id(MAX_INPUT).sendKeys("11:00", Keys.ENTER);

commitInputValue("12:00");
field.selectByText("12:00");
assertClientValid(false);
assertServerValid(false);

commitInputValue("11:00");
field.selectByText("11:00");
assertClientValid(true);
assertServerValid(true);

commitInputValue("10:00");
field.selectByText("10:00");
assertClientValid(true);
assertServerValid(true);
}

@Test
public void badInput_changeInputValue_assertValidity() {
commitInputValue("INVALID");
field.selectByText("INVALID");
assertServerValid(false);
assertClientValid(false);

commitInputValue("10:00");
field.selectByText("10:00");
assertServerValid(true);
assertClientValid(true);

commitInputValue("INVALID");
field.selectByText("INVALID");
assertServerValid(false);
assertClientValid(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public void required_triggerInputBlur_assertValidity() {
public void required_changeInputValue_assertValidity() {
$("input").id(EXPECTED_VALUE_INPUT).sendKeys("10:00", Keys.ENTER);

setInputValue("10:00");
field.selectByText("10:00");
assertServerValid(true);
assertClientValid(true);

setInputValue("");
field.selectByText("");
assertServerValid(false);
assertClientValid(false);
assertErrorMessage(REQUIRED_ERROR_MESSAGE);
Expand All @@ -47,19 +47,19 @@ public void min_changeInputValue_assertValidity() {
$("input").id(EXPECTED_VALUE_INPUT).sendKeys("12:00", Keys.ENTER);

// Constraint validation fails:
setInputValue("10:00");
field.selectByText("10:00");
assertClientValid(false);
assertServerValid(false);
assertErrorMessage("");

// Binder validation fails:
setInputValue("11:00");
field.selectByText("11:00");
assertClientValid(false);
assertServerValid(false);
assertErrorMessage(UNEXPECTED_VALUE_ERROR_MESSAGE);

// Both validations pass:
setInputValue("12:00");
field.selectByText("12:00");
assertClientValid(true);
assertServerValid(true);
}
Expand All @@ -70,19 +70,19 @@ public void max_changeInputValue_assertValidity() {
$("input").id(EXPECTED_VALUE_INPUT).sendKeys("10:00", Keys.ENTER);

// Constraint validation fails:
setInputValue("12:00");
field.selectByText("12:00");
assertClientValid(false);
assertServerValid(false);
assertErrorMessage("");

// Binder validation fails:
setInputValue("11:00");
field.selectByText("11:00");
assertClientValid(false);
assertServerValid(false);
assertErrorMessage(UNEXPECTED_VALUE_ERROR_MESSAGE);

// Both validations pass:
setInputValue("10:00");
field.selectByText("10:00");
assertClientValid(true);
assertServerValid(true);
}
Expand All @@ -91,16 +91,16 @@ public void max_changeInputValue_assertValidity() {
public void badInput_changeInputValue_assertValidity() {
$("input").id(EXPECTED_VALUE_INPUT).sendKeys("10:00", Keys.ENTER);

setInputValue("INVALID");
field.selectByText("INVALID");
assertServerValid(false);
assertClientValid(false);
assertErrorMessage("");

setInputValue("10:00");
field.selectByText("10:00");
assertServerValid(true);
assertClientValid(true);

setInputValue("INVALID");
field.selectByText("INVALID");
assertServerValid(false);
assertClientValid(false);
assertErrorMessage("");
Expand Down

0 comments on commit 9d81d02

Please sign in to comment.