diff --git a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java index 23e7807..29471b5 100644 --- a/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java +++ b/nbri_ehr/test/src/org.labkey.test/tests.nbri_ehr/NBRI_EHRTest.java @@ -144,9 +144,6 @@ public class NBRI_EHRTest extends AbstractGenericEHRTest implements PostgresOnly // cannot change what the snapshot reports. private static final String[] LOCATION_ANIMALS = {"LOC0001"}; - // Longest buffer DataEntryErrorPanel puts between a validation event and repainting the error summary - private static final int ERROR_PANEL_REPAINT_BUFFER = 1500; - // protocol.investigatorId looks up ehr.investigators rather than the user table, so a protocol shows an // investigator only when a row there carries its id. private static final String INVES_LAST_NAME = "Marsh"; @@ -2623,58 +2620,6 @@ private void waitForFormError(String message) waitFor(() -> isTextPresent(message), "Form did not report: " + message, WAIT_FOR_JAVASCRIPT); } - /** - * Waits for a validation message to clear, re-running server-side validation once if it does not. A value can be - * accepted at the field while the form's error summary still lists it, which the form itself handles by pointing - * the user at More Actions -> Re-Validate. - */ - private void waitForValidationToClear(String message) - { - if (waitForValidationToSettleWithout(message)) - return; - - log("Form kept reporting '" + message + "', re-validating"); - revalidateForm(); - if (!waitForValidationToSettleWithout(message)) - Assert.fail("Form kept reporting after re-validating: " + message); - } - - /** - * Waits for the form to go quiet without reporting the given message. DataEntryErrorPanel repaints on a buffered - * event rather than when the validation response lands, so the summary trails the form's actual state by up to a - * second: a message can read as absent before validation has reported it, and read as present after the value - * that raised it was accepted. Neither is worth acting on, so require no validation in flight and the message - * absent, then re-check after the repaint window to confirm the absence survives it. - */ - private boolean waitForValidationToSettleWithout(String message) - { - return waitFor(() -> { - if (getValidationRequestsInFlight() > 0 || isTextPresent(message)) - return false; - - sleep(ERROR_PANEL_REPAINT_BUFFER); - return getValidationRequestsInFlight() == 0 && !isTextPresent(message); - }, WAIT_FOR_JAVASCRIPT); - } - - // Server validations the form is still waiting on. StoreCollection counts these itself; the form has no - // rendered "validating" state to watch instead. - private int getValidationRequestsInFlight() - { - Object inFlight = executeScript("var panel = Ext4.ComponentQuery.query('ehr-dataentrypanel')[0];" + - "return panel && panel.storeCollection ? panel.storeCollection.validationRequestsInFlight : 0;"); - - return inFlight == null ? 0 : ((Number) inFlight).intValue(); - } - - // More Actions -> Re-Validate: re-runs server-side validation on every record in the form - private void revalidateForm() - { - WebElement moreActions = _helper.getDataEntryButton("More Actions").findElement(getDriver()); - scrollIntoView(moreActions); - _ext4Helper.clickExt4MenuButton(false, moreActions, false, "Re-Validate"); - } - /** * Reads a date field for one animal through the API rather than off a grid, so assertions compare stored values * instead of formatted display text, and normalizes to the day: event dates are entered with the time stripped, @@ -2767,9 +2712,7 @@ private void submitForm(String buttonText, String windowTitle) private void submitForm(String buttonText, String windowTitle, boolean expectNavigation) { - //Give time for errors to disappear after validation - Locator.tagContainingText("div", "The form has the following errors and warnings:") - .waitForElementToDisappear(longWait()); + waitForFormValidationToClear(); Locator submitFinalBtn = Locator.linkWithText(buttonText); shortWait().until(ExpectedConditions.elementToBeClickable(submitFinalBtn)); Window msgWindow;