Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/org/labkey/test/components/react/BaseReactSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,41 @@ public String getName()
return elementCache().input.getAttribute("name");
}

/**
* Determines whether the "Add New" menu footer is present at the bottom of the select's menu area. This item is
* rendered only when the underlying schema/query is registered and configured to support adding new values.
*
* @return true if the "Add New" menu item is visible, otherwise false
*/
public boolean isAddNewVisible()
{
open();
return Locators.addEntitiesFooter.isDisplayed(this);
}

/**
* Clicks the "Add New" menu item at the bottom of the select's menu area. The menu is opened first if it is not
* already expanded. This intentionally returns void: the resulting UI varies by schema/query, so the caller is
* responsible for constructing and interacting with whatever the click produces.
*/
public void clickAddNew()
{
open();

try
{
Locators.addEntitiesFooter.findElement(this).click();
}
catch (WebDriverException e)
{
// ReactSelect is notoriously bad at positioning the menu so that it does not render off the screen.
// That said, it can behave better if you close and reopen the menu.
close();
open();
Locators.addEntitiesFooter.findElement(this).click();
}
}

protected T scrollIntoView()
{
try
Expand Down Expand Up @@ -515,6 +550,7 @@ private Locators()
}

public static final Locator.XPathLocator option = Locator.tagWithClass("div", "select-input__option");
public static final Locator.XPathLocator addEntitiesFooter = Locator.tagWithClass("div", "add-entities-footer");
public static final Locator placeholder = Locator.tagWithClass("div", "select-input__placeholder");
public static final Locator clear = Locator.tagWithClass("div","select-input__clear-indicator");
public static final Locator arrow = Locator.tagWithClass("div","select-input__dropdown-indicator");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ public String getDateField(CharSequence fieldIdentifier)
*/
private FileAttachmentContainer getFileField(CharSequence fieldIdentifier)
{
FieldKey identifier = FileAttachmentContainer.fileUploadFieldKey(fieldIdentifier);
return enableAndWait(identifier, elementCache().fileUploadField(identifier));
return enableAndWait(fieldIdentifier, elementCache().fileUploadField(fieldIdentifier));
}

/**
Expand Down Expand Up @@ -307,8 +306,7 @@ public EntityBulkUpdateDialog removeExistingAttachment(CharSequence fieldIdentif

public FileUploadField getExistingFileCard(CharSequence fieldIdentifier)
{
FieldKey identifier = FileAttachmentContainer.fileUploadFieldKey(fieldIdentifier);
return enableAndWait(identifier, elementCache().fileField(identifier));
return enableAndWait(fieldIdentifier, elementCache().fileField(fieldIdentifier));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.labkey.test.components.WebDriverComponent;
import org.labkey.test.components.html.FileInput;
import org.labkey.test.components.html.Input;
import org.labkey.test.params.FieldKey;
import org.openqa.selenium.ElementNotInteractableException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -211,16 +210,6 @@ protected class ElementCache extends Component<?>.ElementCache
public Locator fileUploadScrollFooterLoc = Locator.tagWithClass("div", "file-upload__scroll-footer");
}

/**
* File upload fields append "-fileUpload" to the field's fieldKey
* @param fieldIdentifier Identifier for the field; name ({@link String}) or fieldKey ({@link FieldKey})
* @return FieldKey with expected suffix
*/
public static FieldKey fileUploadFieldKey(CharSequence fieldIdentifier)
{
return FieldKey.fromFieldKey(FieldKey.fromName(fieldIdentifier) + "-fileUpload"); // Issue 53394
}

public static class FileAttachmentContainerFinder extends WebDriverComponentFinder<FileAttachmentContainer, FileAttachmentContainerFinder>
{
private final Locator.XPathLocator _baseLocator = Locator.tagWithClass("div", "file-upload__container").parent("div");
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/util/AuditLogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ public void checkTransactionAuditLogDetails(Integer transactionAuditId, Map<Tran
{
String expectedValue = expectedDetails.get(key).toString();
String actualValue = actualDetails.get(key.name()) != null ? actualDetails.get(key.name()).toString() : null;
assertTrue("Detail value for key " + key + " not as expected", actualValue != null && actualValue.contains(expectedValue));
assertTrue("Detail value for key " + key + " does not contain \"" + expectedValue + "\"", actualValue != null && actualValue.contains(expectedValue));
}
else
assertEquals("Detail value for key " + key + " not as expected", expectedDetails.get(key), actualDetails.get(key.name()));
Expand Down