Skip to content

Commit 9a63dde

Browse files
authored
GitHub Issue #688: Sample's Created By and Modified By fields do not resolve correctly when added to assay results grid if sample lookup is set to a specific sample type (#7564)
- use schema getTable() for materialIdForeignKey - add test case to AssayTest
1 parent 231fba3 commit 9a63dde

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

api/src/org/labkey/api/exp/query/SamplesSchema.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,17 @@ public ForeignKey materialIdForeignKey(@Nullable final ExpSampleType st, @Nullab
260260

261261
private TableInfo createLookupTableInfo()
262262
{
263+
// Hack to support lookup via RowId or Name
264+
if (domainProperty != null && domainProperty.getPropertyType().getJdbcType().isText())
265+
_columnName = "Name";
266+
267+
// GitHub Issue #688
268+
if (st != null)
269+
return getTable(tableName, getLookupContainerFilter());
270+
263271
ExpMaterialTable ret = ExperimentService.get().createMaterialTable(SamplesSchema.this, getLookupContainerFilter(), st);
264272
ret.populate();
265273
ret.overlayMetadata(ret.getPublicName(), SamplesSchema.this, new ArrayList<>());
266-
if (domainProperty != null && domainProperty.getPropertyType().getJdbcType().isText())
267-
{
268-
// Hack to support lookup via RowId or Name
269-
_columnName = "Name";
270-
}
271274
ret.setLocked(true);
272275
return ret;
273276
}

study/test/src/org/labkey/test/tests/study/AssayTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ public void testSampleFieldUpdate()
279279
clickAndWait(Locator.linkWithText("view results"));
280280
assertElementPresent("Sample lookup failed for: OS_1", new Locator.LinkLocator("OS_1"), 1);
281281

282-
283282
log("Edit assay design and change Sample field to point to created Sample Type");
284283
goToManageAssays();
285284
clickAndWait(Locator.LinkLocator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
@@ -294,10 +293,21 @@ public void testSampleFieldUpdate()
294293
importAssayData(SAMPLE_FIELD_TEST_ASSAY, TEST_RUN2, "SampleField\nS_1");
295294
goToManageAssays().clickAndWait(Locator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
296295
clickAndWait(Locator.linkWithText("view results"));
297-
// assertElementPresent("Sample lookup failed for: OS_1", new Locator.LinkLocator("OS_1"), 1); //TODO this becomes the RowId "<123>" after change. Issue #40047
298-
296+
DataRegionTable table = new DataRegionTable("Data", getDriver());
297+
List<String> sampleFieldValues = table.getColumnDataAsText("SampleField");
298+
assertTrue("First sample should not resolve to sample type", sampleFieldValues.get(0).startsWith("<"));
299+
assertEquals("Second sample should resolve to sample type", "S_1", sampleFieldValues.get(1));
299300
assertElementPresent("Sample lookup failed for: S_1", new Locator.LinkLocator("S_1"), 1);
300301

302+
log("GitHub Issue #688: verify sample lookup to createdBy");
303+
_customizeViewsHelper.openCustomizeViewPanel();
304+
_customizeViewsHelper.addColumn("SampleField/CreatedBy");
305+
_customizeViewsHelper.applyCustomView();
306+
table = new DataRegionTable("Data", getDriver());
307+
List<String> createdByValues = table.getColumnDataAsText("SampleField/CreatedBy");
308+
assertEquals("First sample should not have a createdBy since it doesn't resolve", " ", createdByValues.get(0));
309+
assertEquals("Second sample should have a createdBy since it resolves to a sample type", getCurrentUserName(), createdByValues.get(1));
310+
301311
log("Edit assay design and change Sample field to point back to 'All Samples'");
302312
goToManageAssays();
303313
clickAndWait(Locator.LinkLocator.linkWithText(SAMPLE_FIELD_TEST_ASSAY));
@@ -319,6 +329,10 @@ public void testSampleFieldUpdate()
319329
assertElementPresent("Sample lookup failed for: S_2", new Locator.LinkLocator("S_2"), 1);
320330
assertElementPresent("Sample lookup failed for: OS_2", new Locator.LinkLocator("OS_2"), 1);
321331

332+
log("GitHub Issue #688: verify sample lookup to createdBy");
333+
table = new DataRegionTable("Data", getDriver());
334+
for (int i = 0; i < table.getDataRowCount(); i++)
335+
assertEquals("Row " + i + " should have current user as createdBy since they all resolve to samples", getCurrentUserName(), table.getDataAsText(i, "SampleField/CreatedBy"));
322336
}
323337

324338
private void importAssayData(String assayName, String runName, String runDataStr)

0 commit comments

Comments
 (0)