diff --git a/src/org/labkey/test/components/ui/FilterStatusValue.java b/src/org/labkey/test/components/ui/FilterStatusValue.java index bc55410b6c..6f5af0d033 100644 --- a/src/org/labkey/test/components/ui/FilterStatusValue.java +++ b/src/org/labkey/test/components/ui/FilterStatusValue.java @@ -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); } diff --git a/src/org/labkey/test/components/ui/grids/SaveViewDialog.java b/src/org/labkey/test/components/ui/grids/SaveViewDialog.java index 8f7b42d25d..593f72130c 100644 --- a/src/org/labkey/test/components/ui/grids/SaveViewDialog.java +++ b/src/org/labkey/test/components/ui/grids/SaveViewDialog.java @@ -17,6 +17,7 @@ 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; @@ -24,11 +25,16 @@ 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) @@ -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 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 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 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. */ diff --git a/src/org/labkey/test/tests/component/GridPanelViewTest.java b/src/org/labkey/test/tests/component/GridPanelViewTest.java index da44533a33..f307041ead 100644 --- a/src/org/labkey/test/tests/component/GridPanelViewTest.java +++ b/src/org/labkey/test/tests/component/GridPanelViewTest.java @@ -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(); @@ -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.");