|
48 | 48 | import org.labkey.test.params.FieldDefinition; |
49 | 49 | import org.labkey.test.params.FieldDefinition.ColumnType; |
50 | 50 | import org.labkey.test.params.FieldDefinition.LookupInfo; |
| 51 | +import org.labkey.test.params.FieldInfo; |
51 | 52 | import org.labkey.test.params.experiment.SampleTypeDefinition; |
52 | 53 | import org.labkey.test.tests.study.AssayTest; |
53 | 54 | import org.labkey.test.util.DataRegionExportHelper; |
54 | 55 | import org.labkey.test.util.DataRegionTable; |
| 56 | +import org.labkey.test.util.EscapeUtil; |
55 | 57 | import org.labkey.test.util.ExcelHelper; |
56 | 58 | import org.labkey.test.util.PortalHelper; |
57 | 59 | import org.labkey.test.util.SampleTypeHelper; |
|
80 | 82 | import static org.junit.Assert.assertNotEquals; |
81 | 83 | import static org.junit.Assert.assertNotNull; |
82 | 84 | import static org.junit.Assert.assertTrue; |
| 85 | +import static org.labkey.test.params.FieldDefinition.DOMAIN_TRICKY_CHARACTERS; |
83 | 86 | import static org.labkey.test.util.DataRegionTable.DataRegion; |
84 | 87 |
|
85 | 88 | @Category({Daily.class}) |
@@ -242,7 +245,47 @@ public void testCreateSampleTypeNoExpression() |
242 | 245 | sampleTypeHelper.verifyDataValues(data); |
243 | 246 | } |
244 | 247 |
|
245 | | - // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples |
| 248 | + // Issue 53313: LKS doesn't show Sample Type fields with special characters in Custom Properties |
| 249 | + @Test |
| 250 | + public void testCustomProperties() |
| 251 | + { |
| 252 | + final String sampleTypeName = "SampleTypeCustomProps" + DOMAIN_TRICKY_CHARACTERS; |
| 253 | + FieldInfo stringCol1 = new FieldInfo(TestDataGenerator.randomFieldName("StringColPlain"), ColumnType.String); |
| 254 | + FieldInfo stringCol2 = new FieldInfo(TestDataGenerator.randomFieldName("StringCol%"), ColumnType.String); |
| 255 | + // Used to make sure the details page shows properties with null values |
| 256 | + FieldInfo stringCol3 = new FieldInfo(TestDataGenerator.randomFieldName("StringColNull"), ColumnType.String); |
| 257 | + FieldInfo calcCol = new FieldInfo(TestDataGenerator.randomFieldName("CalcCol"), ColumnType.Calculation); |
| 258 | + final List<FieldDefinition> fields = List.of( |
| 259 | + stringCol1.getFieldDefinition(), |
| 260 | + stringCol2.getFieldDefinition(), |
| 261 | + stringCol3.getFieldDefinition(), |
| 262 | + calcCol.getFieldDefinition().setValueExpression(EscapeUtil.getSqlQuotedValue(stringCol1.getName()) + " || 'Concat'") |
| 263 | + ); |
| 264 | + |
| 265 | + SampleTypeDefinition sampleTypeDefinition = new SampleTypeDefinition(sampleTypeName).setFields(fields); |
| 266 | + |
| 267 | + SampleTypeAPIHelper.createEmptySampleType(getProjectName(), sampleTypeDefinition); |
| 268 | + |
| 269 | + log("Create a new sample type"); |
| 270 | + projectMenu().navigateToFolder(PROJECT_NAME, FOLDER_NAME); |
| 271 | + SampleTypeHelper sampleTypeHelper = new SampleTypeHelper(this); |
| 272 | + sampleTypeHelper.goToSampleType(sampleTypeName); |
| 273 | + |
| 274 | + log("Add a single row to the sample type, with trailing spaces"); |
| 275 | + Map<String, String> fieldMap = Map.of("Name", "CustomPropsSample", stringCol1.getName(), "PlainValue", stringCol2.getName(), "PercentValue"); |
| 276 | + sampleTypeHelper.insertRow(fieldMap); |
| 277 | + |
| 278 | + log("Verify custom properties, both name and values, are shown in both the grid and detail pages"); |
| 279 | + var dataRegion = DataRegionTable.DataRegion(getDriver()).withName("Material").waitFor(); |
| 280 | + checker().verifyEquals("Row data does not contain expected custom properties", "PlainValue", dataRegion.getDataAsText(0, stringCol1.getLabel())); |
| 281 | + checker().verifyEquals("Row data does not contain expected custom properties", "PercentValue", dataRegion.getDataAsText(0, stringCol2.getLabel())); |
| 282 | + checker().verifyEquals("Row data does not contain expected custom properties", " ", dataRegion.getDataAsText(0, stringCol3.getLabel())); |
| 283 | + checker().verifyEquals("Row data does not contain expected custom properties", "PlainValueConcat", dataRegion.getDataAsText(0, calcCol.getLabel())); |
| 284 | + clickAndWait(Locator.linkWithText("CustomPropsSample")); |
| 285 | + assertTextPresent(stringCol1.getLabel(), stringCol2.getLabel(), stringCol3.getLabel(), calcCol.getLabel(), "PlainValue", "PercentValue", "PlainValueConcat"); |
| 286 | + } |
| 287 | + |
| 288 | + // Issue 47280: LKSM: Trailing/Leading whitespace in Source name won't resolve when deriving samples |
246 | 289 | @Test |
247 | 290 | public void testImportSamplesWithTrailingSpace() |
248 | 291 | { |
|
0 commit comments