Skip to content
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
43 changes: 40 additions & 3 deletions src/org/labkey/test/components/ui/grids/EditableGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -1019,13 +1019,50 @@ public String copyCurrentSelection() throws IOException, UnsupportedFlavorExcept
return getWrapper().getClipboardContent();
}

/**
* Select a cell range and drag-fill from the end of that selection to {@code dragEnd}.
* Because this overload owns the {@link #selectCellRange} step, it can fully restore state
* and retry if the first drag extended the selection without applying the fill.
*
* @param selectStart first cell of the selection (passed to {@link #selectCellRange})
* @param selectEnd last cell of the selection; also the source of the fill value
* @param dragEnd destination cell for the fill drag
*/
public void dragFill(WebElement selectStart, WebElement selectEnd, WebElement dragEnd)
{
Locator.XPathLocator selectionHandleLoc = Locator.byClass("cell-selection-handle");
selectCellRange(selectStart, selectEnd);
String fillValue = getCellValue(selectEnd);
WebElement selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000);
dragToCell(selectionHandle, dragEnd);
if (!WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(dragEnd)), 3_000))
{
// Fill didn't complete — the drag likely extended the selection without triggering the fill.
selectCellRange(selectStart, selectEnd);
selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000);
dragToCell(selectionHandle, dragEnd);
WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(dragEnd)),
"Drag fill did not populate end cell with value: " + fillValue, 5_000);
}
}

/**
* Drag-fill from {@code startCell} (which must already be selected / part of the current
* selection) to {@code endCell}. Prefer {@link #dragFill(WebElement, WebElement, WebElement)}
* when the selection range is known — that overload can retry reliably.
*/
public void dragFill(WebElement startCell, WebElement endCell)
{
dismissPopover();
Locator.XPathLocator selectionHandleLoc = Locator.byClass("cell-selection-handle");
WebElement selectionHandle = selectionHandleLoc.findElement(startCell);
// Get the value from the start cell
String fillValue = getCellValue(startCell);
WebElement selectionHandle = selectionHandleLoc.waitForElement(getComponentElement(), 2_000);
dragToCell(selectionHandle, endCell);
selectionHandleLoc.waitForElement(endCell, 5_000);
// Handle appearing in endCell alone is insufficient — the selection can expand
// (handle moves) without fill values being applied. Wait for the actual value.
WebDriverWrapper.waitFor(() -> fillValue.equals(getCellValue(endCell)),
"Drag fill did not populate end cell with value: " + fillValue, 5_000);
}

public void selectCellRange(WebElement startCell, WebElement endCell)
Expand All @@ -1045,7 +1082,7 @@ private void dragToCell(WebElement elementToDrag, WebElement destinationCell)
// WebDriver doesn't calculate correct location to click the cell selection handle
.moveToElement(elementToDrag, 0, 7)
.clickAndHold()
.pause(Duration.ofMillis(200))
.pause(Duration.ofMillis(500))
.moveToElement(destinationCell)
// Extra wiggle to get it to stick
.moveByOffset(0, -size.getHeight())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void testCrossFolderMVTCtoTCConversion() throws IOException, CommandExcep
updateSampleTypePage.getFieldsPanel()
.getField(multiValueTextChoiceFieldName)
.expand()
.setAllowMultipleSelections(false);
.setAllowMultipleSelections(false, true);
updateSampleTypePage.clickSave();

// Check that impossible to choose multiple values.
Expand Down
Loading