From d0af8ad735f2ac0b7a3abd3ba16384a930e7de6b Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Thu, 26 Jun 2025 14:00:14 -0700 Subject: [PATCH 1/4] Issue 53313: Fields with non alpha/numeric chars not shown in Custom Properties --- src/org/labkey/test/tests/SampleTypeTest.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/org/labkey/test/tests/SampleTypeTest.java b/src/org/labkey/test/tests/SampleTypeTest.java index 21b1637def..75441d34d4 100644 --- a/src/org/labkey/test/tests/SampleTypeTest.java +++ b/src/org/labkey/test/tests/SampleTypeTest.java @@ -79,6 +79,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS; import static org.labkey.test.util.DataRegionTable.DataRegion; @Category({Daily.class}) @@ -241,7 +242,36 @@ public void testCreateSampleTypeNoExpression() sampleTypeHelper.verifyDataValues(data); } - // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples + // Issue 53313: LKS doesn't show Sample Type fields with special characters in Custom Properties + @Test + public void testCustomProperties() + { + final String sampleTypeName = "SampleTypeCustomProps" + DOMAIN_TRICKY_CHARACTERS; + final List fields = List.of( + new FieldDefinition("StringColPlain", FieldDefinition.ColumnType.String), + new FieldDefinition("StringCol%", FieldDefinition.ColumnType.String), + new FieldDefinition("CalcCol", ColumnType.Calculation).setValueExpression("StringColPlain || 'Concat'")); + + SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName).setFields(fields); + + SampleTypeAPIHelper.createEmptySampleType(getProjectName(), sampleTypeDefinition); + + log("Create a new sample type"); + projectMenu().navigateToFolder(PROJECT_NAME, FOLDER_NAME); + SampleTypeHelper sampleTypeHelper = new SampleTypeHelper(this); + sampleTypeHelper.goToSampleType(sampleTypeName); + + log("Add a single row to the sample type, with trailing spaces"); + Map fieldMap = Map.of("Name", "CustomPropsSample", "StringColPlain", "PlainValue", "StringCol%", "PercentValue"); + sampleTypeHelper.insertRow(fieldMap); + + log("Verify custom properties, both name and values, are shown in both the grid and detail pages"); + assertTextPresent("String Col Plain", "String Col%", "Calc Col", "PlainValue", "PercentValue", "PlainValueConcat"); + clickAndWait(Locator.linkWithText("CustomPropsSample")); + assertTextPresent("String Col Plain", "String Col%", "Calc Col", "PlainValue", "PercentValue", "PlainValueConcat"); + } + + // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples @Test public void testImportSamplesWithTrailingSpace() { From 279d4935d1937665941e86c41dee547ee7ad59ec Mon Sep 17 00:00:00 2001 From: Josh Eckels Date: Fri, 27 Jun 2025 13:41:45 -0700 Subject: [PATCH 2/4] Update src/org/labkey/test/tests/SampleTypeTest.java Co-authored-by: Cory Nathe --- src/org/labkey/test/tests/SampleTypeTest.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/org/labkey/test/tests/SampleTypeTest.java b/src/org/labkey/test/tests/SampleTypeTest.java index 75441d34d4..ccbd5cb7a1 100644 --- a/src/org/labkey/test/tests/SampleTypeTest.java +++ b/src/org/labkey/test/tests/SampleTypeTest.java @@ -247,10 +247,14 @@ public void testCreateSampleTypeNoExpression() public void testCustomProperties() { final String sampleTypeName = "SampleTypeCustomProps" + DOMAIN_TRICKY_CHARACTERS; + FieldInfo stringCol1 = new FieldInfo(TestDataGenerator.randomFieldName("StringColPlain", "\""), ColumnType.String); + FieldInfo stringCol2 = new FieldInfo(TestDataGenerator.randomFieldName("StringCol%"), ColumnType.String); + FieldInfo calcCol = new FieldInfo(TestDataGenerator.randomFieldName("CalcCol"), ColumnType.Calculation); final List fields = List.of( - new FieldDefinition("StringColPlain", FieldDefinition.ColumnType.String), - new FieldDefinition("StringCol%", FieldDefinition.ColumnType.String), - new FieldDefinition("CalcCol", ColumnType.Calculation).setValueExpression("StringColPlain || 'Concat'")); + stringCol1.getFieldDefinition(), + stringCol2.getFieldDefinition(), + calcCol.getFieldDefinition().setValueExpression("\"" + stringCol1.getName() + "\" || 'Concat'") + ); SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName).setFields(fields); @@ -262,13 +266,16 @@ public void testCustomProperties() sampleTypeHelper.goToSampleType(sampleTypeName); log("Add a single row to the sample type, with trailing spaces"); - Map fieldMap = Map.of("Name", "CustomPropsSample", "StringColPlain", "PlainValue", "StringCol%", "PercentValue"); + Map fieldMap = Map.of("Name", "CustomPropsSample", stringCol1.getName(), "PlainValue", stringCol2.getName(), "PercentValue"); sampleTypeHelper.insertRow(fieldMap); log("Verify custom properties, both name and values, are shown in both the grid and detail pages"); - assertTextPresent("String Col Plain", "String Col%", "Calc Col", "PlainValue", "PercentValue", "PlainValueConcat"); + var dataRegion = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor(); + checker().verifyEquals("Row data does not contain expected custom properties", "PlainValue", dataRegion.getDataAsText(0, stringCol1.getLabel())); + checker().verifyEquals("Row data does not contain expected custom properties", "PercentValue", dataRegion.getDataAsText(0, stringCol2.getLabel())); + checker().verifyEquals("Row data does not contain expected custom properties", "PlainValueConcat", dataRegion.getDataAsText(0, calcCol.getLabel())); clickAndWait(Locator.linkWithText("CustomPropsSample")); - assertTextPresent("String Col Plain", "String Col%", "Calc Col", "PlainValue", "PercentValue", "PlainValueConcat"); + assertTextPresent(stringCol1.getLabel(), stringCol2.getLabel(), calcCol.getLabel(), "PlainValue", "PercentValue", "PlainValueConcat"); } // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples From 08328beaf7e44e416b598d01e945ad5033e33e48 Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Fri, 27 Jun 2025 14:13:06 -0700 Subject: [PATCH 3/4] Check null fields too --- src/org/labkey/test/tests/SampleTypeTest.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/org/labkey/test/tests/SampleTypeTest.java b/src/org/labkey/test/tests/SampleTypeTest.java index ccbd5cb7a1..c3b0d188e5 100644 --- a/src/org/labkey/test/tests/SampleTypeTest.java +++ b/src/org/labkey/test/tests/SampleTypeTest.java @@ -48,6 +48,7 @@ import org.labkey.test.params.FieldDefinition; import org.labkey.test.params.FieldDefinition.ColumnType; import org.labkey.test.params.FieldDefinition.LookupInfo; +import org.labkey.test.params.FieldInfo; import org.labkey.test.params.experiment.SampleTypeDefinition; import org.labkey.test.util.DataRegionExportHelper; import org.labkey.test.util.DataRegionTable; @@ -249,10 +250,13 @@ public void testCustomProperties() final String sampleTypeName = "SampleTypeCustomProps" + DOMAIN_TRICKY_CHARACTERS; FieldInfo stringCol1 = new FieldInfo(TestDataGenerator.randomFieldName("StringColPlain", "\""), ColumnType.String); FieldInfo stringCol2 = new FieldInfo(TestDataGenerator.randomFieldName("StringCol%"), ColumnType.String); + // Used to make sure the details page shows properties with null values + FieldInfo stringCol3 = new FieldInfo(TestDataGenerator.randomFieldName("StringColNull"), ColumnType.String); FieldInfo calcCol = new FieldInfo(TestDataGenerator.randomFieldName("CalcCol"), ColumnType.Calculation); final List fields = List.of( stringCol1.getFieldDefinition(), stringCol2.getFieldDefinition(), + stringCol3.getFieldDefinition(), calcCol.getFieldDefinition().setValueExpression("\"" + stringCol1.getName() + "\" || 'Concat'") ); @@ -273,9 +277,10 @@ public void testCustomProperties() var dataRegion = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor(); checker().verifyEquals("Row data does not contain expected custom properties", "PlainValue", dataRegion.getDataAsText(0, stringCol1.getLabel())); checker().verifyEquals("Row data does not contain expected custom properties", "PercentValue", dataRegion.getDataAsText(0, stringCol2.getLabel())); + checker().verifyEquals("Row data does not contain expected custom properties", " ", dataRegion.getDataAsText(0, stringCol3.getLabel())); checker().verifyEquals("Row data does not contain expected custom properties", "PlainValueConcat", dataRegion.getDataAsText(0, calcCol.getLabel())); clickAndWait(Locator.linkWithText("CustomPropsSample")); - assertTextPresent(stringCol1.getLabel(), stringCol2.getLabel(), calcCol.getLabel(), "PlainValue", "PercentValue", "PlainValueConcat"); + assertTextPresent(stringCol1.getLabel(), stringCol2.getLabel(), stringCol3.getLabel(), calcCol.getLabel(), "PlainValue", "PercentValue", "PlainValueConcat"); } // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples From 609d1b5fb819b7a9f0425f7d11e784c30932c9bd Mon Sep 17 00:00:00 2001 From: labkey-jeckels Date: Fri, 27 Jun 2025 14:27:26 -0700 Subject: [PATCH 4/4] Handle quotes too --- src/org/labkey/test/tests/SampleTypeTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/org/labkey/test/tests/SampleTypeTest.java b/src/org/labkey/test/tests/SampleTypeTest.java index c3b0d188e5..3c687fdaaf 100644 --- a/src/org/labkey/test/tests/SampleTypeTest.java +++ b/src/org/labkey/test/tests/SampleTypeTest.java @@ -52,6 +52,7 @@ import org.labkey.test.params.experiment.SampleTypeDefinition; import org.labkey.test.util.DataRegionExportHelper; import org.labkey.test.util.DataRegionTable; +import org.labkey.test.util.EscapeUtil; import org.labkey.test.util.ExcelHelper; import org.labkey.test.util.PortalHelper; import org.labkey.test.util.SampleTypeHelper; @@ -248,7 +249,7 @@ public void testCreateSampleTypeNoExpression() public void testCustomProperties() { final String sampleTypeName = "SampleTypeCustomProps" + DOMAIN_TRICKY_CHARACTERS; - FieldInfo stringCol1 = new FieldInfo(TestDataGenerator.randomFieldName("StringColPlain", "\""), ColumnType.String); + FieldInfo stringCol1 = new FieldInfo(TestDataGenerator.randomFieldName("StringColPlain"), ColumnType.String); FieldInfo stringCol2 = new FieldInfo(TestDataGenerator.randomFieldName("StringCol%"), ColumnType.String); // Used to make sure the details page shows properties with null values FieldInfo stringCol3 = new FieldInfo(TestDataGenerator.randomFieldName("StringColNull"), ColumnType.String); @@ -257,7 +258,7 @@ public void testCustomProperties() stringCol1.getFieldDefinition(), stringCol2.getFieldDefinition(), stringCol3.getFieldDefinition(), - calcCol.getFieldDefinition().setValueExpression("\"" + stringCol1.getName() + "\" || 'Concat'") + calcCol.getFieldDefinition().setValueExpression(EscapeUtil.getSqlQuotedValue(stringCol1.getName()) + " || 'Concat'") ); SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName).setFields(fields);