Skip to content

Commit

Permalink
Adding wait before selecting the metric type while configuring them.
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-sweta committed Aug 29, 2024
1 parent f7d7a61 commit 220dbee
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.labkey.test.pages.panoramapremium;

import org.apache.xmlbeans.impl.xb.xsdschema.FieldDocument;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.labkey.test.BaseWebDriverTest;
Expand All @@ -10,58 +9,12 @@
import org.labkey.test.pages.PortalBodyPanel;
import org.labkey.test.util.Ext4Helper;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.Map;

public class ConfigureMetricsUIPage extends PortalBodyPanel
{
public enum MetricType
{
Precursor,
Run
}

public enum CustomMetricProperties
{
metricName("Name", false),
series1Schema("Series 1 Schema", true),
series2Schema("Series 2 Schema", true),
series1Query("Series 1 Query", true),
series2Query("Series 2 Query", true),
series1AxisLabel("Series 1 Axis Label", false),
series2AxisLabel("Series 2 Axis Label", false),
metricType("Metric Type", true),
enabledSchema("Enabled Schema", true),
enabledQuery("Enabled Query", true);

private final String formLabel;
private final boolean isSelect;

CustomMetricProperties(String formLabel, boolean isSelect)
{
this.formLabel = formLabel + ":";
this.isSelect = isSelect;
}
}

public enum TraceMetricProperties
{
metricName(null, false),
traceName("Use Trace", true),
yAxisLabel(null, false),
timeValue(null, false),
traceValue(null, false);

private final String formLabel;
private final boolean isSelect;

TraceMetricProperties(String formLabel, boolean isSelect)
{
this.formLabel = formLabel + ":";
this.isSelect = isSelect;
}
}

public ConfigureMetricsUIPage(BaseWebDriverTest test)
{
super(test.getDriver());
Expand All @@ -77,14 +30,22 @@ public ConfigureMetricsUIPage setLeveyJennings(String metric, @Nullable String l
return this;
}

public ConfigureMetricsUIPage disableMetric(QCPlotsWebPart.MetricType metricType)
{
waitForMetricToAppear(metricType);
selectOptionByText(Locator.name(metricType.toString()), "Disabled, completely hide the metric");
return this;
}

public ConfigureMetricsUIPage disableMetric(String metric)
{
selectOptionByText(Locator.name(metric), "Disabled, completely hide the metric");
selectOptionByText(waitForElement(Locator.name(metric)), "Disabled, completely hide the metric");
return this;
}

public ConfigureMetricsUIPage setFixedDeviationFromMean(QCPlotsWebPart.MetricType metric, @Nullable String lowerBound, @Nullable String upperBound)
{
waitForMetricToAppear(metric);
selectOptionByText(Locator.name(metric.toString()), "Fixed deviation from mean");
if (lowerBound != null)
setFormElement(Locator.name(metric + "-lower"), lowerBound);
Expand All @@ -95,6 +56,7 @@ public ConfigureMetricsUIPage setFixedDeviationFromMean(QCPlotsWebPart.MetricTyp

public ConfigureMetricsUIPage setFixedValueCutOff(QCPlotsWebPart.MetricType metric, @Nullable String lowerBound, @Nullable String upperBound)
{
waitForMetricToAppear(metric);
selectOptionByText(Locator.name(metric.toString()), "Fixed value cutoff");
if (lowerBound != null)
setFormElement(Locator.name(metric + "-lower"), lowerBound);
Expand All @@ -105,14 +67,21 @@ public ConfigureMetricsUIPage setFixedValueCutOff(QCPlotsWebPart.MetricType metr

public ConfigureMetricsUIPage setShowMetricNoOutlier(QCPlotsWebPart.MetricType metric)
{
waitForMetricToAppear(metric);
selectOptionByText(Locator.name(metric.toString()), "Show metric in plots, but don't identify outliers");
return this;
}

public void waitForMetricToAppear(QCPlotsWebPart.MetricType metric)
{
shortWait().until(ExpectedConditions.visibilityOf(Locator.name(metric.toString()).findElement(getDriver())));
}

public String getLowerBound(String metric)
{
return Locator.name(metric + "-lower").findElement(getDriver()).getText();
}

public String getUpperBound(String metric)
{
return Locator.name(metric + "-upper").findElement(getDriver()).getText();
Expand All @@ -133,7 +102,7 @@ public String clickSaveExpectingError()
Locator.buttonContainingText("Save").findElement(getDriver()).click();
Locator.XPathLocator errorMsgId = Locator.id("qcMetricsError");
waitForElement(errorMsgId);
waitFor(() -> !errorMsgId.findElement(getDriver()).getText().isEmpty() , WAIT_FOR_PAGE);
waitFor(() -> !errorMsgId.findElement(getDriver()).getText().isEmpty(), WAIT_FOR_PAGE);
return errorMsgId.findElement(getDriver()).getText();
}

Expand Down Expand Up @@ -164,7 +133,7 @@ public void editMetric(String metric, Map<CustomMetricProperties, String> metric
private void editCustomMetricValues(Window<?> metricWindow, Map<CustomMetricProperties, String> metricProperties)
{
metricProperties.forEach((prop, val) -> {
if(!prop.isSelect)
if (!prop.isSelect)
{
setFormElement(Locator.name(prop.name()), val);
}
Expand All @@ -188,7 +157,7 @@ private void editCustomMetricValues(Window<?> metricWindow, Map<CustomMetricProp
private void editTraceMetricValues(Window<?> metricWindow, Map<TraceMetricProperties, String> metricProperties)
{
metricProperties.forEach((prop, val) -> {
if(!prop.isSelect)
if (!prop.isSelect)
{
setFormElement(Locator.name(prop.name()), val);
}
Expand All @@ -201,4 +170,51 @@ private void editTraceMetricValues(Window<?> metricWindow, Map<TraceMetricProper
waitForText("QC Plots");
}

public enum MetricType
{
Precursor,
Run
}

public enum CustomMetricProperties
{
metricName("Name", false),
series1Schema("Series 1 Schema", true),
series2Schema("Series 2 Schema", true),
series1Query("Series 1 Query", true),
series2Query("Series 2 Query", true),
series1AxisLabel("Series 1 Axis Label", false),
series2AxisLabel("Series 2 Axis Label", false),
metricType("Metric Type", true),
enabledSchema("Enabled Schema", true),
enabledQuery("Enabled Query", true);

private final String formLabel;
private final boolean isSelect;

CustomMetricProperties(String formLabel, boolean isSelect)
{
this.formLabel = formLabel + ":";
this.isSelect = isSelect;
}
}

public enum TraceMetricProperties
{
metricName(null, false),
traceName("Use Trace", true),
yAxisLabel(null, false),
timeValue(null, false),
traceValue(null, false);

private final String formLabel;
private final boolean isSelect;

TraceMetricProperties(String formLabel, boolean isSelect)
{
this.formLabel = formLabel + ":";
this.isSelect = isSelect;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ protected void doCleanup(boolean afterTest) throws TestTimeoutException
@Test
public void testConfigureQCMetrics()
{
String metric = QCPlotsWebPart.MetricType.TOTAL_PEAK.toString();
QCPlotsWebPart.MetricType metric = QCPlotsWebPart.MetricType.TOTAL_PEAK;
ConfigureMetricsUIPage configureUI = goToConfigureMetricsUI();
configureUI.disableMetric(metric);
configureUI.clickSave();

PanoramaDashboard qcDashboard = new PanoramaDashboard(this);
QCPlotsWebPart qcPlotsWebPart = qcDashboard.getQcPlotsWebPart();
verifyMetricNotPresent(qcPlotsWebPart, metric);
verifyMetricNotPresent(qcPlotsWebPart, metric.toString());

//re-enabling peak area metric
goToConfigureMetricsUI();
configureUI.setLeveyJennings(metric, null, null);
configureUI.setLeveyJennings(metric.toString(), null, null);
clickAndWait(Locator.buttonContainingText("Save"));
impersonate(USER);
log("Verifying Configure QC Metrics Menu option not present for non admin");
Expand Down

0 comments on commit 220dbee

Please sign in to comment.