Skip to content

Item 10437: Aliquot Field Inheritance - automated tests #1151

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

Merged
merged 5 commits into from
Jul 7, 2022
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
45 changes: 45 additions & 0 deletions src/org/labkey/test/components/domain/DomainFieldRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;
import org.labkey.api.exp.query.ExpSchema;
import org.labkey.test.BootstrapLocators;
import org.labkey.test.Locator;
import org.labkey.test.WebDriverWrapper;
Expand Down Expand Up @@ -1040,6 +1041,41 @@ public DomainFieldRow setSampleType(String sampleTypeName)
return this;
}

public DomainFieldRow setAliquotOption(ExpSchema.DerivationDataScopeType option)
{
expand();
elementCache().aliquotOption(option).check();
return this;
}

public RadioButton getAliquotOptionRadioButton(ExpSchema.DerivationDataScopeType option)
{
expand();
return elementCache().aliquotOption(option);
}

public ExpSchema.DerivationDataScopeType getSelectedAliquotOption()
{
expand();
for (ExpSchema.DerivationDataScopeType option : ExpSchema.DerivationDataScopeType.values())
{
if (elementCache().aliquotOption(option).isChecked())
return option;
}
return null;
}

public boolean hasAliquotOptionWarning()
{
expand();
return getWrapper().isElementPresent(elementCache().aliquotWarningAlert);
}

public String getAliquotOptionWarning()
{
return elementCache().aliquotWarningAlert.findElement(this).getText();
}

public static class DomainFieldRowFinder extends WebDriverComponentFinder<DomainFieldRow, DomainFieldRowFinder>
{
private final Locator.XPathLocator _baseLocator = Locator.tagWithClassContaining("div", "domain-field-row").withoutClass("domain-floating-hdr");
Expand Down Expand Up @@ -1141,6 +1177,8 @@ protected class ElementCache extends WebDriverComponent.ElementCache
Locator.XPathLocator selectConceptBtnLoc = Locator.tagWithAttribute("button", "name", "domainpropertiesrow-principalConceptCode")
.withText("Select Concept");

Locator.XPathLocator aliquotWarningAlert = Locator.tagWithClassContaining("div", "aliquot-alert-warning");

public Locator.XPathLocator getCharScaleInputLocForRow(int rowIndex)
{
return Locator.tagWithId("input", "domainpropertiesrow-scale-0-" + rowIndex);
Expand Down Expand Up @@ -1268,5 +1306,12 @@ public WebElement conditionalFormatButton()
return Locator.waitForAnyElement(new FluentWait<SearchContext>(this).withTimeout(Duration.ofMillis(WAIT_FOR_JAVASCRIPT)),
Locator.button("Add Format"), Locator.button("Edit Formats"));
}

public RadioButton aliquotOption(ExpSchema.DerivationDataScopeType option)
{
return new RadioButton.RadioButtonFinder().withValue(option.name()).find(this);
}


}
}
3 changes: 2 additions & 1 deletion src/org/labkey/test/components/domain/DomainFormPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ else if (fieldDefinition.getType() != null)
fieldRow.setRequiredField(fieldDefinition.getRequired());
if (fieldDefinition.getLookupValidatorEnabled() != null)
fieldRow.setLookupValidatorEnabled(fieldDefinition.getLookupValidatorEnabled());

if (fieldDefinition.getAliquotOption() != null)
fieldRow.setAliquotOption(fieldDefinition.getAliquotOption());
// ontology-specific
if (fieldDefinition.getSourceOntology() != null)
fieldRow.setSelectedOntology(fieldDefinition.getSourceOntology());
Expand Down
5 changes: 5 additions & 0 deletions src/org/labkey/test/components/html/RadioButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public SimpleComponentFinder<RadioButton> withName(String name)
return super.locatedBy(Locator.radioButtonByName(name));
}

public SimpleComponentFinder<RadioButton> withValue(String value)
{
return super.locatedBy(Locator.radioButton().withAttribute("value", value));
}

public SimpleComponentFinder<RadioButton> withNameAndValue(String name, String value)
{
return super.locatedBy(Locator.radioButtonByNameAndValue(name, value));
Expand Down
3 changes: 2 additions & 1 deletion src/org/labkey/test/components/ui/grids/GridRow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.labkey.test.components.ui.grids;

import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.test.Locator;
import org.labkey.test.WebDriverWrapper;
import org.labkey.test.components.Component;
Expand Down Expand Up @@ -163,7 +164,7 @@ public Map<String, String> getRowMap()
{
if (_rowMap == null)
{
_rowMap = new HashMap<>();
_rowMap = new CaseInsensitiveHashMap<>();
List<String> columns = _grid.getColumnNames();
List<String> rowCellTexts = getTexts();
for (int i = 0; i < columns.size(); i++)
Expand Down
13 changes: 13 additions & 0 deletions src/org/labkey/test/params/FieldDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.junit.Assert;
import org.labkey.api.exp.query.ExpSchema;
import org.labkey.remoteapi.domain.PropertyDescriptor;
import org.labkey.remoteapi.query.Filter;
import org.labkey.test.components.html.OptionSelect;
Expand All @@ -41,6 +42,7 @@ public class FieldDefinition extends PropertyDescriptor
private LookupInfo _lookup;
private String _principalConceptSearchSourceOntology;
private String _principalConceptSearchExpression;
private ExpSchema.DerivationDataScopeType _aliquotOption;

// Stash validator collection to avoid having to convert back from JSON Maps
private List<FieldValidator<?>> _validators;
Expand Down Expand Up @@ -399,6 +401,17 @@ public FieldDefinition setTextChoiceValues(List<String> values)
return this;
}

public ExpSchema.DerivationDataScopeType getAliquotOption()
{
return _aliquotOption;
}

public void setAliquotOption(ExpSchema.DerivationDataScopeType aliquotOption)
{
super.setDerivationDataScope(aliquotOption.name());
_aliquotOption = aliquotOption;
}

public enum RangeType
{
Equals("Equals", Filter.Operator.EQUAL),
Expand Down