Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/org/labkey/test/components/ui/FilterStatusValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected class ElementCache extends Component<?>.ElementCache

public final WebElement icon = Locator.tag("i").findWhenNeeded(getComponentElement());

public final WebElement popover = Locator.tag("div").withClass("lk-popover popover bottom").findWhenNeeded(_driver);
public final WebElement popover = Locator.tag("div").withClasses("lk-popover", "popover").findWhenNeeded(_driver);
}


Expand Down
81 changes: 81 additions & 0 deletions src/org/labkey/test/components/ui/grids/SaveViewDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@

import org.labkey.test.BootstrapLocators;
import org.labkey.test.Locator;
import org.labkey.test.SortDirection;
import org.labkey.test.components.bootstrap.ModalDialog;
import org.labkey.test.components.html.Checkbox;
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.RadioButton;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

/**
* Dialog used to save a grid view in an app.
*/
public class SaveViewDialog extends ModalDialog
{
private static final int FILTER_SECTION = 0;
private static final int SORT_SECTION = 1;

QueryGrid grid;

public SaveViewDialog(WebDriver driver, QueryGrid grid)
Expand Down Expand Up @@ -185,6 +191,81 @@ public boolean isMakeSharedVisible()
return elementCache().makeShared.isDisplayed();
}

/**
* Get the text of the filter pills listed in the dialog.
*
* @return Filter pill text, empty if the dialog shows the 'no filters' message instead.
*/
public List<String> getFilterValues()
{
return getSectionValues(FILTER_SECTION);
}

/**
* Get the message shown in place of the filter pills when the view will be saved with no filters.
*
* @return The message, or an empty string if filter pills are shown.
*/
public String getNoFiltersMessage()
{
return getSectionMessage(FILTER_SECTION);
}

/**
* Get the text of the sort pills listed in the dialog. A sort pill shows only the column label; use
* {@link #getSortDirection(String)} for the direction.
*
* @return Sort pill text, empty if the dialog shows the 'no sort' message instead.
*/
public List<String> getSortValues()
{
return getSectionValues(SORT_SECTION);
}

/**
* Get the message shown in place of the sort pills when the view will be saved with no sorts.
*
* @return The message, or an empty string if sort pills are shown.
*/
public String getNoSortsMessage()
{
return getSectionMessage(SORT_SECTION);
}

/**
* Get the direction of a sort pill. The pill conveys direction only through its icon.
*
* @param sortValue Text of the sort pill, as returned by {@link #getSortValues()}.
* @return The direction the column will be sorted.
*/
public SortDirection getSortDirection(String sortValue)
{
WebElement pill = Locator.tagWithClass("div", "filter-status-value").withText(sortValue)
.waitForElement(getSection(SORT_SECTION), 5_000);
String iconClass = Locator.tagWithClass("i", "symbol").findElement(pill).getAttribute("class");
return iconClass.contains("fa-sort-amount-desc") ? SortDirection.DESC : SortDirection.ASC;
}

private List<String> getSectionValues(int section)
{
return Locator.tagWithClass("div", "filter-status-value")
.findElements(getSection(section))
.stream().map(WebElement::getText)
.toList();
}

private String getSectionMessage(int section)
{
WebElement message = Locator.tagWithClass("div", "save-view-modal__no-action-values")
.findElementOrNull(getSection(section));
return message == null ? "" : message.getText();
}

private WebElement getSection(int section)
{
return Locator.tagWithClass("div", "save-view-modal__action-values").findElements(this).get(section);
}

/**
* Save the view.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/org/labkey/test/tests/component/GridPanelViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,12 @@ public void testRemoveColumnForView() throws Exception
checker().verifyFalse("The 'Make default' checkbox should not be checked.",
saveViewDialog.isMakeDefaultChecked());

// GitHub Issue #696: nothing but a column was changed, so both sections show their empty message.
checker().verifyEquals("Save view dialog should report that no filters will be saved.",
"No filters applied", saveViewDialog.getNoFiltersMessage());
checker().verifyEquals("Save view dialog should report that no sort will be saved.",
"No sort applied", saveViewDialog.getNoSortsMessage());

checker().screenShotIfNewError("testDefaultViewRemoveColumn_Save_View_Dialog_Defaults_Error");

saveViewDialog.setMakeDefault();
Expand Down Expand Up @@ -639,6 +645,14 @@ public void testColumnHeaderAndFilterPill(String testName, String viewName) thro
savedViewsForDefaultSampleType.add(viewName);
}

// GitHub Issue #696: the dialog shows the filters and sorts that will be saved with the view.
checker().verifyEquals("Filters listed in the save view dialog not as expected.",
List.of(expectedPillText), saveViewDialog.getFilterValues());
checker().verifyEquals("Sorts listed in the save view dialog not as expected.",
List.of(colToSort), saveViewDialog.getSortValues());
checker().verifyEquals("Sort direction shown in the save view dialog not as expected.",
SortDirection.ASC, saveViewDialog.getSortDirection(colToSort));

saveViewDialog.saveView();

log("Refresh the page and validate icons from the view.");
Expand Down