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
2 changes: 1 addition & 1 deletion src/org/labkey/test/WebDriverWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ public static File[] getNewFiles(int minFileCount, File downloadDir, @Nullable F
final File[] files = downloadDir.listFiles(tempFilesFilter);
return files != null && files.length == 0;
},
"Temp files remain in download dir: " + downloadDir, WAIT_FOR_JAVASCRIPT);
"Temp files remain in download dir: " + downloadDir, WAIT_FOR_PAGE);

MutableInt downloadSize = new MutableInt(-1);
MutableInt stabilityDuration = new MutableInt(0);
Expand Down
56 changes: 56 additions & 0 deletions src/org/labkey/test/components/ui/grids/EditableGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,57 @@ else if (value instanceof LocalTime localTime)
return gridCell;
}

/**
* Set the value of a multi-line field for the given row & column. This uses javascript to set the value, not sendKeys.
* Use '\n' for a new line.
*
* @param row Row to update.
* @param columnName Column name of the multi-line field.
* @param value The value to set.
*/
public void setMultiLineCellValue(int row, String columnName, String value)
{

WebElement gridCell = getCell(row, columnName);
String beforeText = gridCell.getText();

WebElement textArea = activateCellUsingDoubleClick(row, columnName);

// Using setFormElement won't call the blur even to remove focus and set the field.
getWrapper().setFormElementJS(textArea, value);
getWrapper().fireEvent(textArea, WebDriverWrapper.SeleniumEvent.blur);

waitFor(()->getWrapper().shortWait().until(ExpectedConditions.stalenessOf(textArea)),
"TextArea did not go away.", 500);

// Wait until the cell shows some kind of update before leaving.
WebDriverWrapper.waitFor(() -> !gridCell.getText().equals(beforeText),
"Doesn't look like the multi-line field was updated.", WAIT_FOR_JAVASCRIPT);

}

/**
* Double-clicking a cell that is "text" value field will activate it and present a textArea for editing the value.
* This will return the textArea WebElement that can be used to set the field.
* @param row Row to be edited.
* @param columnName Column name of the field.
* @return The TextArea component that can be used to edit the field.
*/
public WebElement activateCellUsingDoubleClick(int row, String columnName)
{
WebElement gridCell = getCell(row, columnName);
WebElement textArea = Locator.tag("textarea").refindWhenNeeded(gridCell);

// Account for the cell already being active.
if(!textArea.isDisplayed())
{
getWrapper().doubleClick(gridCell);
waitFor(textArea::isDisplayed,
String.format("Table cell for row %d and column '%s' was not activated.", row, columnName), 1_000);
}
return textArea;
}

/**
* Creates a value in a select that allows the user to insert/create a value, vs. selecting from an existing/populated set
* @param row the row
Expand Down Expand Up @@ -693,6 +744,11 @@ public List<String> getSelectionCellTexts()
return getWrapper().getTexts(cells);
}

public List<WebElement> getSelectedCells()
{
return Locator.tagWithClass("div", "cell-selection").parent("td").findElements(this);
}

/**
* Pastes a single value into as many cells as are selected, or supports pasting a square shaped blob of data
* of the same shape as the prescribed selection. If a single value is supplied, that value will be put into
Expand Down
7 changes: 6 additions & 1 deletion src/org/labkey/test/pages/assay/AssayUploadJobsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ public PipelineStatusTable getDataTable()
}

public PipelineStatusDetailsPage clickJobStatus(String jobDescription)
{
return clickJobStatus(jobDescription, getDefaultWaitForPage());
}

public PipelineStatusDetailsPage clickJobStatus(String jobDescription, int waitTimeout)
{
int jobRow = getDataTable().getJobRow(jobDescription);
return getDataTable().clickStatusLink(jobRow);
return getDataTable().clickStatusLink(jobRow, waitTimeout);
}

public AssayDataPage clickViewResults()
Expand Down
55 changes: 55 additions & 0 deletions src/org/labkey/test/tests/SampleTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,61 @@ public void testFileAttachment()
exportGridVerifyRowCountAndHeader(3, expectedHeaders);
}

@Test // Issue 49830
public void testFilePathOnBulkImport() throws IOException
{
projectMenu().navigateToFolder(PROJECT_NAME, FOLDER_NAME);

String sampleTypeName = "FilePathValidation";
String fileFieldName = "FileField";
SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
sampleHelper.createSampleType(new SampleTypeDefinition(sampleTypeName).setFields(
List.of(new FieldDefinition(fileFieldName, ColumnType.File))
));

// add a file system file that isn't under the current container dir, i.e. in the parent dir
goToProjectHome();
goToModule("FileContent");
_fileBrowserHelper.uploadFile(TestFileUtils.getSampleData("sampleType.xlsx"));

// go back to subfolder and import data with relative path that shouldn't resolve
DataRegionTable drt = importSampleTypeFilePathData(sampleTypeName, fileFieldName, "Test1", "../sampleType.xlsx");
checker().verifyEquals("Sample name in data row not as expected", "Test1", drt.getDataAsText(0, "Name"));
checker().verifyEquals("File field should be empty as path was invalid", " ", drt.getDataAsText(0, fileFieldName));

// add a file system file in current container dir and import data with relative path that should resolve
goToModule("FileContent");
_fileBrowserHelper.uploadFile(TestFileUtils.getSampleData("sampleType.xlsx"));
drt = importSampleTypeFilePathData(sampleTypeName, fileFieldName, "Test2", "sampleType.xlsx");
checker().verifyEquals("Sample name in data row not as expected", "Test2", drt.getDataAsText(0, "Name"));
checker().verifyEquals("File field should contain file name", " sampleType.xlsx", drt.getDataAsText(0, fileFieldName));

// try an import with a valid file that isn't accessible from this container
File propFile = new File(TestFileUtils.getTestRoot(), "test.properties");
drt = importSampleTypeFilePathData(sampleTypeName, fileFieldName, "Test3", propFile.getAbsolutePath());
checker().verifyEquals("Sample name in data row not as expected", "Test3", drt.getDataAsText(0, "Name"));
String actualValue = drt.getDataAsText(0, fileFieldName);
checker().verifyTrue("File field should not be valid", " ".equals(actualValue) || actualValue.contains("properties (unavailable)"));

// try an import with an invalid file path
drt = importSampleTypeFilePathData(sampleTypeName, fileFieldName, "Test4", "invalid/path/to/file");
checker().verifyEquals("Sample name in data row not as expected", "Test4", drt.getDataAsText(0, "Name"));
checker().verifyTrue("File field should not be valid", drt.getDataAsText(0, fileFieldName).contains("file (unavailable)"));
}

private DataRegionTable importSampleTypeFilePathData(String sampleTypeName, String fileFieldName, String sampleName, String filePath)
{
projectMenu().navigateToFolder(PROJECT_NAME, FOLDER_NAME);
clickAndWait(Locator.linkWithText(sampleTypeName));
DataRegionTable drt = DataRegionTable.findDataRegionWithinWebpart(this, "Sample Type Contents");
drt.clickImportBulkData();
String header = "Name\t" + fileFieldName + "\n";
String data = sampleName + "\t" + filePath + "\n";
setFormElement(Locator.name("text"), header + data);
clickButton("Submit");
return DataRegionTable.findDataRegionWithinWebpart(this, "Sample Type Contents");
}

@Test
public void testCreateViaScript()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testUpload200kRows() throws Exception

// wait for import complete
var assayJobsPage1 = new AssayUploadJobsPage(getDriver());
var pipelineDetailsPage1 = assayJobsPage1.clickJobStatus("200k");
var pipelineDetailsPage1 = assayJobsPage1.clickJobStatus("200k", 3 * WebDriverWrapper.WAIT_FOR_PAGE);
pipelineDetailsPage1.waitForComplete(10 * WebDriverWrapper.WAIT_FOR_PAGE);

// export assay1 data to excel
Expand All @@ -136,7 +136,7 @@ public void testUpload200kRows() throws Exception
clickButton("Save and Finish");

var assayJobsPage2 = new AssayUploadJobsPage(getDriver());
var pipelineDetailsPage2 = assayJobsPage2.clickJobStatus("200k take 2");
var pipelineDetailsPage2 = assayJobsPage2.clickJobStatus("200k take 2", 3 * getDefaultWaitForPage());
pipelineDetailsPage2.waitForComplete(10 * WebDriverWrapper.WAIT_FOR_PAGE);

var qPage = SourceQueryPage.beginAt(this, getProjectName(), "assay.General.large_assay_2", "Data");
Expand Down
Loading