Skip to content

Commit

Permalink
Fix test race conditions in WebDav and Viability tests (#1560)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad authored Jul 5, 2023
1 parent 747da78 commit 593f770
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/org/labkey/test/tests/WebDavTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ public void testWebfilesCaching()

log("Visit WebDav and WebFiles after project creation");
WebDavPage.beginAt(this, "");
_fileBrowserHelper.waitForFileGridReady();
assertTextPresent(OTHER_PROJECT);
WebFilesHtmlViewPage.beginAt(this, "");
assertTextPresent(OTHER_PROJECT);
Expand Down
41 changes: 24 additions & 17 deletions src/org/labkey/test/tests/viability/ViabilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.QCAssayScriptHelper;
import org.labkey.test.util.TextSearcher;
import org.openqa.selenium.WebElement;

import java.util.List;

Expand Down Expand Up @@ -84,13 +85,13 @@ protected void runUploadTest()
uploadViabilityRun(TestFileUtils.getSampleData("viability/small.VIA.csv"), true);

log("** Check form field values");
assertFormElementEquals(Locator.name("_pool_1604505335_0_ParticipantID"), "160450533");
assertFormElementEquals(Locator.name("_pool_1604505335_0_VisitID"), "5.0");
assertFormElementEquals(Locator.name("_pool_1604505335_0_TotalCells"), "3.700E7");
assertFormElementEquals(Locator.name("_pool_1604505335_0_ViableCells"), "3.127E7");
assertFormElementEquals(Locator.name("_pool_1604505335_0_Viability"), "84.5%");
assertEquals("160450533", getFormElement(Locator.name("_pool_1604505335_0_ParticipantID")));
assertEquals("5.0", getFormElement(Locator.name("_pool_1604505335_0_VisitID")));
assertEquals("3.700E7", getFormElement(Locator.name("_pool_1604505335_0_TotalCells")));
assertEquals("3.127E7", getFormElement(Locator.name("_pool_1604505335_0_ViableCells")));
assertEquals("84.5%", getFormElement(Locator.name("_pool_1604505335_0_Viability")));
assertNotChecked(Locator.checkboxByName("_pool_1604505335_0_Unreliable"));
assertFormElementEquals(Locator.name("_pool_1604505335_0_IntValue"), "");
assertEquals("", getFormElement(Locator.name("_pool_1604505335_0_IntValue")));

clickButton(SAVE_AND_FINISH, 0);
String alertText = cancelAlert();
Expand Down Expand Up @@ -181,12 +182,12 @@ protected void runReRunTest()
reuploadViabilityRun(TestFileUtils.getSampleData("viability/small.VIA.csv"), runName);

// Check the 'SpecimenIDs' and 'IntValue' field is copied on re-run
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1604505335_0_SpecimenIDs']").index(0), "foobar");
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1604505335_0_SpecimenIDs']").index(1), "vial1");
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1604505335_0_SpecimenIDs']").index(2), "vial2");
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1604505335_0_SpecimenIDs']").index(3), "vial3");
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1614016435_4_SpecimenIDs']").index(0), "xyzzy");
assertFormElementEquals(Locator.xpath("//input[@name='_pool_1604505335_0_IntValue']"), "300");
assertEquals("Specimen IDs for 160450533-5", List.of("foobar", "vial1", "vial2", "vial3"),
getValues("_pool_1604505335_0_SpecimenIDs"));
assertEquals("Specimen IDs for 161401643-5", List.of("xyzzy"),
getValues("_pool_1614016435_4_SpecimenIDs"));
assertEquals("IntValue for 160450533-5", List.of("300"),
getValues("_pool_1604505335_0_IntValue"));

// Check the 'Unreliable' field isn't copied on re-run
assertNotChecked(Locator.checkboxByName("_pool_1604505335_0_Unreliable"));
Expand Down Expand Up @@ -251,11 +252,11 @@ protected void runTransformTest()
uploadViabilityRun(TestFileUtils.getSampleData("viability/small.VIA.csv"), runName, false);

log("** Check form field values");
assertFormElementEquals(Locator.name("_pool_1604505335_0_ParticipantID"), "160450533");
assertFormElementEquals(Locator.name("_pool_1604505335_0_VisitID"), "5.0");
assertFormElementEquals(Locator.name("_pool_1604505335_0_TotalCells"), "3.700E7");
assertFormElementEquals(Locator.name("_pool_1604505335_0_ViableCells"), "3.127E7");
assertFormElementEquals(Locator.name("_pool_1604505335_0_Viability"), "84.5%");
assertEquals("160450533", getFormElement(Locator.name("_pool_1604505335_0_ParticipantID")));
assertEquals("5.0", getFormElement(Locator.name("_pool_1604505335_0_VisitID")));
assertEquals("3.700E7", getFormElement(Locator.name("_pool_1604505335_0_TotalCells")));
assertEquals("3.127E7", getFormElement(Locator.name("_pool_1604505335_0_ViableCells")));
assertEquals("84.5%", getFormElement(Locator.name("_pool_1604505335_0_Viability")));

log("** Insert specimen IDs");
addSpecimenIds("_pool_1604505335_0_SpecimenIDs", "vial2", "vial3", "vial1", "foobar");
Expand Down Expand Up @@ -377,4 +378,10 @@ protected void runTargetStudyTest()
// UNDONE: participant/visit resolver test
// UNDONE: link to study
}

private List<String> getValues(String inputName)
{
List<WebElement> inputs = Locator.input(inputName).waitForElements(shortWait());
return inputs.stream().map(this::getFormElement).toList();
}
}

0 comments on commit 593f770

Please sign in to comment.