Skip to content

Commit a4f244b

Browse files
authored
Issue 52773: display warning for unresolved form lookup values (#2435)
1 parent 01df03e commit a4f244b

File tree

3 files changed

+54
-38
lines changed

3 files changed

+54
-38
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@ public boolean isPlaceholderVisible()
156156
return placeholder != null && placeholder.isDisplayed();
157157
}
158158

159+
public @Nullable String getHelpBlockText()
160+
{
161+
waitForReady();
162+
163+
if (!isHelpBlockVisible())
164+
return null;
165+
166+
return Locators.helpBlock.findElement(getComponentElement()).getText().trim();
167+
}
168+
169+
public boolean isHelpBlockVisible()
170+
{
171+
var helpBlock = Locators.helpBlock.findElementOrNull(getComponentElement());
172+
return helpBlock != null && helpBlock.isDisplayed();
173+
}
174+
159175
public String getValue()
160176
{
161177
waitForReady();
@@ -499,6 +515,7 @@ private Locators()
499515
public static final Locator.XPathLocator singleValueLabel = Locator.tagWithClass("div", "select-input__single-value");
500516
public static final Locator loadingSpinner = Locator.tagWithClass("span", "select-input__loading-indicator");
501517
public static final Locator listItems = Locator.tagWithClass("div", "select-input__option");
518+
public static final Locator.XPathLocator helpBlock = Locator.tagWithClass("span", "help-block");
502519

503520
public static Locator.XPathLocator selectContainer()
504521
{

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,8 @@ public ReactSelect getEntityType(String entityName)
276276
String inputName = input.findElement(this).getAttribute("name");
277277
return new ReactSelect.ReactSelectFinder(getDriver()).withNamedInput(inputName).find(this);
278278
}
279-
else
280-
{
281-
return null;
282-
}
279+
280+
return null;
283281
}
284282

285283
/**
@@ -352,12 +350,10 @@ public ParentEntityEditPanel addParent(String typeName, String parentId)
352350
*/
353351
public ParentEntityEditPanel addParents(String typeName, List<String> parentIds)
354352
{
355-
if(getEntityType(typeName) == null)
353+
if (getEntityType(typeName) == null)
356354
getAddNewEntityTypeSelect().select(typeName);
357355

358-
var selectParent = FilteringReactSelect.finder(getDriver())
359-
.withNamedInput(String.format("parentEntityValue_%s", typeName))
360-
.waitFor(elementCache());
356+
var selectParent = getParent(typeName);
361357

362358
// Adding for debugging (trying to understand why save button is not enabled after setting).
363359
getWrapper().log(String.format("Selections before adding: %s", selectParent.getSelections()));

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

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public String getTextField(String fieldLabel)
131131
{
132132
WebElement fieldValueElement = elementCache().valueCellWithLabel(fieldLabel);
133133
WebElement textElement = fieldValueElement.findElement(By.xpath("./div/div/*"));
134-
if(textElement.getTagName().equalsIgnoreCase("textarea"))
134+
if (textElement.getTagName().equalsIgnoreCase("textarea"))
135135
return textElement.getText();
136136
else
137137
return textElement.getAttribute("value");
@@ -146,14 +146,14 @@ public String getTextField(String fieldLabel)
146146
**/
147147
public DetailTableEdit setTextField(String fieldLabel, String value)
148148
{
149-
if(isFieldEditable(fieldLabel))
149+
if (isFieldEditable(fieldLabel))
150150
{
151151
WebElement fieldValueElement = elementCache().valueCellWithLabel(fieldLabel);
152152

153153
WebElement editableElement = fieldValueElement.findElement(By.xpath("./div/div/*"));
154154
String elementType = editableElement.getTagName().toLowerCase().trim();
155155

156-
switch(elementType)
156+
switch (elementType)
157157
{
158158
case "textarea":
159159
case "input":
@@ -291,6 +291,11 @@ public boolean isFileFieldBlank(String fieldLabel)
291291
.hasAttachedFile();
292292
}
293293

294+
public FilteringReactSelect getSelectField(String fieldLabel)
295+
{
296+
return elementCache().findSelect(fieldLabel);
297+
}
298+
294299
/**
295300
* Get the value of a select field.
296301
*
@@ -299,17 +304,18 @@ public boolean isFileFieldBlank(String fieldLabel)
299304
**/
300305
public String getSelectedValue(String fieldLabel)
301306
{
302-
FilteringReactSelect reactSelect = elementCache().findSelect(fieldLabel);
303-
return reactSelect.getValue();
307+
return getSelectField(fieldLabel).getValue();
304308
}
305309

306-
/*
307-
This allows you to query a given select in the edit panel to see what options it offers
308-
*/
310+
/**
311+
* This allows you to query a given select in the edit panel to see what options it offers.
312+
*
313+
* @param fieldLabel The label of the field to get.
314+
* @return List of strings for the values in the list.
315+
**/
309316
public List<String> getSelectOptions(String fieldLabel)
310317
{
311-
FilteringReactSelect reactSelect = elementCache().findSelect(fieldLabel);
312-
return reactSelect.getOptions();
318+
return getSelectField(fieldLabel).getOptions();
313319
}
314320

315321
/**
@@ -333,7 +339,6 @@ public DetailTableEdit createSelectValue(String fieldLabel, String value)
333339
return this;
334340
}
335341

336-
337342
/**
338343
* Select multiple values from a select list.
339344
*
@@ -343,7 +348,7 @@ public DetailTableEdit createSelectValue(String fieldLabel, String value)
343348
**/
344349
public DetailTableEdit setSelectValue(String fieldLabel, List<String> selectValues)
345350
{
346-
FilteringReactSelect reactSelect = elementCache().findSelect(fieldLabel);
351+
FilteringReactSelect reactSelect = getSelectField(fieldLabel);
347352
selectValues.forEach(reactSelect::typeAheadSelect);
348353
_changeCounter++;
349354
return this;
@@ -361,24 +366,25 @@ public DetailTableEdit clearSelectValue(String fieldLabel)
361366
}
362367

363368
/**
364-
* Clear a given select field
369+
* Clear a given select field.
370+
*
365371
* @param fieldLabel The label of the field to clear.
366372
* @param waitForSelection If true, wait for the select to have a selection before clearing it
367373
* @param assertSelection If true, assert if no selection appears (note: does nothing if waitForSelection is not true)
368-
* @return
374+
* @return A reference to this editable detail table.
369375
*/
370376
public DetailTableEdit clearSelectValue(String fieldLabel, boolean waitForSelection, boolean assertSelection)
371377
{
372-
var select = elementCache().findSelect(fieldLabel);
378+
var select = getSelectField(fieldLabel);
373379
if (waitForSelection)
374380
{
375-
if (assertSelection) {
376-
WebDriverWrapper.waitFor(() -> select.hasSelection(),
381+
if (assertSelection)
382+
{
383+
WebDriverWrapper.waitFor(select::hasSelection,
377384
String.format("The %s select did not have any selection in time", fieldLabel), _readyTimeout);
378385
}
379-
else {
380-
WebDriverWrapper.waitFor(() -> select.hasSelection(), 1000);
381-
}
386+
else
387+
WebDriverWrapper.waitFor(select::hasSelection, 1_000);
382388
}
383389
select.clearSelection();
384390
_changeCounter++;
@@ -398,19 +404,19 @@ public DetailTableEdit clearSelectValue(String fieldLabel, boolean waitForSelect
398404
public DetailTableEdit setDateTimeField(String fieldName, Object dateTime)
399405
{
400406
ReactDateTimePicker dateTimePicker = getDateTimePicker(fieldName);
401-
if(dateTime instanceof LocalDateTime localDateTime)
407+
if (dateTime instanceof LocalDateTime localDateTime)
402408
{
403409
dateTimePicker.select(localDateTime);
404410
}
405-
else if(dateTime instanceof LocalDate localDate)
411+
else if (dateTime instanceof LocalDate localDate)
406412
{
407413
dateTimePicker.selectDate(localDate);
408414
}
409-
else if(dateTime instanceof LocalTime localTime)
415+
else if (dateTime instanceof LocalTime localTime)
410416
{
411417
dateTimePicker.selectTime(localTime);
412418
}
413-
else if(dateTime instanceof String setValue)
419+
else if (dateTime instanceof String setValue)
414420
{
415421
dateTimePicker.set(setValue, true);
416422
}
@@ -481,7 +487,7 @@ private String getSourceTitle()
481487
*/
482488
public String getValidationMessage()
483489
{
484-
if(elementCache().validationMsg.existsIn(this))
490+
if (elementCache().validationMsg.existsIn(this))
485491
return elementCache().validationMsg.findElement(getDriver()).getText();
486492
else
487493
return "";
@@ -534,8 +540,7 @@ public String clickSaveExpectingError()
534540
{
535541
elementCache().saveButton.click();
536542
WebElement errorBanner = BootstrapLocators.errorBanner.findWhenNeeded(this);
537-
WebDriverWrapper.waitFor(()->errorBanner.isDisplayed(),
538-
"No error message was shown.", 1_000);
543+
WebDriverWrapper.waitFor(errorBanner::isDisplayed, "No error message was shown.", 1_000);
539544
return errorBanner.getText();
540545
}
541546

@@ -550,8 +555,7 @@ public String clickCancelExpectingError()
550555
{
551556
elementCache().cancelButton.click();
552557
WebElement errorBanner = BootstrapLocators.errorBanner.findWhenNeeded(this);
553-
WebDriverWrapper.waitFor(()->errorBanner.isDisplayed(),
554-
"No error message was shown.", 1_000);
558+
WebDriverWrapper.waitFor(errorBanner::isDisplayed, "No error message was shown.", 1_000);
555559
return errorBanner.getText();
556560
}
557561

@@ -647,5 +651,4 @@ protected Locator locator()
647651
return _locator;
648652
}
649653
}
650-
651654
}

0 commit comments

Comments
 (0)