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

Assay Transform Script UX update to allow file drop and file path entry #1734

Merged
merged 5 commits into from
Nov 22, 2023
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
62 changes: 52 additions & 10 deletions src/org/labkey/test/pages/ReactAssayDesignerPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package org.labkey.test.pages;

import org.jetbrains.annotations.Nullable;
import org.labkey.test.Locator;
import org.labkey.test.components.DomainDesignerPage;
import org.labkey.test.components.domain.DomainFormPanel;
import org.labkey.test.components.domain.DomainPanel;
import org.labkey.test.components.html.Checkbox;
import org.labkey.test.components.html.Input;
import org.labkey.test.components.html.OptionSelect;
import org.labkey.test.components.ui.files.AttachmentCard;
import org.labkey.test.pages.assay.plate.PlateTemplateListPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand All @@ -30,7 +32,9 @@
import java.io.File;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
import static org.labkey.test.components.html.Checkbox.Checkbox;
import static org.labkey.test.components.html.Input.Input;
import static org.labkey.test.components.html.SelectWrapper.Select;
Expand Down Expand Up @@ -206,23 +210,61 @@ public boolean getStatus()

public ReactAssayDesignerPage addTransformScript(File transformScript)
{
expandPropertiesPanel();
int index = Locator.xpath("//input[starts-with(@id, 'assay-design-protocolTransformScripts')]").findElements(getDriver()).size();
getWrapper().click(Locator.tagWithClass("span", "btn").containing("Add Script"));
return setTransformScript(transformScript, index);
return setTransformScript(transformScript, false, null);
}

public ReactAssayDesignerPage setTransformScript(File transformScript)
public ReactAssayDesignerPage addTransformScript(File transformScript, boolean usingFileUpload)
{
expandPropertiesPanel();
return setTransformScript(transformScript, 0);
return setTransformScript(transformScript, usingFileUpload, null);
}

public ReactAssayDesignerPage setTransformScript(File transformScript, int index)
public ReactAssayDesignerPage addTransformScript(File transformScript, boolean usingFileUpload, @Nullable String expectedError)
{
return setTransformScript(transformScript, usingFileUpload, expectedError);
}

private ReactAssayDesignerPage setTransformScript(File transformScript, boolean usingFileUpload, @Nullable String expectedError)
{
expandPropertiesPanel();
assertTrue("Unable to locate the transform script: " + transformScript, transformScript.exists());
getWrapper().setFormElement(Locator.xpath("//input[@id='assay-design-protocolTransformScripts" + index + "']"), transformScript.getAbsolutePath());

expandPropertiesPanel();
getWrapper().click(Locator.tagWithClass("span", "btn").containing("Add Script"));
String targetPath = transformScript.getAbsolutePath();
if (usingFileUpload)
{
getWrapper().setFormElement(Locator.tagWithClass("input", "file-upload--input"), transformScript);
targetPath = "/@scripts/" + transformScript.getName();
}
else
{
getWrapper().checkRadioButton(Locator.radioButtonByNameAndValue("transformScriptAddType", "path"));
getWrapper().setFormElement(Locator.tagWithClass("div", "transform-script-add--path").child(Locator.tag("input")), transformScript.getAbsolutePath());
getWrapper().clickButton("Apply", 0);
}

if (expectedError == null)
{
String finalTargetPath = targetPath;
getWrapper().waitFor(()-> Locator.tagWithClass("div", "attachment-card__description").endsWith(finalTargetPath).isDisplayed(this),
"Transform script card with expected file not found", WAIT_FOR_JAVASCRIPT);
}
else
{
getWrapper().waitFor(()-> Locator.tagWithClass("div", "alert-danger").withText(expectedError).isDisplayed(this),
"Transform script expected error not found", WAIT_FOR_JAVASCRIPT);
getWrapper().click(Locator.tagWithClass("i", "container--removal-icon"));
}

return this;
}

public ReactAssayDesignerPage removeTransformScript(String fileName)
{
AttachmentCard card = new AttachmentCard.FileAttachmentCardFinder(getDriver()).withFile(fileName).waitFor(this);
int beforeCount = Locator.tagWithClass("div", "attachment-card__description").findElements(this).size();
card.clickRemove();
int afterCount = Locator.tagWithClass("div", "attachment-card__description").findElements(this).size();
assertEquals("Transform script count not as expected after remove.", beforeCount - 1, afterCount);
return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/tests/GpatPlateTemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private void doSetup()
.createAssayDesign("General", ASSAY_NAME)
.setPlateMetadata(true)
// Regression check for Issue 48293: Standard Assay with Plate Metadata & Transformation Script throws an error
.addTransformScript(TRANSFORM_SCRIPT)
.addTransformScript(TRANSFORM_SCRIPT, true)
.clickFinish();
createPlateTemplate(templateName, "blank", "Standard", true);
}
Expand Down
34 changes: 32 additions & 2 deletions src/org/labkey/test/tests/assay/AssayTransformWarningTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.labkey.test.categories.Assays;
import org.labkey.test.categories.Daily;
import org.labkey.test.pages.ReactAssayDesignerPage;
import org.labkey.test.pages.files.WebDavPage;
import org.labkey.test.params.FieldDefinition;
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.QCAssayScriptHelper;
Expand All @@ -46,6 +47,7 @@ public class AssayTransformWarningTest extends BaseWebDriverTest
public static final File JAVA_TRANSFORM_SCRIPT = TestFileUtils.getSampleData("qc/transformWarning.jar");
public static final File R_TRANSFORM_SCRIPT = TestFileUtils.getSampleData("qc/assayTransformWarning.R");
public static final File R_TRANSFORM_ERROR_SCRIPT = TestFileUtils.getSampleData("qc/assayTransformError.R");
public static final File JAVA_INVALID_TRANSFORM_SCRIPT = TestFileUtils.getSampleData("qc/src/org/labkey/AssayTransformNoOp.java");

@Override
public List<String> getAssociatedModules()
Expand Down Expand Up @@ -100,7 +102,7 @@ public void testJavaTransformWarning()
String runName = "java transform run";

_assayHelper.createAssayDesign("General", assayName)
.addTransformScript(JAVA_TRANSFORM_SCRIPT)
.addTransformScript(JAVA_TRANSFORM_SCRIPT, true)
.clickFinish();

clickAndWait(Locator.linkWithText(assayName));
Expand Down Expand Up @@ -136,7 +138,7 @@ public void testRTransformWarning()
String runName = "R transform run";

ReactAssayDesignerPage assayDesignerPage = _assayHelper.createAssayDesign("General", assayName)
.addTransformScript(R_TRANSFORM_SCRIPT);
.addTransformScript(R_TRANSFORM_SCRIPT, true);
assayDesignerPage.goToRunFields()
.addField("myFile")
.setLabel("My File")
Expand Down Expand Up @@ -210,4 +212,32 @@ public void testRTransformError()
assertElementPresent(Locator.tag("td").containing("Col1"));
assertElementPresent(Locator.tag("td").containing("test2"));
}

@Test
public void testTransformScriptValidation()
{
String assayName = "transformInvalid";
ReactAssayDesignerPage assayDesignerPage = _assayHelper.createAssayDesign("General", assayName);

// verify check for valid script engine defined for the file extension
assayDesignerPage.addTransformScript(JAVA_INVALID_TRANSFORM_SCRIPT, true, "Script engine for the extension '.java' has not been registered.");
assayDesignerPage.addTransformScript(JAVA_INVALID_TRANSFORM_SCRIPT, false, "Script engine for the extension '.java' has not been registered.");

// verify check for duplicate file in @scripts dir
assayDesignerPage.addTransformScript(R_TRANSFORM_ERROR_SCRIPT, true);
assayDesignerPage.addTransformScript(R_TRANSFORM_ERROR_SCRIPT, true, "File already exists: assayTransformError.R");

// verify that removing the transform script path does not remove file from file system
assayDesignerPage.removeTransformScript(R_TRANSFORM_ERROR_SCRIPT.getName());
WebDavPage webDavPage = WebDavPage.beginAt(this, getProjectName() + "/@scripts");
webDavPage.getFileBrowserHelper().waitForFileGridReady();
assertTrue("Transform script file not present in file system.", webDavPage.getFileBrowserHelper().getFileList(false).contains(R_TRANSFORM_ERROR_SCRIPT.getName()));

// verify file exists in @scripts dir via webdav page
goToProjectHome();
impersonateRole("Folder Administrator");
WebDavPage.beginAt(this, getProjectName() + "/@scripts");
waitForElement(Locators.labkeyErrorHeading.withText("/_webdav/" + getProjectName() + "/@scripts"));
stopImpersonatingHTTP();
}
}
10 changes: 6 additions & 4 deletions src/org/labkey/test/tests/elispotassay/ElispotAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public class ElispotAssayTest extends AbstractAssayTest
protected static final File TEST_ASSAY_ELISPOT_FILE5 = TestFileUtils.getSampleData("Elispot/AID_0161456 W8.txt");
protected static final File TEST_ASSAY_ELISPOT_FILE6 = TestFileUtils.getSampleData("Elispot/AID_TNTC.txt");

private static final File TRANSFORM_SCRIPT_FILE = TestFileUtils.getSampleData("qc/transform.jar");

private static final String PLATE_TEMPLATE_NAME = "ElispotAssayTest Template";

protected static final String TEST_ASSAY_FLUOROSPOT = "TestAssayFluorospot";
Expand Down Expand Up @@ -495,7 +497,7 @@ protected void runTransformTest()


ReactAssayDesignerPage assayDesigner = _assayHelper.clickEditAssayDesign();
assayDesigner.addTransformScript(TestFileUtils.getSampleData("qc/transform.jar"));
assayDesigner.addTransformScript(TRANSFORM_SCRIPT_FILE, true);
assayDesigner.clickFinish();
DataRegionTable.DataRegion(getDriver()).withName("Runs").waitFor();

Expand Down Expand Up @@ -525,9 +527,9 @@ protected void removeTransformScript()
{
clickProject(TEST_ASSAY_PRJ_ELISPOT);
clickAndWait(Locator.linkWithText(TEST_ASSAY_ELISPOT));
ReactAssayDesignerPage assayDesignerPage = _assayHelper.clickEditAssayDesign();
waitAndClick(Locator.tagWithClass("i", "container--removal-icon")); // TODO add a specific class to the transform script removal icon
assayDesignerPage.clickFinish();
_assayHelper.clickEditAssayDesign()
.removeTransformScript(TRANSFORM_SCRIPT_FILE.getName())
.clickFinish();
DataRegionTable.DataRegion(getDriver()).withName("Runs").waitFor();
}

Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/tests/nab/NabAssayTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ protected void runTransformTest()
clickAndWait(Locator.linkWithText(TEST_ASSAY_NAB));

_assayHelper.clickEditAssayDesign()
.addTransformScript(TestFileUtils.getSampleData("qc/transform.jar"))
.addTransformScript(TestFileUtils.getSampleData("qc/transform.jar"), true)
.clickFinish();

navigateToFolder(TEST_ASSAY_PRJ_NAB, TEST_ASSAY_FLDR_NAB);
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/tests/viability/ViabilityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected void runTransformTest()
clickAndWait(Locator.linkWithText(getAssayName()));
ReactAssayDesignerPage assayDesigner = _assayHelper.clickEditAssayDesign(true);

assayDesigner.addTransformScript(TestFileUtils.getSampleData("qc/transform.jar"));
assayDesigner.addTransformScript(TestFileUtils.getSampleData("qc/transform.jar"), true);
assayDesigner.clickFinish();

final String runName = "transformed assayId";
Expand Down
7 changes: 6 additions & 1 deletion src/org/labkey/test/util/FileBrowserHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,12 @@ public void refreshFileList()

public List<String> getFileList()
{
return getTexts(Locators.gridRow().childTag("td").position(3).findElements(getDriver()));
return getFileList(true);
}

public List<String> getFileList(boolean hasCheckboxColumn)
{
return getTexts(Locators.gridRow().childTag("td").position(hasCheckboxColumn ? 3 : 2).findElements(getDriver()));
}

public void createFolder(String folderName)
Expand Down