Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bot] Fast-forward for 23.11.6 #1807

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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: 28 additions & 8 deletions src/org/labkey/test/components/ui/entities/EntityInsertPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ public FileUploadPanel getFileUploadPanel()
return panel.fileUploadPanel();
}

private Optional<EditableGrid> optionalGrid()
{
return new EditableGrid.EditableGridFinder(_driver).findOptional(this);
}

public EntityInsertPanel setMergeData(boolean allowMerge)
{
var panel = showFileUpload();
Expand All @@ -213,7 +208,7 @@ public boolean hasMergeOption()

protected FileUploadPanel fileUploadPanel()
{
return new FileUploadPanel.FileUploadPanelFinder(_driver).timeout(WAIT_FOR_JAVASCRIPT).waitFor(this);
return elementCache().fileUploadPanel();
}

private Optional<FileUploadPanel> optionalFileUploadPanel()
Expand All @@ -233,7 +228,7 @@ public List<Map<String, String>> getGridData()

public boolean isGridVisible()
{
var optionalGrid = optionalGrid();
var optionalGrid = elementCache().optionalGrid();
return optionalGrid.isPresent() && optionalGrid.get().isDisplayed();
}

Expand Down Expand Up @@ -272,7 +267,7 @@ public EntityBulkUpdateDialog clickBulkUpdate()

public boolean hasTabs()
{
return Locator.tagWithClassContaining("ul", "list-group").existsIn(this);
return elementCache().hasTabs();
}

public boolean isFileUploadVisible()
Expand Down Expand Up @@ -327,6 +322,11 @@ protected boolean isVisible(Locator locator)

public EntityInsertPanel showGrid()
{
/* either this is a grid-only insert panel, or there will be a mode-select list-item to
allow the user to select the grid. Await one or the other to be present */
WebDriverWrapper.waitFor(()-> isGridVisible() || hasTabs(),
"Neither the grid nor its selector appeared within the ready timeout", _readyTimeout);

if (!isGridVisible())
{
modeSelectListItem("from Grid")
Expand Down Expand Up @@ -429,8 +429,28 @@ protected class ElementCache extends Component<?>.ElementCache

EditableGrid grid = new EditableGrid.EditableGridFinder(_driver).timeout(WAIT_FOR_JAVASCRIPT).findWhenNeeded();

private Optional<EditableGrid> optionalGrid()
{
return new EditableGrid.EditableGridFinder(_driver).findOptional(this);
}

private Optional<FileUploadPanel> optionalFileUploadPanel()
{
return new FileUploadPanel.FileUploadPanelFinder(getDriver()).findOptional();
}

protected FileUploadPanel fileUploadPanel()
{
return new FileUploadPanel.FileUploadPanelFinder(_driver).timeout(WAIT_FOR_JAVASCRIPT).waitFor(this);
}

WebElement formatString = Locator.tagWithClass("div","file-form-formats")
.refindWhenNeeded(this).withTimeout(WAIT_FOR_JAVASCRIPT);

public boolean hasTabs()
{
return Locator.tagWithClassContaining("ul", "list-group").existsIn(elementCache());
}
}

public static class EntityInsertPanelFinder extends WebDriverComponent.WebDriverComponentFinder<EntityInsertPanel, EntityInsertPanelFinder>
Expand Down
44 changes: 31 additions & 13 deletions src/org/labkey/test/components/ui/grids/DetailTableEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DetailTableEdit extends WebDriverComponent<DetailTableEdit.ElementC
private final WebElement _formElement;
private final WebDriver _driver;
private String _title;
private int _readyTimeout = WebDriverWrapper.WAIT_FOR_JAVASCRIPT;

protected DetailTableEdit(WebElement formElement, WebDriver driver)
{
Expand All @@ -56,6 +57,12 @@ public String getTitle()
return _title;
}

public DetailTableEdit setReadyTimeout(int readyTimeout)
{
_readyTimeout = readyTimeout;
return this;
}

/**
* Check to see if a field is editable. Could be state dependent, that is it returns false if the field is
* loading but if checked later could return true.
Expand Down Expand Up @@ -264,18 +271,6 @@ public String getSelectedValue(String fieldCaption)
return reactSelect.getValue();
}

/**
* clears the selections from the specified reactSelect
* @param fieldCaption The label text for the select box
* @return A reference to the current object
*/
public DetailTableEdit clearSelectionValues(String fieldCaption)
{
FilteringReactSelect reactSelect = elementCache().findSelect(fieldCaption);
reactSelect.clearSelection();
return this;
}

/*
This allows you to query a given select in the edit panel to see what options it offers
*/
Expand Down Expand Up @@ -329,7 +324,30 @@ public DetailTableEdit setSelectValue(String fieldCaption, List<String> selectVa
**/
public DetailTableEdit clearSelectValue(String fieldCaption)
{
elementCache().findSelect(fieldCaption).clearSelection();
return clearSelectValue(fieldCaption, true, true);
}

/**
* Clear a given select field
* @param fieldCaption The caption/label of the field to clear.
* @param waitForSelection If true, wait for the select to have a selection before clearing it
* @param assertSelection If true, assert if no selection appears (note: does nothing if waitForSelection is not true)
* @return
*/
public DetailTableEdit clearSelectValue(String fieldCaption, boolean waitForSelection, boolean assertSelection)
{
var select = elementCache().findSelect(fieldCaption);
if (waitForSelection)
{
if (assertSelection) {
WebDriverWrapper.waitFor(() -> select.hasSelection(),
String.format("The %s select did not have any selection in time", fieldCaption), _readyTimeout);
}
else {
WebDriverWrapper.waitFor(() -> select.hasSelection(), 1000);
}
}
select.clearSelection();
return this;
}

Expand Down