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

component updates for auto-hit-selection #2218

Merged
merged 4 commits into from
Jan 9, 2025
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
31 changes: 31 additions & 0 deletions src/org/labkey/test/components/domain/DomainFieldRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,25 @@ public ConditionalFormatDialog clickConditionalFormatButton()
return new ConditionalFormatDialog(this);
}

public boolean hasHitSelectionCriteriaBtn()
{
return elementCache().hitSelectionCriteriaBtnLoc.existsIn(this);
}

public HitSelectionDialog clickHitSelectionCriteriaButton()
{
expand();
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(elementCache().hitSelectionCriteriaButton()));
elementCache().hitSelectionCriteriaButton().click();
return new HitSelectionDialog(getDriver());
}

public List<String> getHitSelectionCriteria()
{
expand();
return elementCache().hitSelectionCriteria();
}

@Override
protected ElementCache newElementCache()
{
Expand Down Expand Up @@ -1768,6 +1787,18 @@ public WebElement conditionalFormatButton()
Locator.button("Add Format"), Locator.button("Edit Formats"));
}

public Locator hitSelectionCriteriaBtnLoc = Locator.button("Edit Criteria");
public WebElement hitSelectionCriteriaButton()
{
return hitSelectionCriteriaBtnLoc.waitForElement(this, WAIT_FOR_JAVASCRIPT);
}

public List<String> hitSelectionCriteria()
{
return getWrapper().getTexts(Locator.tagWithClass("li", "hit-criteria-renderer__field-value")
.findElements(this));
}

public RadioButton aliquotOption(ExpSchema.DerivationDataScopeType option)
{
return new RadioButton.RadioButtonFinder().withValue(option.name()).find(this);
Expand Down
94 changes: 94 additions & 0 deletions src/org/labkey/test/components/domain/HitSelectionDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.labkey.test.components.domain;

import org.labkey.test.Locator;
import org.labkey.test.components.Component;
import org.labkey.test.components.WebDriverComponent;
import org.labkey.test.components.bootstrap.ModalDialog;
import org.labkey.test.components.html.Input;
import org.labkey.test.components.ui.search.FilterExpressionPanel;
import org.labkey.test.pages.LabKeyPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

import static org.labkey.test.components.html.Input.Input;


public class HitSelectionDialog extends ModalDialog
{

public HitSelectionDialog(WebDriver driver)
{
super(new ModalDialogFinder(driver));
}

public List<String> getAvailableFields()
{
return getWrapper().getTexts(elementCache().findFieldOptions());
}

public FilterExpressionPanel selectField(String fieldName)
{
var fieldItem = elementCache().findFieldOption(fieldName);
fieldItem.click();
return elementCache().filterExpressionPanel();
}

public void cancel()
{
dismiss("Cancel");
}

public void clickApply()
{
if (!elementCache().submitButton.isEnabled())
{
throw new IllegalStateException("Apply button is not enabled.");
}
elementCache().submitButton.click();
Copy link
Member

Choose a reason for hiding this comment

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

Wait for dialog to close.

Suggested change
elementCache().submitButton.click();
elementCache().submitButton.click();
waitForClose();

If possible, add some synchronization that waits for the DomainFieldRow to update.

waitForClose();
}

@Override
protected ElementCache elementCache()
{
return (ElementCache) super.elementCache();
}

@Override
protected ElementCache newElementCache()
{
return new ElementCache();
}


protected class ElementCache extends ModalDialog.ElementCache
{
public final Locator listItemLoc = Locator.byClass("list-group-item");

// fields panel
WebElement fieldsPanel = Locator.tagWithClass("div", "field-modal__col")
.withChild(Locator.tagWithClass("div", "field-modal__col-title").withText("Fields"))
.child(Locator.tagWithClass("div", "field-modal__col-content")).findWhenNeeded(this).withTimeout(5000);
protected WebElement findFieldOption(String queryName)
{
return listItemLoc.withText(queryName).findElement(fieldsPanel);
}
protected List<WebElement> findFieldOptions()
{
return listItemLoc.findElements(fieldsPanel);
}

// filter panel
WebElement filterCriteriaPanel = Locator.tagWithClass("div", "field-modal__col")
.withChild(Locator.tagWithClass("div", "field-modal__col-title").withText("Filter Criteria"))
.child(Locator.tagWithClass("div", "field-modal__col-content")).findWhenNeeded(this).withTimeout(5000);
protected final FilterExpressionPanel filterExpressionPanel()
{
return new FilterExpressionPanel.FilterExpressionPanelFinder(getDriver()).findWhenNeeded(filterCriteriaPanel);
}

protected final WebElement submitButton = Locator.css(".modal-footer .btn-success").findWhenNeeded(this);
}
}
19 changes: 19 additions & 0 deletions src/org/labkey/test/pages/ReactAssayDesignerPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.labkey.test.components.DomainDesignerPage;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.components.domain.DomainPanel;
import org.labkey.test.components.domain.HitSelectionDialog;
import org.labkey.test.components.html.Checkbox;
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.OptionSelect;
Expand All @@ -33,6 +34,7 @@
import org.openqa.selenium.support.ui.Select;

import java.io.File;
import java.util.List;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -205,6 +207,19 @@ public ReactAssayDesignerPage setPlateMetadata(boolean checked)
return this;
}

public HitSelectionDialog clickEditCriteria()
{
expandPropertiesPanel();
elementCache().hitSelectionCriteriaBtn.click();
return new HitSelectionDialog(getDriver());
}

public List<String> getHitCriteria()
{
expandPropertiesPanel();
return getWrapper().getTexts(elementCache().hitSelectionCriteriaLoc.findElements(elementCache().propertiesPanel));
}

public ReactAssayDesignerPage setStatus(boolean checked)
{
expandPropertiesPanel();
Expand Down Expand Up @@ -351,5 +366,9 @@ final Optional<OptionSelect<MetadataInputFormat>> metadataInputSelect()
final Checkbox qcEnabledCheckbox = Checkbox(Locator.checkboxById("assay-design-qcEnabled")).findWhenNeeded(propertiesPanel);
final Checkbox plateTemplateCheckbox = Checkbox(Locator.checkboxById("assay-design-plateMetadata")).findWhenNeeded(propertiesPanel);
final Checkbox activeStatusCheckBox = Checkbox(Locator.checkboxById("assay-design-status")).findWhenNeeded(propertiesPanel);

final WebElement hitSelectionCriteriaBtn = Locator.tagWithClass("div", "filter-criteria-input__button")
.child(Locator.button("Edit Criteria")).findWhenNeeded(propertiesPanel);
final Locator hitSelectionCriteriaLoc = Locator.tagWithClass("li", "hit-criteria-renderer__field-value");
}
}