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
9 changes: 9 additions & 0 deletions src/org/labkey/test/components/html/BootstrapMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.labkey.test.components.react.BaseBootstrapMenu;
import org.labkey.test.util.LogMethod;
import org.labkey.test.util.LoggedParam;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Expand Down Expand Up @@ -118,6 +119,14 @@ public void clickSubMenu(boolean wait, @LoggedParam String ... subMenuLabels)
clickSubMenu(wait ? getWrapper().getDefaultWaitForPage() : 0, subMenuLabels);
}

public boolean menuItemIsDisabled(String text)
{
if (findVisibleMenuItemOrNull(text) == null)
throw new NoSuchElementException("Menu item not found: " + text);

return findDisabledMenuItemOrNull(text) != null;
}

@Override
protected Locator getToggleLocator()
{
Expand Down
6 changes: 4 additions & 2 deletions src/org/labkey/test/components/react/QueryChartDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ public QueryChartPanel clickCreateChart()
{
WebDriverWrapper.waitFor(this::isCreateChartButtonEnabled,
"the create chart button did not become enabled", 2000);
String name = getName();
dismiss("Create Chart");
return _queryGrid.getChartPanel();
return _queryGrid.getChartPanel(name);
}

/*
Expand All @@ -405,8 +406,9 @@ public QueryChartPanel clickSaveChart()
{
WebDriverWrapper.waitFor(this::isSaveChartButtonEnabled,
"the Save chart button did not become enabled", 2000);
String name = getName();
dismiss("Save Chart");
return _queryGrid.getChartPanel();
return _queryGrid.getChartPanel(name);
}

/*
Expand Down
7 changes: 5 additions & 2 deletions src/org/labkey/test/components/react/QueryChartPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ public static class QueryChartPanelFinder extends WebDriverComponentFinder<Query
{
private final QueryGrid _queryGrid;
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "chart-panel");
private final String _name;

public QueryChartPanelFinder(WebDriver driver, QueryGrid queryGrid)
public QueryChartPanelFinder(WebDriver driver, QueryGrid queryGrid, String name)
{
super(driver);
_queryGrid = queryGrid;
_name = name;
Comment on lines +105 to +109
Copy link
Member

Choose a reason for hiding this comment

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

The chart name shouldn't be mandatory. The finder should find all of the charts by default and there should be a withName method to specify the name.
QueryChartPanel should probably have a getName method too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if we only ever want to find a chart by name, then why should it find all by default? Put another way, why make a default that isn't used? Same goes for QueryChartPanel, why add a getName method that isn't used?

Copy link
Member

Choose a reason for hiding this comment

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

That's a fair point, I was mostly commenting on the typical design of component finders. If we ever have other needs for this, refactoring the finder is easy enough.

}

@Override
Expand All @@ -116,7 +118,8 @@ protected QueryChartPanel construct(WebElement el, WebDriver driver)
@Override
protected Locator locator()
{
return _baseLocator;
Locator.XPathLocator headingLocator = Locator.tagWithClass("div", "chart-panel__heading").withChild(Locator.tagWithClass("div", "chart-panel__heading-title").containing(_name));
return _baseLocator.withChild(headingLocator);
}
}
}
40 changes: 34 additions & 6 deletions src/org/labkey/test/components/ui/grids/QueryGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.labkey.test.components.ui.FilterStatusValue;
import org.labkey.test.util.selenium.WebElementUtils;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
Expand Down Expand Up @@ -720,7 +721,7 @@ public QueryGrid resetToDefaultState(boolean revertDefaultView)
public QueryChartPanel showChart(String chartName)
{
elementCache().chartsMenu.clickSubMenu(false, chartName);
return getChartPanel();
return getChartPanel(chartName);
}

public QueryChartDialog createChart()
Expand All @@ -729,12 +730,39 @@ public QueryChartDialog createChart()
return new QueryChartDialog("Create Chart", getDriver(), this);
}

public boolean createChartIsDisabled()
{
return chartIsDisabled("Create Chart");
}

public boolean chartIsDisabled(String name)
{
elementCache().chartsMenu.expand();
return elementCache().chartsMenu.menuItemIsDisabled(name);
}

public boolean chartIsSelected(String name)
{
elementCache().chartsMenu.expand();
List<WebElement> menuItems = elementCache().chartsMenu.findVisibleMenuItems();

Optional<WebElement> menuItem = menuItems.stream().filter(item -> item.getText().contains(name)).findFirst();

if (menuItem.isEmpty()) {
throw new NoSuchElementException(String.format("Could not find chart menu item %s", name));
}

WebElement checkbox = menuItem.get().findElement(Locator.byClass("chart-menu-checkbox"));

return checkbox.getAttribute("class").contains("fa-check-square");
}

/*
gets a chart panel that is already being shown
gets a chart panel that is already being shown for a given chart name
*/
public QueryChartPanel getChartPanel()
public QueryChartPanel getChartPanel(String name)
{
return new QueryChartPanel.QueryChartPanelFinder(getDriver(), this).waitFor(this);
return new QueryChartPanel.QueryChartPanelFinder(getDriver(), this, name).waitFor(this);
}

public WebElement showRReport(String reportName)
Expand All @@ -743,9 +771,9 @@ public WebElement showRReport(String reportName)
return elementCache().rReport();
}

public void closeChart()
public void closeChart(String name)
{
getChartPanel().clickClose();
getChartPanel(name).clickClose();
}

@Override
Expand Down