Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for Issue 39496 #2089

Merged
merged 5 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public FileUploadField fileField(String caption)
public FilteringReactSelect findSelect(String fieldCaption)
{
WebElement container = Locator.tag("td").withAttribute("data-caption", fieldCaption).findElement(this);
return FilteringReactSelect.finder(_driver).find(container);
return FilteringReactSelect.finder(_driver).timeout(_readyTimeout).waitFor(container);
}
}

Expand Down
58 changes: 58 additions & 0 deletions src/org/labkey/test/tests/assay/AssayMissingValuesTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package org.labkey.test.tests.assay;

import org.intellij.lang.annotations.Language;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.categories.Daily;
import org.labkey.test.pages.admin.ExportFolderPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.params.assay.GeneralAssayDesign;
import org.labkey.test.tests.MissingValueIndicatorsTest;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.LogMethod;
Expand Down Expand Up @@ -217,6 +221,60 @@ public void testAssayMV()
testMvFiltering(List.of("age", "sex"));
}

/**
* provides regression coverage for Issue 39496
* @throws Exception there was an exception creating the assay for this test
*/
@Test
public void testSaveBatchAPIMissingValues() throws Exception
{
// create the assay
String assayName = "missingValueSaveBatchAPIAssay";
List<PropertyDescriptor> dataFields = List.of(
new FieldDefinition("ParticipantId", FieldDefinition.ColumnType.String),
new FieldDefinition("VisitId", FieldDefinition.ColumnType.Integer),
new FieldDefinition("Count", FieldDefinition.ColumnType.Integer).setMvEnabled(true));

var serverProtocol = new GeneralAssayDesign(assayName)
.setBatchFields(List.of(new FieldDefinition("batchData", FieldDefinition.ColumnType.String)), false)
.setDataFields(dataFields, false)
.createAssay(getProjectName(), createDefaultConnection());

@Language("JavaScript") String saveBatch = """
LABKEY.Experiment.saveBatch({
assayId: %protocolId%,
batch: {
runs: [{
name: 'js api',
dataRows : [
{participantId : 'p1', visitId : 1, count : 4.0},
{participantId : 'p2', visitId : 1, count : 'N'},
{participantId : 'p3', visitId : 1, count : 5, countMVIndicator : 'Q'}
]
}]
}
});
""".replace("%protocolId%", serverProtocol.getProtocolId().toString());
executeScript(saveBatch);

// navigate to the results view
goToProjectHome();
clickAndWait(Locator.linkWithText(assayName));
clickAndWait(Locator.linkWithText("view results"));
var dataRegion = DataRegionTable.DataRegion(getDriver()).waitFor();

// expect 3 rows in this assay, p2 and p3 should get mv indicators in the count column
Map<String, List<String>> expectedData = new HashMap<>();
expectedData.put("Participant ID", List.of("p1", "p2", "p3"));
expectedData.put("Visit ID", List.of("1", "1", "1"));
expectedData.put("Count", List.of("4", "N", "Q"));
checkDataregionData(dataRegion, expectedData);

Map<String, List<Integer>> expectedMVIndicators = new HashMap<>();
expectedMVIndicators.put("Count", List.of(1, 2));
checkMvIndicatorPresent(dataRegion, expectedMVIndicators);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good and matches the approach we discussed!
looks like the other test cases in this file also have a call to checkDataregionData() that goes with the checkMvIndicatorPresent() call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a check for dataRegion data to the test, thanks for the suggestion

}

@Override
public List<String> getAssociatedModules()
{
Expand Down