Skip to content

Commit 9999e6e

Browse files
committed
Merge branch 'develop' into fb_encodeFormName
2 parents dcecfe3 + 03fdbba commit 9999e6e

4 files changed

Lines changed: 71 additions & 9 deletions

File tree

src/org/labkey/test/components/domain/DomainFieldRow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public DomainFieldRow clickRemoveOntologyConcept()
770770
public void setAllowMultipleSelections(Boolean allowMultipleSelections)
771771
{
772772
WebDriverWrapper.waitFor(() -> elementCache().allowMultipleSelectionsCheckbox.isDisplayed(),
773-
"Allow Multiple Selections checkbox did not become visible", 2000);
773+
"Allow Multiple Selections checkbox did not become visible", 1000);
774774
elementCache().allowMultipleSelectionsCheckbox.set(allowMultipleSelections);
775775
}
776776

src/org/labkey/test/components/ui/grids/EditableGrid.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import static org.labkey.test.BaseWebDriverTest.WAIT_FOR_JAVASCRIPT;
5757
import static org.labkey.test.WebDriverWrapper.waitFor;
5858
import static org.labkey.test.util.TestLogger.log;
59+
import static org.labkey.test.util.data.TestArrayDataUtils.formatMultiValueText;
5960
import static org.labkey.test.util.selenium.ScrollUtils.Alignment.center;
6061
import static org.labkey.test.util.selenium.WebDriverUtils.MODIFIER_KEY;
6162

@@ -921,6 +922,39 @@ public EditableGrid pasteMultipleCells(String pasteText, int startRowIndex, Char
921922
return this;
922923
}
923924

925+
/**
926+
* Format data for pasting into an editable grid. List elements in each row are quoted and separated by commas.
927+
* This allows values containing commas to be pasted into multi-value columns. Even single-selections for these
928+
* types of columns should be passed in as Lists to ensure they are quoted properly.
929+
*
930+
* @param rows values for pasting into an editable grid.
931+
* @return rows formatted for pasting into an editable grid.
932+
*/
933+
public static String formatForPaste(List<List<?>> rows)
934+
{
935+
StringBuilder sb = new StringBuilder();
936+
for (List<?> row : rows)
937+
{
938+
if (!sb.isEmpty())
939+
sb.append("\n");
940+
941+
boolean firstVal = true;
942+
for (Object value : row)
943+
{
944+
if (!firstVal)
945+
sb.append("\t");
946+
else
947+
firstVal = false;
948+
949+
if (value instanceof List<?> l)
950+
sb.append(formatMultiValueText(l));
951+
else
952+
sb.append(value);
953+
}
954+
}
955+
return sb.toString();
956+
}
957+
924958
/**
925959
* Copies text from the grid, b
926960
* @param startRowIndex Index of the top-left cell's row

src/org/labkey/test/pages/assay/AssayRunsPage.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public void clickEditAssayDesign()
113113
elementCache().manageMenu.doMenuAction("Edit Assay Design");
114114
}
115115

116+
//Method for Standard assays only.
117+
public AssayImportPage clickImportData()
118+
{
119+
clickAndWait(Locator.linkWithText("Import Data"));
120+
return new AssayImportPage(getDriver());
121+
}
122+
116123
@Override
117124
protected ElementCache newElementCache()
118125
{

src/org/labkey/test/util/data/TestArrayDataUtils.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,35 @@ public static <T> Map<String, List<String>> filterMap(Map<String, T> map, List<S
4545
.filter(entry -> isMatch(entry.getValue(), searchValues, filterType))
4646
.collect(Collectors.toMap(
4747
Map.Entry::getKey,
48-
e -> e.getValue().stream()
49-
// Standard alphabetical sort that accounts for symbols and numbers.
50-
// But uppercase letters are positioned before lowercase letters.
51-
.sorted(Comparator
52-
.comparing((String s) -> s.substring(0, 1).toLowerCase())
53-
.thenComparing(s -> s.substring(0, 1))
54-
.thenComparing(s -> s))
55-
.collect(Collectors.toList()),
48+
e -> sortValues(e.getValue()),
5649
(e1, e2) -> e1,
5750
LinkedHashMap::new
5851
));
5952
}
6053

54+
/**
55+
* Standard alphabetical sort that accounts for symbols and numbers.
56+
* Uppercase letters are positioned before lowercase letters.
57+
*/
58+
public static List<String> sortValues(List<String> values)
59+
{
60+
return values.stream()
61+
.peek(s -> { if (s.isEmpty()) throw new IllegalArgumentException("Empty values aren't allowed: " + values);})
62+
.sorted(Comparator
63+
.comparing((String s) -> s.substring(0, 1).toLowerCase())
64+
.thenComparing(s -> s.substring(0, 1))
65+
.thenComparing(s -> s))
66+
.collect(Collectors.toList());
67+
}
68+
69+
/**
70+
* Sorts values alphabetically and joins them with the given separator.
71+
*/
72+
public static String sortAndJoin(List<String> values, String separator)
73+
{
74+
return String.join(separator, sortValues(values));
75+
}
76+
6177
public static Map<String, String> prepareMapForCheck(Map<String, List<String>> map)
6278
{
6379
return map.entrySet().stream()
@@ -87,6 +103,11 @@ public static List<String> parseMultiValueText(String multiValueString) throws I
87103
}
88104
}
89105

106+
public static <T> String formatMultiValueText(List<T> values)
107+
{
108+
return values.stream().map(CSVFormat.DEFAULT::format).collect(Collectors.joining(","));
109+
}
110+
90111
private static boolean isMatch(List<String> actualValues, List<String> searchValues, Filter.Operator type)
91112
{
92113
return switch (type)

0 commit comments

Comments
 (0)