diff --git a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationIT.java b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationIT.java index c5db642993a..7ab74a7fa8f 100644 --- a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationIT.java +++ b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationIT.java @@ -26,6 +26,8 @@ import static com.vaadin.tests.validation.AbstractValidationPage.DETACH_FIELD_BUTTON; import static com.vaadin.tests.validation.AbstractValidationPage.SERVER_VALIDITY_STATE; import static com.vaadin.tests.validation.AbstractValidationPage.SERVER_VALIDITY_STATE_BUTTON; +import static com.vaadin.tests.validation.AbstractValidationPage.SERVER_VALIDATION_COUNTER; +import static com.vaadin.tests.validation.AbstractValidationPage.SERVER_VALIDATION_COUNTER_RESET_BUTTON; public abstract class AbstractValidationIT extends AbstractComponentIT { @@ -39,6 +41,17 @@ public void init() { protected abstract T getTestField(); + protected void assertValidationCount(int expected) { + int actual = Integer + .parseInt($("div").id(SERVER_VALIDATION_COUNTER).getText()); + Assert.assertEquals("The field should have validated " + expected + + " times on the server-side", expected, actual); + } + + protected void resetValidationCount() { + $("button").id(SERVER_VALIDATION_COUNTER_RESET_BUTTON).click(); + } + protected void assertErrorMessage(String expected) { Assert.assertEquals(expected, testField.getPropertyString("errorMessage")); diff --git a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationPage.java b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationPage.java index 3ddab408fa4..3c1e6014fe3 100644 --- a/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationPage.java +++ b/vaadin-flow-components-shared-parent/vaadin-flow-components-test-util/src/main/java/com/vaadin/tests/validation/AbstractValidationPage.java @@ -30,9 +30,14 @@ public abstract class AbstractValidationPage serverValidationCounter.setText("0")); + + add(new Div(serverValidationCounter, + serverValidationCounterResetButton)); + } + + protected void incrementServerValidationCounter() { + int count = Integer.parseInt(serverValidationCounter.getText()); + serverValidationCounter.setText(String.valueOf(count + 1)); + } + private void addAttachDetachControls() { NativeButton attachButton = createButton(ATTACH_FIELD_BUTTON, "Attach field", event -> add(testField));