Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
32 changes: 32 additions & 0 deletions src/org/labkey/test/components/ChartLayoutDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,35 @@ public ChartLayoutDialog setYAxisRangeMinMax(String min, String max)
return this;
}

public ChartLayoutDialog setYAxisAggregateMethod(String method)
{
clickYAxisTab();
getWrapper()._ext4Helper.selectComboBoxItem("Aggregate Method:", method);
return this;
}

public boolean isYAxisAggregateMethodVisible()
{
return getWrapper().isElementPresent(Ext4Helper.Locators.formItemWithLabel("Aggregate Method:"));
}

public ChartLayoutDialog setYAxisErrorBarsMethod(String method)
{
clickYAxisTab();
if (method.equals("Standard Deviation"))
getWrapper().click(elementCache().sdErrorBarRadioButton);
else if (method.equals("Standard Error of the Mean"))
getWrapper().click(elementCache().semErrorBarRadioButton);
else
getWrapper().click(elementCache().noneErrorBarRadioButton);
return this;
}

public boolean isYAxisErrorBarsMethodVisible()
{
return getWrapper().isElementPresent(Ext4Helper.Locators.formItemWithLabel("Error Bars:"));
}

protected void setLabel(String label)
{
getWrapper().setFormElement(elementCache().visibleLabelTextBox, label);
Expand Down Expand Up @@ -461,6 +490,9 @@ class ElementCache extends ChartWizardDialog.ElementCache
public Locator visibleLabelTextBox = Locator.xpath(VISIBLE_PANEL_XPATH + "//input[@name='label']");
public Locator visibleRangeMinTextBox = Locator.xpath(VISIBLE_PANEL_XPATH + "//input[@name='rangeMin']");
public Locator visibleRangeMaxTextBox = Locator.xpath(VISIBLE_PANEL_XPATH + "//input[@name='rangeMax']");
public Locator noneErrorBarRadioButton = Locator.xpath(VISIBLE_PANEL_XPATH + "//label[text()='None']/preceding-sibling::input[@type='button']");
public Locator sdErrorBarRadioButton = Locator.xpath(VISIBLE_PANEL_XPATH + "//label[text()='Standard Deviation']/preceding-sibling::input[@type='button']");
public Locator semErrorBarRadioButton = Locator.xpath(VISIBLE_PANEL_XPATH + "//label[text()='Standard Error of the Mean']/preceding-sibling::input[@type='button']");
}

public enum ScaleType
Expand Down
90 changes: 67 additions & 23 deletions src/org/labkey/test/components/react/QueryChartDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ public boolean hasAxisFieldOptions(String label)
return elementCache().fieldOptionIconByLabel(label) != null;
}

private QueryChartDialog clickAxisFieldOptions(String label)
private void clickFieldOptions(String label)
{
elementCache().fieldOptionIconByLabel(label).click();
return this;
}

/**
Expand All @@ -112,23 +111,23 @@ private QueryChartDialog clickAxisFieldOptions(String label)
*/
public QueryChartDialog setAxisScaleType(String label, String value)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
if ("linear".equalsIgnoreCase(value))
elementCache().scaleLinearRadio.check();
else if ("log".equalsIgnoreCase(value))
elementCache().scaleLogRadio.check();
else
throw new IllegalArgumentException("Invalid scale value: " + value);
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return this;
}

public boolean isAxisScaleTypeSelected(String label, String value)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
boolean selected = "linear".equalsIgnoreCase(value) ? elementCache().scaleLinearRadio.isChecked() :
"log".equalsIgnoreCase(value) && elementCache().scaleLogRadio.isChecked();
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return selected;
}

Expand All @@ -140,51 +139,51 @@ public boolean isAxisScaleTypeSelected(String label, String value)
*/
public QueryChartDialog setAxisRangeType(String label, String value)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
if ("automatic".equalsIgnoreCase(value))
elementCache().scaleAutomaticRadio.check();
else if ("manual".equalsIgnoreCase(value))
elementCache().scaleManualRadio.check();
else
throw new IllegalArgumentException("Invalid range value: " + value);
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return this;
}

public boolean isAxisRangeTypeSelected(String label, String value)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
boolean selected = "automatic".equalsIgnoreCase(value) ? elementCache().scaleAutomaticRadio.isChecked() :
"manual".equalsIgnoreCase(value) && elementCache().scaleManualRadio.isChecked();
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return selected;
}

public QueryChartDialog setAxisRange(String label, String min, String max)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
if (elementCache().scaleManualRadio.isChecked())
{
elementCache().scaleRangeMinInput.set(min);
elementCache().scaleRangeMaxInput.set(max);
}
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return this;
}

public String getAxisRangeMin(String label)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
String min = elementCache().scaleRangeMinInput.get();
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return min;
}

public String getAxisRangeMax(String label)
{
clickAxisFieldOptions(label); // open the popover
clickFieldOptions(label); // open the popover
String max = elementCache().scaleRangeMaxInput.get();
clickAxisFieldOptions(label); // close the popover
clickFieldOptions(label); // close the popover
return max;
}

Expand All @@ -207,18 +206,57 @@ public List<String> getYAxisSelectionOptions()
return elementCache().reactSelectByLabel("Y Axis").getOptions();
}

/*
Y Axis Aggregate Method is an option for bar chart
*/
public QueryChartDialog selectYAxisAggregateMethod(String option)
{
elementCache().reactSelectByLabel("Y Axis Aggregate Method").select(option);
clickFieldOptions("Y Axis"); // open the popover
getAggregateMethodSelect().select(option);
Locator.tagWithText("label", "Name *").findElement(this).click(); // close the popover
return this;
}

public List<String> getYAxisAggregateMethodOptions()
{
clickFieldOptions("Y Axis"); // open the popover
List<String> options = getAggregateMethodSelect().getOptions();
Locator.tagWithText("label", "Name *").findElement(this).click(); // close the popover
return options;
}

public String getYAxisAggregateMethod()
{
return elementCache().reactSelectByLabel("Y Axis Aggregate Method").getValue();
clickFieldOptions("Y Axis"); // open the popover
String value = getAggregateMethodSelect().getValue();
Locator.tagWithText("label", "Name *").findElement(this).click(); // close the popover
return value;
}

private ReactSelect getAggregateMethodSelect()
{
// can't use elementCache() because the popover is outside the dialog
Locator loc = Locator.tag("div").withChild(Locator.tagContainingText("label", "Aggregate Method"));
return ReactSelect.finder(getDriver()).find(loc.waitForElement(getDriver(), 1500));
}

private RadioButton getErrorBarsRadio(String value)
{
// can't use elementCache() because the popover is outside the dialog
return RadioButton.RadioButton(Locator.radioButtonByNameAndValue("error-bar-method", value)).find(getDriver());
}

public QueryChartDialog selectYAxisErrorBar(String value)
{
clickFieldOptions("Y Axis"); // open the popover
getErrorBarsRadio(value).check();
Locator.tagWithText("label", "Name *").findElement(this).click(); // close the popover
return this;
}

public boolean isYAxisErrorBarOptionEnabled(String value)
{
clickFieldOptions("Y Axis"); // open the popover
boolean enabled = getErrorBarsRadio(value).isEnabled();
Locator.tagWithText("label", "Name *").findElement(this).click(); // close the popover
return enabled;
}

/*
Expand Down Expand Up @@ -404,10 +442,16 @@ public QueryChartPanel clickCreateChart()
*/
public QueryChartPanel clickSaveChart()
{
return clickSaveChart(getName());
}
public QueryChartPanel clickSaveChart(String previousChartName)
{
String name = getName();
WebElement prevChart = _queryGrid.getChartPanel(previousChartName).getSvgChart();
WebDriverWrapper.waitFor(this::isSaveChartButtonEnabled,
"the Save chart button did not become enabled", 2000);
String name = getName();
dismiss("Save Chart");
getWrapper().shortWait().until(ExpectedConditions.stalenessOf(prevChart));
return _queryGrid.getChartPanel(name);
}

Expand Down Expand Up @@ -489,7 +533,7 @@ public String grayTextPreviewInstruction()
}

private final Locator previewBodyLoc = Locator.tagWithClass("div", "chart-builder-preview-body");
private final Locator svgLoc = Locator.tagWithClass("div", "svg-chart__chart");
private final Locator svgLoc = Locator.tagWithClass("div", "svg-chart__chart").childTag("svg");

public WebElement svg()
{
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/components/react/QueryChartPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getTitle()

public WebElement getSvgChart()
{
return Locator.byClass("svg-chart").waitForElement(this, WAIT_FOR_JAVASCRIPT);
return Locator.byClass("svg-chart__chart").childTag("svg").waitForElement(this, WAIT_FOR_JAVASCRIPT);
}

public QueryGrid clickClose()
Expand Down
29 changes: 27 additions & 2 deletions src/org/labkey/test/tests/visualization/BarPlotTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ public class BarPlotTest extends GenericChartsTest
private final String ALT_GROUPED_BAR_PLOT_SVG_TEXT = "0\nNormal\nNot Done\n0\n2\n4\n6\n8\n10\n12\n14\n16\n18\n20\n22\nAPX-1: Abbreviated Physical Exam\nNew Label\n0\nNegative";
private final String SECOND_BAR_PLOT_SVG_TEXT = "0\nNegative\n0\n200\n400\n600\n800\n1000\n1200\n1400\n1600\n1800\n2000\n2200\n2400\n" + TRICKY_CHART_TITLE + "\n" + PREG_TEST_RESULTS + "\nSum of " + BP_DIASTOLIC;
private final String THIRD_BAR_PLOT_SVG_TEXT = "0\nNegative\n-50\n-49\n-48\n-47\n-46\n-45\n-44\n-43\n-42\n-41\n-40\n"+ TRICKY_CHART_TITLE + "\n" + PREG_TEST_RESULTS + "\nSum of " + BP_DIASTOLIC;
private final String FOURTH_BAR_PLOT_SVG_TEXT = "0\nNegative\n200\n400\n600\n800\n1000\n1200\n1400\n1600\n1800\n2000\n2200\n2400\n2600\n2800\n3000\n"+ TRICKY_CHART_TITLE + "\n" + PREG_TEST_RESULTS + "\nSum of " + BP_DIASTOLIC;
private final String FOURTH_BAR_PLOT_SVG_TEXT = "0\nNegative\n0\n500\n1000\n1500\n2000\n2500\n3000\n"+ TRICKY_CHART_TITLE + "\n" + PREG_TEST_RESULTS + "\nSum of " + BP_DIASTOLIC;
private final String SUM_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n2e+7\n4e+7\n6e+7\n8e+7\n1e+8\n1.2e+8\n1.4e+8\n1.6e+8\n1.8e+8\n2e+8\n2.2e+8\n2.4e+8\nTypes\nStudy: Cohort\nSum of Double";
private final String COUNT_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n2\n4\n6\n8\n10\n12\n14\n16\n18\n20\nTypes\nStudy: Cohort\nCount (non-blank) of Double";
private final String MIN_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n-1\n-0.9\n-0.8\n-0.7\n-0.6\n-0.5\n-0.4\n-0.3\n-0.2\n-0.1\n0\nTypes\nStudy: Cohort\nMin of Double";
private final String MAX_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n1e+7\n2e+7\n3e+7\n4e+7\n5e+7\n6e+7\n7e+7\n8e+7\n9e+7\n1e+8\n1.1e+8\n1.2e+8\nTypes\nStudy: Cohort\nMax of Double";
private final String MEAN_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n2e+6\n4e+6\n6e+6\n8e+6\n1e+7\n1.2e+7\n1.4e+7\n1.6e+7\n1.8e+7\n2e+7\nTypes\nStudy: Cohort\nMean of Double";
private final String MEAN_SD_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n1e+7\n2e+7\n3e+7\n4e+7\n5e+7\n6e+7\nTypes\nStudy: Cohort\nMean of Double";
private final String MEAN_SEM_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n5e+6\n1e+7\n1.5e+7\n2e+7\n2.5e+7\n3e+7\nTypes\nStudy: Cohort\nMean of Double";
private final String MEAN_NONE_GROUPED_BAR_PLOT_SVG_TEXT = "Enroll/Vacc#1\nScreening\n0\n2e+6\n4e+6\n6e+6\n8e+6\n1e+7\n1.2e+7\n1.4e+7\n1.6e+7\n1.8e+7\n2e+7\n2.2e+7\n2.4e+7\nTypes\nVisit\nMean of Double\nGroup 1\nGroup 2";
private final String MEAN_SD_GROUPED_BAR_PLOT_SVG_TEXT = "Enroll/Vacc#1\nScreening\n0\n1e+7\n2e+7\n3e+7\n4e+7\n5e+7\n6e+7\n7e+7\nTypes\nVisit\nMean of Double\nGroup 1\nGroup 2";
private final String MEAN_SEM_GROUPED_BAR_PLOT_SVG_TEXT = "Enroll/Vacc#1\nScreening\n0\n5e+6\n1e+7\n1.5e+7\n2e+7\n2.5e+7\n3e+7\n3.5e+7\n4e+7\n4.5e+7\nTypes\nVisit\nMean of Double\nGroup 1\nGroup 2";
private final String MEDIAN_BAR_PLOT_SVG_TEXT = "Group 1\nGroup 2\n0\n0.05\n0.1\n0.15\n0.2\n0.25\n0.3\n0.35\n0.4\n0.45\n0.5\n0.55\n0.6\nTypes\nStudy: Cohort\nMedian of Double";

@Override
Expand Down Expand Up @@ -462,14 +467,34 @@ private void doYAxisAggregateMethodTest()
setBarAggregateMethodAndVerify("Mean", MEAN_BAR_PLOT_SVG_TEXT);
setBarAggregateMethodAndVerify("Median", MEDIAN_BAR_PLOT_SVG_TEXT);

log("Change and verify error bar types for Mean aggregate method");
setBarAggregateMethodAndVerify("Mean", null);
setBarErrorBarMethodAndVerify("Standard Deviation", MEAN_SD_BAR_PLOT_SVG_TEXT);
setBarErrorBarMethodAndVerify("Standard Error of the Mean", MEAN_SEM_BAR_PLOT_SVG_TEXT);

log("Add a Group By variable and verify aggregate and error bar case.");
chartWizard.clickChartTypeButton().setXSubCategory("Visit").clickApply();
setBarErrorBarMethodAndVerify("None", MEAN_NONE_GROUPED_BAR_PLOT_SVG_TEXT);
setBarErrorBarMethodAndVerify("Standard Deviation", MEAN_SD_GROUPED_BAR_PLOT_SVG_TEXT);
setBarErrorBarMethodAndVerify("Standard Error of the Mean", MEAN_SEM_GROUPED_BAR_PLOT_SVG_TEXT);

savePlot(BAR_PLOT_SAVE_NAME_4, null);
}

private void setBarErrorBarMethodAndVerify(String method, String svgTxt)
{
LookAndFeelBarPlot lookAndFeelDialog = clickChartLayoutButton();
lookAndFeelDialog.setYAxisErrorBarsMethod(method);
lookAndFeelDialog.clickApply();
assertSVG(svgTxt);
}

private void setBarAggregateMethodAndVerify(String method, String svgTxt)
{
clickButton("Chart Type", 0);
ChartTypeDialog chartTypeDialog = new ChartTypeDialog(getDriver());
chartTypeDialog.setYAxisAggregateMethod(method).clickApply();
assertSVG(svgTxt);
if (svgTxt != null)
assertSVG(svgTxt);
}
}
Loading