Skip to content

Commit

Permalink
test: adapt Testers to component changes (#1589)
Browse files Browse the repository at this point in the history
TextField hierarchy has changed.
Temporary fix for TextAreaTester test, setting required with setRequiredIndicatorVisible
mcollovati authored Dec 21, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent fc594a7 commit d00bdfa
Showing 5 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ public void textAreaWithMaxLength_lengthIsChecked() {
@Test
public void textAreaWithRequired_valueIsChecked() {
TextArea tf = view.textArea;
tf.setRequired(true);
tf.setRequiredIndicatorVisible(true);

final TextAreaTester<TextArea> ta_ = test(tf);
ta_.setValue("value1"); // must be value changed to trigger required
Original file line number Diff line number Diff line change
@@ -24,8 +24,8 @@
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.textfield.GeneratedVaadinTextField;
import com.vaadin.flow.component.textfield.IntegerField;
import com.vaadin.flow.component.textfield.InternalFieldBase;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.dom.Element;
import com.vaadin.testbench.unit.ComponentTesterTest.Span;
@@ -493,7 +493,7 @@ void withValue_expectedNull_findsAllComponent() {
rootElement.appendChild(otherField.getElement());

Assertions.assertIterableEquals(List.of(targetField, otherField),
$(GeneratedVaadinTextField.class).withValue(null).all());
$(InternalFieldBase.class).withValue(null).all());
}

@Test
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ public void setValue(V value) {
}

private boolean isValid(V value) {
final boolean isRequiredButEmpty = getComponent().isRequiredBoolean()
final boolean isRequiredButEmpty = getComponent().isRequired()
&& Objects.equals(getComponent().getEmptyValue(), value);
final boolean isGreaterThanMax = value != null
&& value.doubleValue() > getComponent().getMaxDouble();
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@ public TextAreaTester(T component) {
/**
* Set the value to the component if it is usable.
*
* For a non interactable component an IllegalStateException will be thrown
* as the end user would not be able to set a value.
*
* @param value
* value to set
*/
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
*/
@Tests({ TextField.class, PasswordField.class, EmailField.class,
BigDecimalField.class })
public class TextFieldTester<T extends GeneratedVaadinTextField<T, V>, V>
public class TextFieldTester<T extends InternalFieldBase<T, V>, V>
extends ComponentTester<T> {

/**
@@ -40,6 +40,9 @@ public TextFieldTester(T component) {
/**
* Set the value to the component if it is usable.
*
* For a non interactable component an IllegalStateException will be thrown
* as the end user would not be able to set a value.
*
* @param value
* value to set
*/

0 comments on commit d00bdfa

Please sign in to comment.