diff --git a/src/org/labkey/test/AssayAPITest.java b/src/org/labkey/test/AssayAPITest.java index a3f1945a62..bb05a2ba72 100644 --- a/src/org/labkey/test/AssayAPITest.java +++ b/src/org/labkey/test/AssayAPITest.java @@ -424,8 +424,8 @@ private void verifyUpdateRunFileAPI(String assayName, String runFileField, int r "queryName: \"Runs\", " + "success: callback," + "failure: callback," + - "rows: [{ RowId: \""+ runRowId + "\"," + - "\"" + EscapeUtil.toJSONStr(runFileField) + "\": \"" + EscapeUtil.toJSONStr(filePath) + "\"," + + "rows: [{ \"RowId\": " + runRowId + "," + + EscapeUtil.toJSONStr(runFileField) + ": " + EscapeUtil.toJSONStr(filePath) + "}]" + "})"; executeAndVerifyScript(updateScript, errorMsg); diff --git a/src/org/labkey/test/components/react/BaseReactSelect.java b/src/org/labkey/test/components/react/BaseReactSelect.java index 0761b6fbaf..cc35b0acc6 100644 --- a/src/org/labkey/test/components/react/BaseReactSelect.java +++ b/src/org/labkey/test/components/react/BaseReactSelect.java @@ -115,7 +115,7 @@ public boolean isClearable() public boolean isDisabled() { - return hasClass("select-input__control--is-disabled"); + return hasClass("select-input__control--is-disabled") || hasClass("select-input--is-disabled"); } public boolean isEnabled() diff --git a/src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java b/src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java index 0a8678bda1..62d61fbb25 100644 --- a/src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java +++ b/src/org/labkey/test/components/ui/domainproperties/EntityTypeDesigner.java @@ -365,18 +365,18 @@ public List getParentAliasOptions(int index) return elementCache().parentAliasSelect(index).getOptions(); } - public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText) + public T setParentAlias(int index, @Nullable String alias, @Nullable String dataType) { - return setParentAlias(index, alias, optionDisplayText, false); + return setParentAlias(index, alias, dataType, false); } - public T setParentAlias(int index, @Nullable String alias, @Nullable String optionDisplayText, boolean isRequired) + public T setParentAlias(int index, @Nullable String alias, @Nullable String dataType, boolean isRequired) { expandPropertiesPanel(); elementCache().parentAlias(index).setValue(alias); - if (optionDisplayText != null) + if (dataType != null) { - elementCache().parentAliasSelect(index).select(optionDisplayText); + elementCache().parentAliasSelect(index).select(dataType); } // The "Required" checkbox is not presented outside of the apps. Only a test running in the app could set diff --git a/src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java b/src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java index 522a4726f5..2b0ebfeb5c 100644 --- a/src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java +++ b/src/org/labkey/test/components/ui/domainproperties/samples/SampleTypeDesigner.java @@ -41,12 +41,12 @@ public T addParentAlias(String alias) return addParentAlias(alias, null); } - public T addParentAlias(String alias, @Nullable String optionDisplayText) + public T addParentAlias(String alias, @Nullable String dataType) { - return addParentAlias(alias, optionDisplayText, false); + return addParentAlias(alias, dataType, false); } - public T addParentAlias(String alias, @Nullable String optionDisplayText, boolean isRequired) + public T addParentAlias(String alias, @Nullable String dataType, boolean isRequired) { expandPropertiesPanel(); @@ -55,11 +55,11 @@ public T addParentAlias(String alias, @Nullable String optionDisplayText, boolea elementCache().addParentAliasButton.click(); int initialCount = findEmptyAlias(); - if (optionDisplayText == null) + if (dataType == null) { - optionDisplayText = CURRENT_SAMPLE_TYPE; + dataType = CURRENT_SAMPLE_TYPE; } - setParentAlias(initialCount, alias, optionDisplayText, isRequired); + setParentAlias(initialCount, alias, dataType, isRequired); return getThis(); } diff --git a/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java b/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java index e71980e918..34efbee7fa 100644 --- a/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java +++ b/src/org/labkey/test/components/ui/entities/ParentEntityEditPanel.java @@ -262,13 +262,20 @@ public ReactSelect getAddNewEntityTypeSelect() * * @return A select at this given ordinal position. */ - private ReactSelect getEntityTypeByPosition(int index) + public ReactSelect getEntityTypeByPosition(int index) { return ReactSelect.finder(getDriver()) .withNamedInput(String.format("entityType%d", index)) .waitFor(elementCache()); } + public ReactSelect getDisabledEntityTypeByLabel(String typeName) + { + return ReactSelect.finder(getDriver()) + .followingLabelWithSpan(typeName) + .waitFor(elementCache()); + } + public ReactSelect getEntityType(String entityName) { Locator input = Locator.tagWithAttribute("input", "value", entityName.toLowerCase()); @@ -344,6 +351,10 @@ public ParentEntityEditPanel addParent(String typeName, String parentId) return addParents(typeName, Arrays.asList(parentId)); } + public ParentEntityEditPanel addParents(String typeName, List parentIds) + { + return addParents(typeName, parentIds, false); + } /** * Add a specific parents (samples or sources) from the given type. If the type is not currently being used for * parent elements it will be added. @@ -353,9 +364,9 @@ public ParentEntityEditPanel addParent(String typeName, String parentId) * @param parentIds A list of the individuals samples or sources to add. * @return A reference to this panel. */ - public ParentEntityEditPanel addParents(String typeName, List parentIds) + public ParentEntityEditPanel addParents(String typeName, List parentIds, boolean skipAdd) { - if (getEntityType(typeName) == null) + if (!skipAdd && getEntityType(typeName) == null) getAddNewEntityTypeSelect().select(typeName); var selectParent = getParentFinder(typeName).waitFor(elementCache()); @@ -393,6 +404,9 @@ public ParentEntityEditPanel removeEntityType(String typeName) boolean found = false; for (ReactSelect reactSelect : selectControls) { + if (reactSelect.isDisabled()) + continue; + if (reactSelect.getSelections().contains(typeName)) { found = true; @@ -444,6 +458,11 @@ public void clearActionComment() elementCache().commentInput.clear(); } + public boolean hasParentInputError() + { + return Locator.tagWithClass("div", "edit-parent-danger").isDisplayed(this); + } + /** * Simple finder for this panel. diff --git a/src/org/labkey/test/components/ui/grids/EditableGrid.java b/src/org/labkey/test/components/ui/grids/EditableGrid.java index 5819cce130..49322c054e 100644 --- a/src/org/labkey/test/components/ui/grids/EditableGrid.java +++ b/src/org/labkey/test/components/ui/grids/EditableGrid.java @@ -161,6 +161,19 @@ public EditableGrid removeColumn(CharSequence columnIdentifier) return this; } + public boolean canRemoveColumn(CharSequence columnIdentifier) + { + WebElement headerCell = elementCache().getColumnHeaderCell(columnIdentifier); + WebElement downBtn = Locator.byClass("fa-chevron-circle-down").findElementOrNull(headerCell); + if (downBtn == null) + return false; + downBtn.click(); + WebElement removeBtn = Locator.tagWithText("a", "Remove Column").findElementOrNull(headerCell); + boolean canRemove = removeBtn != null && removeBtn.isDisplayed() && removeBtn.isEnabled(); + downBtn.click(); // close dropdown + return canRemove; + } + private boolean hasSelectColumn() { return elementCache().selectColumn.isDisplayed(); diff --git a/src/org/labkey/test/util/EscapeUtil.java b/src/org/labkey/test/util/EscapeUtil.java index b5ea40ad83..08ac4bbfc2 100644 --- a/src/org/labkey/test/util/EscapeUtil.java +++ b/src/org/labkey/test/util/EscapeUtil.java @@ -23,6 +23,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -50,7 +51,23 @@ static public String toJSONStr(String str) } } } - return escaped.toString(); + return "\"" + escaped + "\""; + } + + static public String toJSONRow(Map row) + { + StringBuilder sb = new StringBuilder("{"); + String comma = ""; + for (Map.Entry entry : row.entrySet()) + { + sb.append(comma); + Object value = entry.getValue(); + sb.append(EscapeUtil.toJSONStr(entry.getKey())) + .append(": ").append(value instanceof String ? EscapeUtil.toJSONStr((String) entry.getValue()) : value); + comma = ","; + } + sb.append("}"); + return sb.toString(); } static public String jsString(String s)