Add sample finder test for multi choice field#2903
Conversation
create TestArrayDataUtils to move duplicated methods for multi choice simplify verifyFilter method in SMSourceTypeMultiChoiceTest
| public class TestArrayDataUtils | ||
| { |
There was a problem hiding this comment.
Consider moving TestDataUtils.parseMultiValueText and ResponsiveGrid.ARRAY_OPERATORS into this class.
| case ARRAY_CONTAINS_NOT_EXACT -> !(actualValues.size() == searchValues.size() && actualValues.containsAll(searchValues)); | ||
| case ARRAY_ISEMPTY -> actualValues.isEmpty(); | ||
| case ARRAY_ISNOTEMPTY -> !actualValues.isEmpty(); | ||
| default -> true; |
There was a problem hiding this comment.
Should this default to true for non-array operators? What does the server do?
Unless this matches the actual product behavior, we should just throw an IllegalArgumentException for non-array operators.
| public static Map<String, String> filterMap(Map<String, List<String>> sourceMap, List<String> searchValues, Filter.Operator filterType) | ||
| { | ||
| return sourceMap.entrySet().stream() | ||
| .filter(entry -> isMatch(entry.getValue(), searchValues, filterType)) | ||
| .collect(Collectors.toMap( | ||
| Map.Entry::getKey, | ||
| e -> e.getValue().stream().sorted().collect(Collectors.joining(", ")), | ||
| (e1, e2) -> e1, | ||
| LinkedHashMap::new | ||
| )); | ||
| } |
There was a problem hiding this comment.
Avoid losing information. filterMap should return the filtered map in the same format that it was passed in, Map<String, List<String>>.
Maybe create a separate method to sort and join the values in a standard format. Something like:
public static String formatValues(List<String> values)
{
return TextUtils.normalizeSpace(values.stream().sorted().collect(Collectors.joining(", "));
}
| for (int i = 0; i < size; i++) | ||
| { | ||
| textChoices.add(randomString(randomInt(1, 25))); | ||
| } |
There was a problem hiding this comment.
This should trim the generated values and ensure that there aren't any duplicate or blank values.
| // waitForElement(elementCache().findCheckbox(values[0])); | ||
| // waitFor(() -> elementCache().findCheckbox(values[0]).isDisplayed(), 10000); | ||
| for (String value : values) | ||
| { | ||
| elementCache().findCheckbox(value).check(); | ||
| try{ | ||
| elementCache().findCheckbox(value).check();} | ||
| catch (Exception e){ | ||
| elementCache().findCheckbox(value).check(); | ||
| } |
There was a problem hiding this comment.
Consider making ElementCache.findCheckbox wait for the checkbox instead of attempting to find it twice here.
There was a problem hiding this comment.
This method should be the same as it was. Used this for debugging and forgot to delete it, my bad
| .sorted(Comparator | ||
| .comparing((String s) -> s.substring(0, 1).toLowerCase()) | ||
| .thenComparing(s -> s.substring(0, 1)) | ||
| .thenComparing(s -> s)) | ||
| .collect(Collectors.toList()), |
There was a problem hiding this comment.
Add some documentation explaining this special sorting.
comment fix Co-authored-by: Trey Chadick <tchad@labkey.com>
| { | ||
| textChoices.add(randomString(randomInt(1, 25))); | ||
| } | ||
| return textChoices; |
There was a problem hiding this comment.
This is likely to be used to generate Lists that shouldn't be changed. Use Collections.unmodifiableList to prevent modification.
| return textChoices; | |
| return Collections.unmodifiableList(textChoices); |
Rationale
Add sample finder test for multi choice field
Related Pull Requests
Changes