Skip to content

Commit f09d272

Browse files
authored
Selenium tests : Required Lineage Relationships (#2617)
1 parent f0fcd7c commit f09d272

File tree

7 files changed

+67
-18
lines changed

7 files changed

+67
-18
lines changed

src/org/labkey/test/AssayAPITest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,8 @@ private void verifyUpdateRunFileAPI(String assayName, String runFileField, int r
424424
"queryName: \"Runs\", " +
425425
"success: callback," +
426426
"failure: callback," +
427-
"rows: [{ RowId: \""+ runRowId + "\"," +
428-
"\"" + EscapeUtil.toJSONStr(runFileField) + "\": \"" + EscapeUtil.toJSONStr(filePath) + "\"," +
427+
"rows: [{ \"RowId\": " + runRowId + "," +
428+
EscapeUtil.toJSONStr(runFileField) + ": " + EscapeUtil.toJSONStr(filePath) +
429429
"}]" +
430430
"})";
431431
executeAndVerifyScript(updateScript, errorMsg);

src/org/labkey/test/components/react/BaseReactSelect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public boolean isClearable()
115115

116116
public boolean isDisabled()
117117
{
118-
return hasClass("select-input__control--is-disabled");
118+
return hasClass("select-input__control--is-disabled") || hasClass("select-input--is-disabled");
119119
}
120120

121121
public boolean isEnabled()

src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,18 @@ public List<String> getParentAliasOptions(int index)
365365
return elementCache().parentAliasSelect(index).getOptions();
366366
}
367367

368-
public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText)
368+
public T setParentAlias(int index, @Nullable String alias, @Nullable String dataType)
369369
{
370-
return setParentAlias(index, alias, optionDisplayText, false);
370+
return setParentAlias(index, alias, dataType, false);
371371
}
372372

373-
public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText, boolean isRequired)
373+
public T setParentAlias(int index, @Nullable String alias, @Nullable String dataType, boolean isRequired)
374374
{
375375
expandPropertiesPanel();
376376
elementCache().parentAlias(index).setValue(alias);
377-
if (optionDisplayText != null)
377+
if (dataType != null)
378378
{
379-
elementCache().parentAliasSelect(index).select(optionDisplayText);
379+
elementCache().parentAliasSelect(index).select(dataType);
380380
}
381381

382382
// The "Required" checkbox is not presented outside of the apps. Only a test running in the app could set

src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public T addParentAlias(String alias)
4141
return addParentAlias(alias, null);
4242
}
4343

44-
public T addParentAlias(String alias, @Nullable String optionDisplayText)
44+
public T addParentAlias(String alias, @Nullable String dataType)
4545
{
46-
return addParentAlias(alias, optionDisplayText, false);
46+
return addParentAlias(alias, dataType, false);
4747
}
4848

49-
public T addParentAlias(String alias, @Nullable String optionDisplayText, boolean isRequired)
49+
public T addParentAlias(String alias, @Nullable String dataType, boolean isRequired)
5050
{
5151
expandPropertiesPanel();
5252

@@ -55,11 +55,11 @@ public T addParentAlias(String alias, @Nullable String optionDisplayText, boolea
5555

5656
elementCache().addParentAliasButton.click();
5757
int initialCount = findEmptyAlias();
58-
if (optionDisplayText == null)
58+
if (dataType == null)
5959
{
60-
optionDisplayText = CURRENT_SAMPLE_TYPE;
60+
dataType = CURRENT_SAMPLE_TYPE;
6161
}
62-
setParentAlias(initialCount, alias, optionDisplayText, isRequired);
62+
setParentAlias(initialCount, alias, dataType, isRequired);
6363
return getThis();
6464
}
6565

src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,20 @@ public ReactSelect getAddNewEntityTypeSelect()
262262
*
263263
* @return A select at this given ordinal position.
264264
*/
265-
private ReactSelect getEntityTypeByPosition(int index)
265+
public ReactSelect getEntityTypeByPosition(int index)
266266
{
267267
return ReactSelect.finder(getDriver())
268268
.withNamedInput(String.format("entityType%d", index))
269269
.waitFor(elementCache());
270270
}
271271

272+
public ReactSelect getDisabledEntityTypeByLabel(String typeName)
273+
{
274+
return ReactSelect.finder(getDriver())
275+
.followingLabelWithSpan(typeName)
276+
.waitFor(elementCache());
277+
}
278+
272279
public ReactSelect getEntityType(String entityName)
273280
{
274281
Locator input = Locator.tagWithAttribute("input", "value", entityName.toLowerCase());
@@ -344,6 +351,10 @@ public ParentEntityEditPanel addParent(String typeName, String parentId)
344351
return addParents(typeName, Arrays.asList(parentId));
345352
}
346353

354+
public ParentEntityEditPanel addParents(String typeName, List<String> parentIds)
355+
{
356+
return addParents(typeName, parentIds, false);
357+
}
347358
/**
348359
* Add a specific parents (samples or sources) from the given type. If the type is not currently being used for
349360
* parent elements it will be added.
@@ -353,9 +364,9 @@ public ParentEntityEditPanel addParent(String typeName, String parentId)
353364
* @param parentIds A list of the individuals samples or sources to add.
354365
* @return A reference to this panel.
355366
*/
356-
public ParentEntityEditPanel addParents(String typeName, List<String> parentIds)
367+
public ParentEntityEditPanel addParents(String typeName, List<String> parentIds, boolean skipAdd)
357368
{
358-
if (getEntityType(typeName) == null)
369+
if (!skipAdd && getEntityType(typeName) == null)
359370
getAddNewEntityTypeSelect().select(typeName);
360371

361372
var selectParent = getParentFinder(typeName).waitFor(elementCache());
@@ -393,6 +404,9 @@ public ParentEntityEditPanel removeEntityType(String typeName)
393404
boolean found = false;
394405
for (ReactSelect reactSelect : selectControls)
395406
{
407+
if (reactSelect.isDisabled())
408+
continue;
409+
396410
if (reactSelect.getSelections().contains(typeName))
397411
{
398412
found = true;
@@ -444,6 +458,11 @@ public void clearActionComment()
444458
elementCache().commentInput.clear();
445459
}
446460

461+
public boolean hasParentInputError()
462+
{
463+
return Locator.tagWithClass("div", "edit-parent-danger").isDisplayed(this);
464+
}
465+
447466

448467
/**
449468
* Simple finder for this panel.

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ public EditableGrid removeColumn(CharSequence columnIdentifier)
161161
return this;
162162
}
163163

164+
public boolean canRemoveColumn(CharSequence columnIdentifier)
165+
{
166+
WebElement headerCell = elementCache().getColumnHeaderCell(columnIdentifier);
167+
WebElement downBtn = Locator.byClass("fa-chevron-circle-down").findElementOrNull(headerCell);
168+
if (downBtn == null)
169+
return false;
170+
downBtn.click();
171+
WebElement removeBtn = Locator.tagWithText("a", "Remove Column").findElementOrNull(headerCell);
172+
boolean canRemove = removeBtn != null && removeBtn.isDisplayed() && removeBtn.isEnabled();
173+
downBtn.click(); // close dropdown
174+
return canRemove;
175+
}
176+
164177
private boolean hasSelectColumn()
165178
{
166179
return elementCache().selectColumn.isDisplayed();

src/org/labkey/test/util/EscapeUtil.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.net.URLEncoder;
2424
import java.nio.charset.StandardCharsets;
2525
import java.util.List;
26+
import java.util.Map;
2627
import java.util.regex.Pattern;
2728
import java.util.stream.Collectors;
2829

@@ -50,7 +51,23 @@ static public String toJSONStr(String str)
5051
}
5152
}
5253
}
53-
return escaped.toString();
54+
return "\"" + escaped + "\"";
55+
}
56+
57+
static public String toJSONRow(Map<String, Object> row)
58+
{
59+
StringBuilder sb = new StringBuilder("{");
60+
String comma = "";
61+
for (Map.Entry<String, Object> entry : row.entrySet())
62+
{
63+
sb.append(comma);
64+
Object value = entry.getValue();
65+
sb.append(EscapeUtil.toJSONStr(entry.getKey()))
66+
.append(": ").append(value instanceof String ? EscapeUtil.toJSONStr((String) entry.getValue()) : value);
67+
comma = ",";
68+
}
69+
sb.append("}");
70+
return sb.toString();
5471
}
5572

5673
static public String jsString(String s)

0 commit comments

Comments
 (0)