Skip to content
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
83 changes: 83 additions & 0 deletions src/org/labkey/test/components/domain/ConditionalFormatPanel.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.labkey.test.components.domain;

import org.labkey.remoteapi.domain.ConditionalFormat;
import org.labkey.remoteapi.query.Filter;
import org.labkey.test.Locator;
import org.labkey.test.components.WebDriverComponent;
Expand All @@ -24,51 +25,112 @@ public ConditionalFormatPanel(WebElement element, ConditionalFormatDialog dialog
_dialog = dialog;
}

public ConditionalFormatPanel setConditionalFormat(ConditionalFormat conditionalFormat)
{
for (int i = 0; i < conditionalFormat.getQueryFilter().size(); i++)
{
var filterCondition = conditionalFormat.getQueryFilter().get(i);
if (i==0)
{
setFirstCondition(filterCondition.getOperator());
if (filterCondition.getValue() != null)
setFirstValue(filterCondition.getValue().toString());
}
if (i==1)
{
setSecondCondition(filterCondition.getOperator());
if (filterCondition.getValue() != null)
setSecondValue(filterCondition.getValue().toString());
}
Comment on lines +33 to +44
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this really just an if / else condition? Isn't the limit is two conditions at most? If i != 0 then you have to be setting the second one.

}
setBoldCheckbox(conditionalFormat.getBold());
setItalicsCheckbox(conditionalFormat.getItalic());
setStrikethroughCheckbox(conditionalFormat.getStrikethrough());
setTextColor(conditionalFormat.getTextColor());
setFillColor(conditionalFormat.getBackgroundColor());
return this;
}

public ConditionalFormatPanel setFirstCondition(Filter.Operator operator)
{
expand();
elementCache().firstConditionSelect().selectByValue(operator.getUrlKey());
return this;
}
public String getFirstCondition()
{
return elementCache().firstConditionSelect().getFirstSelectedOption().getText();
}

public ConditionalFormatPanel setFirstValue(String value)
{
expand();
elementCache().firstFilterValueInput().setValue(value);
return this;
}
public String getFirstValue()
{
return elementCache().firstFilterValueInput().getValue();
}

public ConditionalFormatPanel setSecondCondition(Filter.Operator operator)
{
expand();
elementCache().secondConditionSelect().selectByValue(operator.getUrlKey());
return this;
}
public String getSecondCondition()
{
return elementCache().secondConditionSelect().getFirstSelectedOption().getText();
}

public ConditionalFormatPanel setSecondValue(String value)
{
expand();
elementCache().secondFilterValueInput().setValue(value);
return this;
}
public String getSecondValue()
{
return elementCache().secondFilterValueInput().getValue();
}

public ConditionalFormatPanel setBoldCheckbox(boolean checked)
{
expand();
elementCache().boldCheckbox().set(checked);
return this;
}

public boolean getBoldChecked()
{
return elementCache().boldCheckbox().get();
}

public ConditionalFormatPanel setItalicsCheckbox(boolean checked)
{
expand();
elementCache().italicsCheckbox().set(checked);
return this;
}

public boolean getItalicsChecked()
{
return elementCache().italicsCheckbox().get();
}

public ConditionalFormatPanel setStrikethroughCheckbox(boolean checked)
{
expand();
elementCache().strikethroughCheckbox().set(checked);
return this;
}

public boolean getStrikethroughChecked()
{
return elementCache().strikethroughCheckbox().get();
}

public ConditionalFormatPanel setTextColor(String colorHex)
{
expand();
Expand All @@ -78,6 +140,12 @@ public ConditionalFormatPanel setTextColor(String colorHex)
return this;
}

public String getTextStyle()
{
expand();
return elementCache().textColorPreview.getAttribute("style");
}

public ConditionalFormatPanel setFillColor(String colorHex)
{
expand();
Expand All @@ -87,6 +155,18 @@ public ConditionalFormatPanel setFillColor(String colorHex)
return this;
}

public String getFillStyle()
{
expand();
return elementCache().fillColorPreview.getAttribute("style");
}

public String getPreviewTextStyle()
{
expand();
return elementCache().previewTextInput.getAttribute("style");
}

public ConditionalFormatDialog clickRemove()
{
expand();
Expand Down Expand Up @@ -171,7 +251,10 @@ public Checkbox strikethroughCheckbox()

final Locator collapseIconLocator = Locator.tagWithClass("div", "domain-validator-collapse-icon");
final WebElement textColor = Locator.tagWithName("button", "domainpropertiesrow-textColor").findWhenNeeded(this);
final WebElement textColorPreview = Locator.tagWithClass("div", "domain-color-preview").index(0).findWhenNeeded(this);
final WebElement fillColor = Locator.tagWithName("button", "domainpropertiesrow-backgroundColor").findWhenNeeded(this);
final WebElement fillColorPreview = Locator.tagWithClass("div", "domain-color-preview").index(1).findWhenNeeded(this);
final WebElement previewTextInput = Locator.tagWithAttribute("input", "value", "Preview Text").findWhenNeeded(this);
final WebElement removeButton = Locator.button("Remove Formatting").findWhenNeeded(this);
}

Expand Down
11 changes: 10 additions & 1 deletion src/org/labkey/test/components/ui/grids/DetailTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,21 @@ else if (elementCache().siblingField(identifier).isDisplayed())
{
return elementCache().siblingField(identifier);
}
else if (elementCache().dataFieldByKey(identifier).isDisplayed())
{
return elementCache().dataFieldByKey(identifier);
}
else
{
throw new NoSuchElementException(String.format("Could not find field '%s'.", identifier));
}
}

public boolean fieldHasFormatPill(String identifier)
{
return Locator.tagWithClass("*", "status-pill").existsIn(getField(identifier));
}

/**
* Return the value of a cell identified by the text in the left most column.
*
Expand Down Expand Up @@ -234,7 +243,7 @@ public final WebElement dataByLabel(String fieldLabel)

public final WebElement dataFieldByKey(String fieldKey)
{
return Locator.tagWithAttribute("td", "data-fieldkey", fieldKey).findElement(this);
return Locator.tagWithAttribute("td", "data-fieldkey", fieldKey).findWhenNeeded(this);
}

// Some tables will show a value in a td with no attributes, use the td that has the text (label) to find the value.
Expand Down
15 changes: 15 additions & 0 deletions src/org/labkey/test/components/ui/grids/GridRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public boolean hasSelectColumn()
return _grid.hasSelectColumn();
}

public boolean hasConditionalFormatPill(CharSequence columnIdentifier)
{
return Locator.tagWithClass("*", "status-pill").existsIn(getCell(columnIdentifier));
}

/**
* Returns the selected state of the row selector checkbox, if one is present
* @return true if the select checkbox is checked.
Expand Down Expand Up @@ -90,6 +95,16 @@ public WebElement getCell(CharSequence columnIdentifier)
return getCell(_grid.getColumnIndex(columnIdentifier));
}

/**
* gets the style attribute of the value-wrapper for the specified cell
* @return
*/
public String getCellStyle(CharSequence columnIdentifier)
{
var cell = getCell(columnIdentifier);
return Locator.tagWithClass("span", "ws-pre-wrap").findElement(cell).getAttribute("style");
}

/**
* Returns true if the row contains all of the specified column/value pairs
* @param partialMap Map of key (column) value (text)
Expand Down