-
Notifications
You must be signed in to change notification settings - Fork 9
Tests for multi choice value #2872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
333c490
fabe096
349d08d
0ab67be
fd9d700
bf42d09
1745585
f349d82
92000dd
c3c8266
e5ec9db
33683e0
9a5773a
41e1c78
36a970a
bac1f69
c44cbd6
c60c514
fe04f1f
0435138
b4d52e0
fd83f85
6648cf1
d1751b3
187e9b4
7c72826
e9aab1d
87c688b
6cab358
987b284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,11 +507,14 @@ public WebElement setCellValue(int row, CharSequence columnIdentifier, Object va | |
|
|
||
| if (value instanceof List) | ||
| { | ||
|
|
||
| // If this is a list assume that it will need a lookup. | ||
| List<String> values = (List) value; | ||
|
|
||
| ReactSelect lookupSelect = elementCache().lookupSelect(gridCell); | ||
|
|
||
| lookupSelect.clearSelection(); | ||
|
|
||
|
Comment on lines
+516
to
+517
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this work if a test is trying to add to an existing selections?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect a method called |
||
| lookupSelect.open(); | ||
|
|
||
| for (String _value : values) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |||||||||||||||||||
| import org.labkey.test.components.react.ReactCheckBox; | ||||||||||||||||||||
| import org.labkey.test.components.ui.grids.FieldReferenceManager.FieldReference; | ||||||||||||||||||||
| import org.labkey.test.components.ui.search.FilterExpressionPanel; | ||||||||||||||||||||
| import org.labkey.test.components.ui.search.FilterFacetedPanel; | ||||||||||||||||||||
| import org.labkey.test.params.FieldKey; | ||||||||||||||||||||
| import org.labkey.test.util.selenium.WebElementUtils; | ||||||||||||||||||||
| import org.openqa.selenium.Keys; | ||||||||||||||||||||
|
|
@@ -40,6 +41,14 @@ | |||||||||||||||||||
| import static org.hamcrest.CoreMatchers.is; | ||||||||||||||||||||
| import static org.hamcrest.MatcherAssert.assertThat; | ||||||||||||||||||||
| import static org.junit.Assert.assertEquals; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.CONTAINS_ALL; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.CONTAINS_ANY; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.CONTAINS_EXACTLY; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.CONTAINS_NONE; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.DOES_NOT_CONTAIN_EXACTLY; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.IN; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.IS_EMPTY; | ||||||||||||||||||||
| import static org.labkey.remoteapi.query.Filter.Operator.IS_NOT_EMPTY; | ||||||||||||||||||||
| import static org.labkey.test.WebDriverWrapper.waitFor; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public class ResponsiveGrid<T extends ResponsiveGrid<?>> extends WebDriverComponent<ResponsiveGrid<T>.ElementCache> implements UpdatingComponent | ||||||||||||||||||||
|
|
@@ -234,18 +243,31 @@ public String filterColumnExpectingError(CharSequence columnIdentifier, Filter.O | |||||||||||||||||||
|
|
||||||||||||||||||||
| private GridFilterModal initFilterColumn(CharSequence columnIdentifier, Filter.Operator operator, Object value) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| List<Filter.Operator> listOperators = List.of(IN, CONTAINS_ALL, CONTAINS_ANY, CONTAINS_EXACTLY, CONTAINS_NONE, | ||||||||||||||||||||
| DOES_NOT_CONTAIN_EXACTLY); | ||||||||||||||||||||
|
Comment on lines
243
to
+247
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| clickColumnMenuItem(columnIdentifier, "Filter...", false); | ||||||||||||||||||||
| GridFilterModal filterModal = new GridFilterModal(getDriver(), this); | ||||||||||||||||||||
| if (operator != null) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (operator.equals(Filter.Operator.IN) && value instanceof List<?>) | ||||||||||||||||||||
| if (listOperators.contains(operator) && value instanceof List<?>) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| List<String> values = (List<String>) value; | ||||||||||||||||||||
| filterModal.selectFacetTab().selectValue(values.get(0)); | ||||||||||||||||||||
| filterModal.selectFacetTab().checkValues(values.toArray(String[]::new)); | ||||||||||||||||||||
| FilterFacetedPanel filterPanel = filterModal.selectFacetTab(); | ||||||||||||||||||||
| filterPanel.selectValue(values.get(0)); | ||||||||||||||||||||
| filterPanel.checkValues(values.toArray(String[]::new)); | ||||||||||||||||||||
| if (filterPanel.isFiltersPresented()) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| filterPanel.selectFilter(operator); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (value == null) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| filterModal.selectFacetTab().selectFilter(operator); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
-241
to
266
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that I have a better understanding of these new filter operators, I have a better idea for this method. We don't actually need to check whether the operator select is present; for the new operators, the select will always be present. |
||||||||||||||||||||
| else | ||||||||||||||||||||
| { | ||||||||||||||||||||
| filterModal.selectExpressionTab().setFilter(new FilterExpressionPanel.Expression(operator, value)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return filterModal; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -385,15 +407,16 @@ public T selectRow(int index, boolean checked) | |||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Finds the first row with the specified texts in the specified columns, and sets its checkbox | ||||||||||||||||||||
| * @param partialMap key-column (fieldKey, name, or label), value-text in that column | ||||||||||||||||||||
| * @param checked the desired checkbox state | ||||||||||||||||||||
| * | ||||||||||||||||||||
| * @param partialMap key-column (fieldKey, name, or label), value-text in that column | ||||||||||||||||||||
| * @param checked the desired checkbox state | ||||||||||||||||||||
| * @return this grid | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| public T selectRow(Map<String, String> partialMap, boolean checked) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| GridRow row = getRow(partialMap); | ||||||||||||||||||||
| selectRowAndVerifyCheckedCounts(row, checked); | ||||||||||||||||||||
| getWrapper().log("Row described by map ["+partialMap+"] selection state set to + ["+row.isSelected()+"]"); | ||||||||||||||||||||
| getWrapper().log("Row described by map [" + partialMap + "] selection state set to + [" + row.isSelected() + "]"); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return getThis(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,15 +6,19 @@ | |||||||||
| import org.labkey.test.components.WebDriverComponent; | ||||||||||
| import org.labkey.test.components.html.Checkbox; | ||||||||||
| import org.labkey.test.components.html.Input; | ||||||||||
| import org.labkey.test.components.react.ReactSelect; | ||||||||||
| import org.labkey.test.components.ui.FilterStatusValue; | ||||||||||
| import org.labkey.remoteapi.query.Filter; | ||||||||||
| import org.openqa.selenium.WebDriver; | ||||||||||
| import org.openqa.selenium.WebElement; | ||||||||||
| import org.openqa.selenium.support.ui.ExpectedConditions; | ||||||||||
|
|
||||||||||
| import java.util.List; | ||||||||||
| import java.util.stream.Collectors; | ||||||||||
|
|
||||||||||
| import static org.labkey.test.WebDriverWrapper.waitFor; | ||||||||||
| import static org.labkey.test.components.html.Input.Input; | ||||||||||
| import static org.labkey.test.util.samplemanagement.SMTestUtils.isVisible; | ||||||||||
|
|
||||||||||
| public class FilterFacetedPanel extends WebDriverComponent<FilterFacetedPanel.ElementCache> | ||||||||||
| { | ||||||||||
|
|
@@ -48,6 +52,23 @@ public void selectValue(String value) | |||||||||
| elementCache().findCheckboxLabel(value).click(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Check that filter choosing option exists on the page. | ||||||||||
| */ | ||||||||||
| public boolean isFiltersPresented() | ||||||||||
| { | ||||||||||
| return waitFor(() -> isVisible(elementCache().filterTypeSelects), 1000); | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't wait for things that might not be present, especially when the most common state is for it to not be present. |
||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Select a filer by clicking its label. Right now this method relevant only for multi-value text choice. | ||||||||||
| * @param operator desired filter value | ||||||||||
| */ | ||||||||||
| public void selectFilter(Filter.Operator operator) | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A slightly more descriptive method name.
Suggested change
|
||||||||||
| { | ||||||||||
| elementCache().filterTypeSelects.select(operator.getDisplayValue()); | ||||||||||
| } | ||||||||||
labkey-tchad marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Check single facet value by label to see if it is checked or not. | ||||||||||
| * @param value desired value | ||||||||||
|
|
@@ -123,6 +144,8 @@ protected class ElementCache extends Component<?>.ElementCache | |||||||||
| { | ||||||||||
| protected final Input filterInput = | ||||||||||
| Input(Locator.id("filter-faceted__typeahead-input"), getDriver()).findWhenNeeded(this); | ||||||||||
| protected final ReactSelect filterTypeSelects = | ||||||||||
| new ReactSelect.ReactSelectFinder(getDriver()).index(0).findWhenNeeded(this); | ||||||||||
|
Comment on lines
+147
to
+148
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making name consistent with method rename suggestion.
Suggested change
|
||||||||||
| protected final WebElement checkboxSection = | ||||||||||
| Locator.byClass("labkey-wizard-pills").index(0).refindWhenNeeded(this); | ||||||||||
| protected final Locator.XPathLocator checkboxLabelLoc | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,11 +13,13 @@ | |||||||||||||||||||||||||||
| import org.labkey.test.components.html.OptionSelect; | ||||||||||||||||||||||||||||
| import org.labkey.test.pages.LabKeyPage; | ||||||||||||||||||||||||||||
| import org.labkey.test.util.EscapeUtil; | ||||||||||||||||||||||||||||
| import org.openqa.selenium.By; | ||||||||||||||||||||||||||||
| import org.openqa.selenium.WebDriver; | ||||||||||||||||||||||||||||
| import org.openqa.selenium.WebElement; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| import java.io.File; | ||||||||||||||||||||||||||||
| import java.util.HashMap; | ||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public class UpdateQueryRowPage extends LabKeyPage<UpdateQueryRowPage.ElementCache> | ||||||||||||||||||||||||||||
|
|
@@ -87,6 +89,10 @@ else if (value instanceof File f) | |||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| setField(entry.getKey(), f); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| else if (value instanceof List l) | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| setField(entry.getKey(), l); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| throw new IllegalArgumentException("Unsupported value type for '" + entry.getKey() + "': " + value.getClass().getName()); | ||||||||||||||||||||||||||||
|
|
@@ -99,7 +105,7 @@ public UpdateQueryRowPage setField(String fieldName, String value) | |||||||||||||||||||||||||||
| WebElement field = elementCache().findField(fieldName); | ||||||||||||||||||||||||||||
| if (field.getTagName().equals("select")) | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| setField(fieldName, OptionSelect.SelectOption.textOption(value)); | ||||||||||||||||||||||||||||
| selectOptionByText(field, value); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
|
|
@@ -108,6 +114,19 @@ public UpdateQueryRowPage setField(String fieldName, String value) | |||||||||||||||||||||||||||
| return this; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public UpdateQueryRowPage setField(String fieldName, List<String> values) | ||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can replace the existing |
||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| WebElement field = elementCache().findField(fieldName, true); | ||||||||||||||||||||||||||||
| List<WebElement> options = field.findElements(By.tagName("option")); | ||||||||||||||||||||||||||||
| //unselect all options that selected but shouldn't be selected | ||||||||||||||||||||||||||||
| options.forEach(option -> | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| if (!values.contains(option.getText()) && option.getAttribute("selected") != null) option.click(); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| values.forEach(value -> selectOptionByText(field, value)); | ||||||||||||||||||||||||||||
| return this; | ||||||||||||||||||||||||||||
|
Comment on lines
+119
to
+127
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WebDriver's
Suggested change
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| public UpdateQueryRowPage setField(String fieldName, Boolean value) | ||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||
| new Checkbox(elementCache().findField(fieldName)).set(value); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MultiValueTextChoiceValidatoris redundant. We can just check the column type to decide whether to allow multiple selections.