From ae521afc24ac90e9b0194eae2af9f9a5094273e7 Mon Sep 17 00:00:00 2001
From: labkey-susanh
Date: Mon, 5 Oct 2026 10:04:29 -0700
Subject: [PATCH 1/3] GH Issue 980: Remove deprecated UI for deriving samples
in LKS interface
---
.../SampleTypeFolderExportImportTest.java | 12 +-
.../test/tests/SampleTypeLimitsTest.java | 74 ++---
.../test/tests/SampleTypeLineageTest.java | 313 +++---------------
.../test/tests/SampleTypeLinkToStudyTest.java | 43 +--
.../tests/SampleTypeNameExpressionTest.java | 56 +---
5 files changed, 103 insertions(+), 395 deletions(-)
diff --git a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
index eaef546e67..907b5f8b44 100644
--- a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
+++ b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
@@ -46,7 +46,6 @@
import org.labkey.test.util.DataRegionTable;
import org.labkey.test.util.EscapeUtil;
import org.labkey.test.util.LogMethod;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
@@ -102,15 +101,8 @@ public BrowserType bestBrowser()
protected void doCleanup(boolean afterTest)
{
super.doCleanup(afterTest);
- if (afterTest)
- {
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
- }
- else {
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
- SampleTypeFolderExportImportTest init = getCurrentTest();
- init.doSetup();
- }
+ SampleTypeFolderExportImportTest init = getCurrentTest();
+ init.doSetup();
}
private void doSetup()
diff --git a/src/org/labkey/test/tests/SampleTypeLimitsTest.java b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
index 4933febe16..c29d3dc43b 100644
--- a/src/org/labkey/test/tests/SampleTypeLimitsTest.java
+++ b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
@@ -36,10 +36,10 @@
import org.labkey.test.params.list.ListDefinition;
import org.labkey.test.params.list.VarListDefinition;
import org.labkey.test.util.DataRegionTable;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
+import org.labkey.test.util.query.QueryApiHelper;
import java.io.IOException;
import java.util.Arrays;
@@ -118,13 +118,6 @@ private void doSetup()
}
}
- @Override
- protected void doCleanup(boolean afterTest)
- {
- super.doCleanup(afterTest);
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
- }
-
@Test
public void testStringLookupFields() throws IOException, CommandException
{
@@ -203,48 +196,55 @@ private void insertSampleTypeRow(String regionName, String rowValue)
@Test
public void testDeriveSamplesLookupFields() throws IOException, CommandException
{
- goToProjectHome();
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
-
log("Create sample type with lookup field to " + SAMPLE_TYPE_NAME);
String sampleTypeName = "SampleTypeWithLookup";
- SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
- SampleTypeDefinition definition = new SampleTypeDefinition(sampleTypeName);
- definition.addField(new FieldDefinition("label", FieldDefinition.ColumnType.String));
- definition.addField(new FieldDefinition("lookUpField",
- new FieldDefinition.LookupInfo(null, "exp.materials", "10000Samples")
- .setTableType(FieldDefinition.ColumnType.Integer))
- .setDescription("LookUp in same container with 10000 samples"));
- sampleHelper.createSampleType(definition);
- sampleHelper.goToSampleType(sampleTypeName);
+ new SampleTypeDefinition(sampleTypeName)
+ .addField(new FieldDefinition("label", FieldDefinition.ColumnType.String))
+ .addField(new FieldDefinition("lookUpField",
+ new FieldDefinition.LookupInfo(null, "exp.materials", SAMPLE_TYPE_NAME)
+ .setTableType(FieldDefinition.ColumnType.Integer))
+ .setDescription("LookUp in same container with 10000 samples"))
+ .create(createDefaultConnection(), getProjectName());
+ QueryApiHelper queryHelper = new QueryApiHelper(createDefaultConnection(), getProjectName(), "samples", sampleTypeName);
log("Insert one sample that we can use to derive from");
- insertSampleTypeRow("Material", "Test1");
+ queryHelper.insertRows(List.of(Map.of("Name", "Test1", "label", "Test1")));
+ String parentColumn = "MaterialInputs/" + sampleTypeName;
- log("Attempt Derive Samples with invalid lookup value");
- initDeriveSamplesForm(sampleTypeName, "Derivative1");
- verifyInvalidLookupSample("Output Sample 1_lookUpField", "Sample3", "Could not convert value 'Sample3' (String) for Integer field 'lookUpField'.");
+ log("Attempt to derive a sample with invalid lookup value");
+ try
+ {
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative1", "Sample3"), true);
+ fail("Deriving a sample with an invalid lookup value should fail");
+ }
+ catch (CommandException e)
+ {
+ checker().verifyTrue("Unexpected error for invalid lookup value: " + e.getMessage(), e.getMessage().contains("Sample3"));
+ }
- log("Insert Derive Samples with valid lookup display value");
- verifyValidLookupSample("Output Sample 1_lookUpField", "Sample2", "Sample2", "Material", true);
+ log("Derive a sample with valid lookup display value");
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative1", "Sample2"), true);
- log("Insert Derive Samples with valid lookup to sample RowId");
- initDeriveSamplesForm(sampleTypeName, "Derivative2");
+ log("Derive a sample with valid lookup to sample RowId");
SelectRowsCommand command = new SelectRowsCommand("samples", SAMPLE_TYPE_NAME);
command.setFilters(Arrays.asList(new Filter("Name", "Sample1")));
SelectRowsResponse response = command.execute(createDefaultConnection(), getProjectName());
- verifyValidLookupSample("Output Sample 1_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "Material", true);
+ queryHelper.importData(deriveSampleTsv(parentColumn, "Derivative2", response.getRows().getFirst().get("RowId").toString()), true);
+
+ log("Verify derived samples have the expected lookup values");
+ goToProjectHome();
+ SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
+ sampleHelper.goToSampleType(sampleTypeName);
+ DataRegionTable table = sampleHelper.getSamplesDataRegionTable();
+ checker().verifyEquals("Lookup field value is incorrect", "Sample2",
+ table.getDataAsText(table.getRowIndex("Name", "Derivative1"), "lookUpField"));
+ checker().verifyEquals("Lookup field value is incorrect", "Sample1",
+ table.getDataAsText(table.getRowIndex("Name", "Derivative2"), "lookUpField"));
}
- private void initDeriveSamplesForm(String sampleTypeName, String sampleName)
+ private String deriveSampleTsv(String parentColumn, String sampleName, String lookupValue)
{
- DataRegionTable samplesTable = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor();
- samplesTable.uncheckAllOnPage();
- samplesTable.checkCheckbox(0);
- samplesTable.clickHeaderButtonAndWait("Derive Samples");
- selectOptionByText(Locator.name("targetSampleTypeId"), sampleTypeName + " in /" + getProjectName());
- clickButton("Next");
- setFormElement(Locator.name("Output Sample 1_Name"), sampleName);
+ return "Name\t" + parentColumn + "\tlookUpField\n" + sampleName + "\tTest1\t" + lookupValue + "\n";
}
@Test
diff --git a/src/org/labkey/test/tests/SampleTypeLineageTest.java b/src/org/labkey/test/tests/SampleTypeLineageTest.java
index 47dcac6485..0bf71bb341 100644
--- a/src/org/labkey/test/tests/SampleTypeLineageTest.java
+++ b/src/org/labkey/test/tests/SampleTypeLineageTest.java
@@ -29,7 +29,6 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
-import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
import org.labkey.test.components.ext4.Window;
@@ -38,18 +37,17 @@
import org.labkey.test.params.experiment.DataClassDefinition;
import org.labkey.test.params.experiment.SampleTypeDefinition;
import org.labkey.test.util.DataRegionTable;
-import org.labkey.test.util.OptionalFeatureHelper;
import org.labkey.test.util.PortalHelper;
import org.labkey.test.util.SampleTypeHelper;
import org.labkey.test.util.TestDataGenerator;
+import org.labkey.test.util.exp.SampleTypeAPIHelper;
+import org.labkey.test.util.query.QueryApiHelper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -101,15 +99,6 @@ private void doSetup()
portalHelper.addWebPart("Sample Types");
portalHelper.exitAdminMode();
- OptionalFeatureHelper.setOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp", true);
- }
-
- @Override
- protected void doCleanup(boolean afterTest) throws TestTimeoutException
- {
- super.doCleanup(afterTest);
-
- OptionalFeatureHelper.resetOptionalFeature(createDefaultConnection(), "deriveSamplesNotInApp");
}
/**
@@ -215,7 +204,7 @@ public void testLineageWithParentInRootFolder()
}
@Test
- public void testSampleTypeAndLineageInSubfolder()
+ public void testSampleTypeAndLineageInSubfolder() throws IOException, CommandException
{
/*
This test will create a sample type named "ParentFolder_SampleType" in the root folder.
@@ -270,67 +259,24 @@ at ParentFolder_SampleType in the sub folder it should see one sample (the deriv
checker().wrapAssertion(()->assertTextNotPresent(parentFolderSampleType));
log("Derive two samples from the samples already present in this sample type (SubFolder_SampleType).");
- clickFolder(SUB_FOLDER_NAME);
- checker().wrapAssertion(()->assertTextPresent(subFolderSampleType, parentFolderSampleType));
-
- clickAndWait(Locator.linkWithText(subFolderSampleType));
- checkCheckbox(Locator.name(".toggle"));
- clickButton("Derive Samples");
- waitForElement(Locator.name("inputRole0"));
-
- selectOptionByText(Locator.name("inputRole0"), "Add a new role...");
- setFormElement(Locator.id("customRole0"), "FirstRole");
- selectOptionByText(Locator.name("inputRole1"), "Add a new role...");
- setFormElement(Locator.id("customRole1"), "SecondRole");
- selectOptionByText(Locator.name("inputRole2"), "Add a new role...");
- setFormElement(Locator.id("customRole2"), "ThirdRole");
- selectOptionByText(Locator.name("inputRole3"), "Add a new role...");
- setFormElement(Locator.id("customRole3"), "FourthRole");
- selectOptionByText(Locator.name("outputCount"), "2");
- selectOptionByText(Locator.name("targetSampleTypeId"), subFolderSampleType + " in /" + getProjectName() + "/" + SUB_FOLDER_NAME);
- clickButton("Next");
-
- setFormElement(Locator.name("Output Sample 1_Name"), "SampleSetBVT15");
- setFormElement(Locator.name("Output Sample 2_Name"), "SampleSetBVT16");
- checkCheckbox(Locator.name("outputSample1_IntColFolderCheckBox"));
- setFormElement(Locator.name("Output Sample 1_IntCol-Folder"), "500a");
- setFormElement(Locator.name("Output Sample 1_StringCol-Folder"), "firstOutput");
- setFormElement(Locator.name("Output Sample 2_StringCol-Folder"), "secondOutput");
- clickButton("Submit");
-
- log("Do a simple check that data validation works.");
- checker().verifyTrue("Expected error message '(String) for Integer field' is not present.",
- isTextPresent("(String) for Integer field"));
- checkCheckbox(Locator.name("outputSample1_IntColFolderCheckBox"));
- setFormElement(Locator.name("Output Sample 1_IntCol-Folder"), "500");
- clickButton("Submit");
-
- clickAndWait(Locator.linkContainingText("Derive 2 samples"));
- clickAndWait(Locator.linkContainingText("Text View"));
- assertTextPresent("FirstRole", "SecondRole", "ThirdRole", "FourthRole");
-
- log("Select one of these new derived samples and derive a sample from it");
- log("But put this new derived sample in the sample type created in the parent folder (ParentFolder_SampleType)");
- clickAndWait(Locator.linkContainingText("16"));
- clickAndWait(Locator.linkContainingText("derive samples from this sample"));
-
- selectOptionByText(Locator.name("inputRole0"), "FirstRole");
- selectOptionByText(Locator.name("targetSampleTypeId"), parentFolderSampleType + " in /" + getProjectName());
- clickButton("Next");
-
+ String subFolderPath = getProjectName() + "/" + SUB_FOLDER_NAME;
+ String grandparents = "SampleSetBVT11,SampleSetBVT4,SampleSetBVT12,SampleSetBVT13,SampleSetBVT14";
+ new QueryApiHelper(createDefaultConnection(), subFolderPath, "samples", subFolderSampleType)
+ .insertRows(List.of(
+ Map.of("Name", "SampleSetBVT15", "IntCol-Folder", 500, "StringCol-Folder", "firstOutput",
+ "MaterialInputs/" + subFolderSampleType, grandparents),
+ Map.of("Name", "SampleSetBVT16", "StringCol-Folder", "secondOutput",
+ "MaterialInputs/" + subFolderSampleType, grandparents)));
+
+ log("Derive a sample from one of these new derived samples but put it in the sample type created in the parent folder (ParentFolder_SampleType)");
String derivedSampleName = "Only_In_Sub_Folder";
- setFormElement(Locator.name("Output Sample 1_Name"), derivedSampleName);
- setFormElement(Locator.name("Output Sample 1_IntCol"), "600");
- setFormElement(Locator.name("Output Sample 1_StringCol"), "String");
- setFormElement(Locator.name("Output Sample 1_DateCol"), "BadDate");
- uncheckCheckbox(Locator.name("Output Sample 1_BoolCol"));
- clickButton("Submit");
-
- log("Again check that data validation works as expected.");
- checker().verifyTrue("Expected error message 'is not a valid Date' is not present.",
- isTextPresent(getConversionErrorMessage("BadDate", "DateCol", Date.class)));
- setFormElement(Locator.name("Output Sample 1_DateCol"), "1/1/2007");
- clickButton("Submit");
+ new QueryApiHelper(createDefaultConnection(), subFolderPath, "samples", parentFolderSampleType)
+ .insertRows(List.of(Map.of("Name", derivedSampleName, "IntCol", 600, "StringCol", "String",
+ "DateCol", "1/1/2007", "BoolCol", false,
+ "MaterialInputs/" + subFolderSampleType, "SampleSetBVT16")));
+
+ Integer derivedRowId = SampleTypeAPIHelper.getRowIdsForSamples(subFolderPath, parentFolderSampleType, List.of(derivedSampleName)).get(derivedSampleName);
+ beginAt(WebTestHelper.buildURL("experiment", subFolderPath, "showMaterial", Map.of("rowId", derivedRowId)));
log("Check that the correct sample id is shown as the parent.");
checker().verifyTrue("Link to parent sample not present.",
@@ -353,10 +299,7 @@ at ParentFolder_SampleType in the sub folder it should see one sample (the deriv
isElementPresent(Locator.linkWithText("Derive sample from SampleSetBVT16")));
checker().verifyTrue("Expected run text is not present.",
- isElementPresent(
- Locator.linkWithText("Derive 2 samples from SampleSetBVT11, SampleSetBVT12, SampleSetBVT13, SampleSetBVT14, SampleSetBVT4")
- )
- );
+ isElementPresent(Locator.linkContainingText("Derive 2 samples from ")));
log("Go to the 'SubFolder_SampleType' and make sure the expected data is there.");
clickFolder(SUB_FOLDER_NAME);
@@ -600,163 +543,6 @@ public void testDeriveSampleByImport()
assertNotEquals("RowD should not equal C", rowD.get("Run"), rowC.get("Run"));
}
- @Test
- public void testDeriveSampleByUI() throws CommandException, IOException
- {
- String sampleTypeName= "LineageUI_01";
- String namePrefix = "SampleUI-";
- int newSampleIndex = 6;
-
- goToProjectHome();
-
- log("Create a simple sample type with some samples.");
- final TestDataGenerator dgen = new SampleTypeDefinition(sampleTypeName)
- .create(createDefaultConnection(), getProjectName());
-
- for(int i = 1; i < newSampleIndex; i++)
- {
- Map sampleData = new HashMap<>();
- sampleData.put("name", namePrefix + i);
- dgen.addCustomRow(sampleData);
- }
-
- dgen.insertRows(createDefaultConnection(), dgen.getRows());
- // Refresh the page so the new sample type shows up in the UI.
- refresh();
- waitAndClickAndWait(Locator.linkWithText(sampleTypeName));
-
- log("Go to the first samples detail page and derive a sample from it.");
-
- String parentSample = namePrefix + "1";
- log(String.format("Using sample named '%s' as the parent.", parentSample));
-
- waitAndClickAndWait(Locator.linkWithText(parentSample));
-
- waitAndClickAndWait(Locator.linkWithText("derive samples from this sample"));
-
- log("Nothing fancy just going to create a single derived sample in the same sample type.");
- waitAndClickAndWait(Locator.lkButton("Next"));
- Locator nameTxtbox = Locator.inputByNameContaining("_Name");
- waitForElement(nameTxtbox);
-
- String newSampleName = namePrefix + newSampleIndex;
- log(String.format("The new sample will be named '%s' and it shall go forth upon the land.", newSampleName));
-
- setFormElement(nameTxtbox, newSampleName);
- clickAndWait(Locator.lkButton("Submit"));
-
- // Increment the index.
- newSampleIndex++;
-
- log(String.format("Check that '%s' is shown as the parent.", parentSample));
- checkRowsInDataRegion("parentMaterials", "Name", List.of(parentSample));
-
- log(String.format("Go to the detail page for '%s' and verify it has a child.", parentSample));
- clickAndWait(Locator.linkWithText(parentSample));
- checkRowsInDataRegion("childMaterials", "Name", List.of(newSampleName));
-
- log("For the parent also verify that the run column (for the child sample) is populated as expected.");
- String runTextStrFormat = "Derive sample from %s";
- checkRowsInDataRegion("childMaterials", "Run", List.of(String.format(runTextStrFormat, parentSample)));
-
- log("Go back to the sample type page and select several samples from the grid and derive a sample from them.");
- goToProjectHome();
- SampleTypeHelper sampleHelper = new SampleTypeHelper(this);
-
- sampleHelper.goToSampleType(sampleTypeName);
- DataRegionTable drt = sampleHelper.getSamplesDataRegionTable();
-
- List parents = Arrays.asList(namePrefix + "2", namePrefix + "3", namePrefix + "4");
- log(String.format("Using samples '%s' as the parents.", parents));
-
- for(String parent : parents)
- {
- int index = drt.getRowIndex("Name", parent);
- drt.checkCheckbox(index);
- }
-
- drt.clickHeaderButtonAndWait("Derive Samples");
- log("Again, nothing fancy just going to create a single derived sample.");
- waitAndClickAndWait(Locator.lkButton("Next"));
- nameTxtbox = Locator.inputByNameContaining("_Name");
- waitForElement(nameTxtbox);
-
- newSampleName = namePrefix + newSampleIndex;
- log(String.format("The new sample will be named '%s' and it will go to sea.", newSampleName));
-
- setFormElement(nameTxtbox, newSampleName);
- clickAndWait(Locator.lkButton("Submit"));
-
- // Increment the index.
- newSampleIndex++;
-
- log("Check that the expected samples are shown as the parents of this new sample.");
- checkRowsInDataRegion("parentMaterials", "Name", parents);
-
- log("Go look at each one of the parents and make sure they have the new sample as a child and the run column is correct.");
-
- String parentListUI = parents.get(0) + ", " + parents.get(1) + ", " + parents.get(2);
- String runTextUI = String.format(runTextStrFormat, parentListUI);
-
- for(String parent : parents)
- {
- // A link to the sample type should be visible on this page, use it to go back to the sample type page.
- clickAndWait(Locator.linkWithText(sampleTypeName));
- clickAndWait(Locator.linkWithText(parent));
- checkRowsInDataRegion("childMaterials", "Name", List.of(newSampleName));
- checkRowsInDataRegion("childMaterials", "Run", List.of(runTextUI));
- }
-
- log("Finally derive a sample from a sample that was itself also derived.");
-
- clickAndWait(Locator.linkWithText(sampleTypeName));
-
- log("Make the parent sample the same sample that was just created.");
- parentSample = newSampleName;
- log(String.format("Using sample named '%s' as the parent.", parentSample));
-
- waitAndClickAndWait(Locator.linkWithText(parentSample));
-
- waitAndClickAndWait(Locator.linkWithText("derive samples from this sample"));
-
- log("Again just create a single derived sample.");
- waitAndClickAndWait(Locator.lkButton("Next"));
- nameTxtbox = Locator.inputByNameContaining("_Name");
- waitForElement(nameTxtbox);
-
- newSampleName = namePrefix + newSampleIndex;
- log(String.format("The new sample will be named '%s' and this one was a failure to launch and never left home.", newSampleName));
-
- setFormElement(nameTxtbox, newSampleName);
- clickAndWait(Locator.lkButton("Submit"));
-
- List newParents = new ArrayList<>();
- newParents.add(parentSample);
- newParents.addAll(parents);
-
- log(String.format("Check that all samples '%s' are listed as parents.", newParents));
- checkRowsInDataRegion("parentMaterials", "Name", newParents);
-
- log("Also check that the run column for the parents are as expected.");
- checkRowsInDataRegion("parentMaterials", "Run", List.of(runTextUI, " ", " ", " "));
-
- log(String.format("Go to the 'derived' parent '%s' and verify it has '%s' as a child.", parentSample, newSampleName));
-
- clickAndWait(Locator.linkWithText(parentSample));
- checkRowsInDataRegion("childMaterials", "Name", List.of(newSampleName));
-
- log(String.format("Verify again that '%s' parents are still as expected.", parentSample));
- checkRowsInDataRegion("parentMaterials", "Name", parents);
-
- String grandParent = parents.getFirst();
- log(String.format("Select one of '%s' parents, '%s' and verify that it now has two children.", parentSample, grandParent));
-
- clickAndWait(Locator.linkWithText(grandParent));
- checkRowsInDataRegion("childMaterials", "Name", Arrays.asList(newSampleName, parentSample));
-
- log("Test complete.");
- }
-
private void checkRowsInDataRegion(String dataRegionName, String columnName, final List expectedValues)
{
DataRegionTable dataRegionTable = new DataRegionTable(dataRegionName, this);
@@ -1133,52 +919,31 @@ public void testDeleteSampleSources() throws CommandException, IOException
}
@Test
- public void testDeleteSamplesSomeWithDerivedSamples()
+ public void testDeleteSamplesSomeWithDerivedSamples() throws IOException, CommandException
{
final String SAMPLE_TYPE_NAME = "DeleteSamplesWithParents" + DOMAIN_TRICKY_CHARACTERS;
List parentSampleNames = Arrays.asList("P-1", "P-2", "P-3");
- List
* @throws Exception Can be thrown by test helper.
*/
@Test
- public void testDeriveSampleFromSampleDetailsPage() throws Exception
+ public void testDeriveSampleWithAncestorNameExpression() throws Exception
{
goToProjectHome();
@@ -979,32 +966,17 @@ public void testDeriveSampleFromSampleDetailsPage() throws Exception
private String deriveSample(String parentSampleName, String parentSampleType, String targetSampleType, Map setField) throws IOException, CommandException
{
- log(String.format("Go to the 'overview' page for sample '%s' in sample type '%s'", parentSampleName, parentSampleType));
- Integer sampleRowNum = SampleTypeAPIHelper.getRowIdsForSamples(getProjectName(), parentSampleType, Arrays.asList(parentSampleName)).get(parentSampleName);
-
- String url = WebTestHelper.buildRelativeUrl("experiment", getCurrentContainerPath(), "showMaterial", Map.of("rowId", sampleRowNum));
- beginAt(url);
-
- log("Derive a sample from this sample but give it no name. The name expression should be used to name the derived sample.");
-
- waitForElement(Locator.linkWithText("derive samples from this sample"));
-
- clickAndWait(Locator.linkWithText("derive samples from this sample"));
-
- selectOptionByText(Locator.name("targetSampleTypeId"), String.format("%s in /%s", targetSampleType, getProjectName()));
- clickButton("Next");
-
- String flagString = "";
- for(Map.Entry entry : setField.entrySet())
- {
- setFormElement(Locator.name(String.format("Output Sample 1_%s", entry.getKey())), entry.getValue());
- flagString = entry.getValue();
- }
- clickButton("Submit");
+ log(String.format("Derive a sample from '%s' in sample type '%s' but give it no name. The name expression should be used to name the derived sample.", parentSampleName, parentSampleType));
+ Map row = new HashMap<>(setField);
+ row.put("MaterialInputs/" + parentSampleType, parentSampleName);
+ String derivedSampleName = (String) new QueryApiHelper(createDefaultConnection(), getProjectName(), "samples", targetSampleType)
+ .insertRows(List.of(row)).getRows().getFirst().get("name");
- waitForElement(Locator.tagWithText("td", flagString));
+ log(String.format("Go to the 'overview' page for derived sample '%s'", derivedSampleName));
+ Integer sampleRowNum = SampleTypeAPIHelper.getRowIdsForSamples(getProjectName(), targetSampleType, List.of(derivedSampleName)).get(derivedSampleName);
+ beginAt(WebTestHelper.buildRelativeUrl("experiment", getCurrentContainerPath(), "showMaterial", Map.of("rowId", sampleRowNum)));
- return Locator.tagWithText("td", "Name:").followingSibling("td").findElement(getDriver()).getText();
+ return derivedSampleName;
}
/**
From ed26cd3aaf52c37c750d36f33bbe414a52efeeba Mon Sep 17 00:00:00 2001
From: labkey-susanh
Date: Mon, 5 Oct 2026 10:21:42 -0700
Subject: [PATCH 2/3] Remove actions and JSPs that are no longer used
---
.../test/tests/SampleTypeFolderExportImportTest.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
index 907b5f8b44..693118a774 100644
--- a/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
+++ b/src/org/labkey/test/tests/SampleTypeFolderExportImportTest.java
@@ -101,8 +101,11 @@ public BrowserType bestBrowser()
protected void doCleanup(boolean afterTest)
{
super.doCleanup(afterTest);
- SampleTypeFolderExportImportTest init = getCurrentTest();
- init.doSetup();
+ if (!afterTest)
+ {
+ SampleTypeFolderExportImportTest init = getCurrentTest();
+ init.doSetup();
+ }
}
private void doSetup()
From fd58014827a87065f1a89cb31dd20acce10b1a98 Mon Sep 17 00:00:00 2001
From: labkey-susanh
Date: Mon, 5 Oct 2026 16:26:26 -0700
Subject: [PATCH 3/3] Remove some unuseful parameters
---
.../test/tests/SampleTypeLimitsTest.java | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/org/labkey/test/tests/SampleTypeLimitsTest.java b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
index c29d3dc43b..d01630ab3e 100644
--- a/src/org/labkey/test/tests/SampleTypeLimitsTest.java
+++ b/src/org/labkey/test/tests/SampleTypeLimitsTest.java
@@ -15,7 +15,6 @@
*/
package org.labkey.test.tests;
-import org.jetbrains.annotations.Nullable;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -141,12 +140,12 @@ public void testStringLookupFields() throws IOException, CommandException
table.clickInsertNewRow();
setFormElement(Locator.name("quf_id"), "1");
setFormElement(Locator.name("quf_name"), "1");
- verifyInvalidLookupSample("quf_lookUpField", "Sample3", null);
+ verifyInvalidLookupSample("quf_lookUpField", "Sample3");
verifyValidLookupSample("quf_lookUpField", "Sample1");
log("Verifying editing list row with the sample display name");
table.clickEditRow("1");
- verifyInvalidLookupSample("quf_lookUpField", "Sample3", null);
+ verifyInvalidLookupSample("quf_lookUpField", "Sample3");
verifyValidLookupSample("quf_lookUpField", "Sample2");
log("Verifying editing list row with the sample RowId");
@@ -154,31 +153,28 @@ public void testStringLookupFields() throws IOException, CommandException
SelectRowsCommand command = new SelectRowsCommand("samples", SAMPLE_TYPE_NAME);
command.setFilters(Arrays.asList(new Filter("Name", "Sample1")));
SelectRowsResponse response = command.execute(createDefaultConnection(), getProjectName());
- verifyValidLookupSample("quf_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "query", false);
+ verifyValidLookupSample("quf_lookUpField", response.getRows().getFirst().get("RowId").toString(), "Sample1", "query");
}
- private void verifyInvalidLookupSample(String fieldName, String sampleValue, @Nullable String expectedErrorMsg)
+ private void verifyInvalidLookupSample(String fieldName, String sampleValue)
{
setFormElement(Locator.name(fieldName), sampleValue);
clickButton("Submit");
String errMsg = Locators.labkeyError.findElement(getDriver()).getText();
- assertEquals("Expected error is different", expectedErrorMsg == null ? "Could not convert value: " + sampleValue : expectedErrorMsg, errMsg);
+ assertEquals("Expected error is different", "Could not convert value: " + sampleValue, errMsg);
}
private void verifyValidLookupSample(String fieldName, String sampleValue)
{
- verifyValidLookupSample(fieldName, sampleValue, sampleValue, "query", false);
+ verifyValidLookupSample(fieldName, sampleValue, sampleValue, "query");
}
- private void verifyValidLookupSample(String fieldName, String sampleValue, String sampleDisplay, String dataRegionName, boolean navigateViaBreadcrumb)
+ private void verifyValidLookupSample(String fieldName, String sampleValue, String sampleDisplay, String dataRegionName)
{
setFormElement(Locator.name(fieldName), sampleValue);
clickButton("Submit");
- if (navigateViaBreadcrumb)
- clickAndWait(Locator.tagWithClass("ol", "breadcrumb").childTag("li").index(1).childTag("a"));
-
log("Verifying row is inserted correctly");
DataRegionTable table = DataRegionTable.DataRegion(getDriver()).withName(dataRegionName).waitFor();
assertEquals("Lookup field value is incorrect", sampleDisplay, table.getDataAsText(0, "lookUpField"));