diff --git a/data/lists/BadSampleFieldLookup.fields.json b/data/lists/BadSampleFieldLookup.fields.json new file mode 100644 index 0000000000..3408cda101 --- /dev/null +++ b/data/lists/BadSampleFieldLookup.fields.json @@ -0,0 +1,147 @@ +[ + { + "conceptURI": "http://www.labkey.org/types#autoInt", + "conditionalFormats": [], + "defaultScale": "LINEAR", + "defaultValueType": "FIXED_EDITABLE", + "defaultValue": null, + "defaultDisplayValue": "[none]", + "description": null, + "dimension": false, + "excludeFromShifting": false, + "filterCriteria": [], + "format": null, + "hidden": false, + "importAliases": null, + "label": null, + "lookupContainer": null, + "lookupQuery": null, + "lookupSchema": null, + "measure": false, + "mvEnabled": false, + "name": "Key", + "PHI": "NotPHI", + "propertyId": 1331387, + "propertyURI": "urn:lsid:labkey.com:IntList.Folder-2:1737#Key", + "propertyValidators": [], + "rangeURI": "http://www.w3.org/2001/XMLSchema#int", + "recommendedVariable": false, + "required": true, + "scale": 4000, + "URL": null, + "shownInDetailsView": true, + "shownInInsertView": true, + "shownInUpdateView": true, + "isPrimaryKey": true, + "lockType": "PKLocked", + "valueExpression": null, + "sourceOntology": null, + "conceptSubtree": null, + "conceptLabelColumn": null, + "conceptImportColumn": null, + "principalConceptCode": null, + "derivationDataScope": null, + "scannable": false + }, + { + "conceptURI": "http://www.labkey.org/exp/xml#sample", + "conditionalFormats": [], + "defaultScale": "LINEAR", + "defaultValueType": "FIXED_EDITABLE", + "defaultValue": null, + "defaultDisplayValue": "[none]", + "description": null, + "dimension": true, + "excludeFromShifting": false, + "filterCriteria": [], + "format": null, + "hidden": false, + "importAliases": null, + "label": null, + "lookupContainer": null, + "lookupQuery": "Materials", + "lookupSchema": "exp", + "measure": false, + "mvEnabled": false, + "name": "AllSamples", + "PHI": "NotPHI", + "propertyId": 1331389, + "propertyURI": "urn:lsid:labkey.com:IntList.Folder-2:1737#asdf", + "propertyValidators": [ + { + "type": "Lookup", + "name": "Lookup Validator", + "properties": { + "failOnMatch": false + }, + "errorMessage": null, + "description": null, + "new": true, + "rowId": 19457, + "expression": null + } + ], + "rangeURI": "http://www.w3.org/2001/XMLSchema#int", + "recommendedVariable": false, + "required": false, + "scale": 4000, + "URL": null, + "shownInDetailsView": true, + "shownInInsertView": true, + "shownInUpdateView": true, + "isPrimaryKey": false, + "lockType": "NotLocked", + "valueExpression": null, + "sourceOntology": null, + "conceptSubtree": null, + "conceptLabelColumn": null, + "conceptImportColumn": null, + "principalConceptCode": null, + "derivationDataScope": null, + "scannable": false + }, + { + "conceptURI": "http://www.labkey.org/exp/xml#sample", + "conditionalFormats": [], + "defaultScale": "LINEAR", + "defaultValueType": "FIXED_EDITABLE", + "defaultValue": null, + "defaultDisplayValue": "[none]", + "description": null, + "dimension": true, + "excludeFromShifting": false, + "filterCriteria": [], + "format": null, + "hidden": false, + "importAliases": null, + "label": "Sample ID", + "lookupContainer": null, + "lookupQuery": "NoSuchSampleType", + "lookupSchema": "samples", + "measure": false, + "mvEnabled": true, + "name": "SampleID", + "PHI": "PHI", + "propertyId": 1331388, + "propertyURI": "urn:lsid:labkey.com:IntList.Folder-2:1737#SampleID", + "propertyValidators": [], + "rangeURI": "http://www.w3.org/2001/XMLSchema#int", + "recommendedVariable": false, + "required": false, + "scale": -10, + "URL": null, + "shownInDetailsView": false, + "shownInInsertView": true, + "shownInUpdateView": true, + "isPrimaryKey": false, + "lockType": "NotLocked", + "valueExpression": null, + "sourceOntology": null, + "conceptSubtree": null, + "conceptLabelColumn": null, + "conceptImportColumn": null, + "principalConceptCode": null, + "derivationDataScope": null, + "scannable": false + } +] \ No newline at end of file diff --git a/src/org/labkey/test/components/domain/AdvancedSettingsDialog.java b/src/org/labkey/test/components/domain/AdvancedSettingsDialog.java index b684d9eeab..6fc243a399 100644 --- a/src/org/labkey/test/components/domain/AdvancedSettingsDialog.java +++ b/src/org/labkey/test/components/domain/AdvancedSettingsDialog.java @@ -77,6 +77,11 @@ public AdvancedSettingsDialog showInDetailsView(boolean checked) } // default value options + public boolean isDefaultValueTypeVisible() + { + return elementCache().defaultTypeSelect.getWrappedElement().isDisplayed(); + } + public String getDefaultValueType() { return elementCache().defaultTypeSelect.getFirstSelectedOption().getText(); @@ -178,6 +183,11 @@ public AdvancedSettingsDialog setUniqueConstraint(boolean checked) return this; } + public boolean isMissingValuesVisible() + { + return elementCache().enableMissingValues.isDisplayed(); + } + public boolean missingValuesEnabled() { return elementCache().enableMissingValues.get(); diff --git a/src/org/labkey/test/tests/DomainDesignerTest.java b/src/org/labkey/test/tests/DomainDesignerTest.java index 28f09fcc25..b4a3b75fea 100644 --- a/src/org/labkey/test/tests/DomainDesignerTest.java +++ b/src/org/labkey/test/tests/DomainDesignerTest.java @@ -26,6 +26,7 @@ import org.labkey.test.BaseWebDriverTest; import org.labkey.test.Locator; import org.labkey.test.SortDirection; +import org.labkey.test.TestFileUtils; import org.labkey.test.TestTimeoutException; import org.labkey.test.categories.BVT; import org.labkey.test.components.DomainDesignerPage; @@ -40,10 +41,14 @@ import org.labkey.test.pages.experiment.CreateSampleTypePage; import org.labkey.test.pages.list.EditListDefinitionPage; import org.labkey.test.params.FieldDefinition; +import org.labkey.test.params.FieldInfo; +import org.labkey.test.params.experiment.SampleTypeDefinition; import org.labkey.test.util.AuditLogHelper; import org.labkey.test.util.DataRegionTable; +import org.labkey.test.util.DomainUtils; import org.labkey.test.util.PortalHelper; import org.labkey.test.util.TestDataGenerator; +import org.labkey.test.util.exp.SampleTypeAPIHelper; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -251,9 +256,9 @@ public void testDeleteDomainField() throws Exception @Test public void testInvalidLookupDomainField() throws IOException, CommandException { - String listName = "InvalidLookUpNameList"; + String listName = TestDataGenerator.randomDomainName("InvalidLookUpNameList", null, 10, DomainUtils.DomainKind.IntList); String editedListName = listName + "_edited"; - String sampleType = "TestSampleForInvalidLookupField"; + String sampleType = TestDataGenerator.randomDomainName("TestSampleForInvalidLookupField", DomainUtils.DomainKind.SampleSet); log("Creating a list used for look up"); _listHelper.createList(getProjectName(), listName, "Id"); @@ -282,7 +287,7 @@ public void testInvalidLookupDomainField() throws IOException, CommandException .clickSave(); AuditLogHelper.DetailedAuditEventRow expectedDomainEvent = new AuditLogHelper.DetailedAuditEventRow(null, listName, null, - "The name of the list domain 'InvalidLookUpNameList' was changed to 'InvalidLookUpNameList_edited'. The descriptor of domain InvalidLookUpNameList_edited was updated.", + "The name of the list domain '" + listName + "' was changed to '" + listName + "_edited'. The descriptor of domain " + listName + "_edited was updated.", "", null, null, "Name: " + listName + " > " + editedListName); boolean pass = _auditLogHelper.validateLastDomainAuditEvents(editedListName, getProjectName(), expectedDomainEvent, Collections.emptyMap()); checker().verifyTrue("The comment logged for the list renaming was not as expected", pass); @@ -296,18 +301,74 @@ public void testInvalidLookupDomainField() throws IOException, CommandException log("Verifying the error message"); domainDesignerPage = DomainDesignerPage.beginAt(this, getProjectName(), "exp.materials", sampleType); - domainDesignerPage.fieldsPanel().getField("lookUpField").detailsMessage(); + DomainFieldRow domainFieldRow = domainDesignerPage.fieldsPanel().getField("lookUpField"); + domainFieldRow.expand(); Assert.assertEquals("Missing invalid look up message", "Current Folder > lists > " + editedListName + " . Error: Lookup target table does not exist.", - domainDesignerPage.fieldsPanel().getField("lookUpField").detailsMessage()); + domainFieldRow.detailsMessage()); log("Updating valid value for lookup field value "); - domainDesignerPage.fieldsPanel().getField("lookUpField") - .expand() - .setFromTargetTable("anotherList (Integer)") + domainFieldRow.setFromTargetTable("anotherList (Integer)") .collapse(); domainDesignerPage.clickFinish(); } + @Test // GitHub Issue 788 + public void testInvalidSampleFieldFromDelete() throws Exception + { + String listName = TestDataGenerator.randomDomainName("Sample Lookups List", DomainUtils.DomainKind.IntList); + String listKey = TestDataGenerator.randomFieldName("Id", null, 10, null, DomainUtils.DomainKind.IntList); + String sampleType1 = TestDataGenerator.randomDomainName("Sample Type 1"); + String sampleType2 = TestDataGenerator.randomDomainName("Sample Type 2"); + SampleTypeAPIHelper.createEmptySampleType(getProjectName(), new SampleTypeDefinition(sampleType1)); + SampleTypeAPIHelper.createEmptySampleType(getProjectName(), new SampleTypeDefinition(sampleType2)); + + log("Create the list with 3 sample lookup fields"); + FieldInfo allSamplesField = FieldInfo.random("All Samples", FieldDefinition.ColumnType.Sample); + FieldInfo st1SamplesField = FieldInfo.random("Sample Type 1", FieldDefinition.ColumnType.Sample); + FieldInfo st2SamplesField = FieldInfo.random("Sample Type 2", FieldDefinition.ColumnType.Sample); + _listHelper.createList(getProjectName(), listName, listKey, + allSamplesField.getFieldDefinition(), st1SamplesField.getFieldDefinition(), st2SamplesField.getFieldDefinition()); + + log("Edit the list design so that the single sample type lookup fields are set"); + EditListDefinitionPage editListDefinitionPage = _listHelper.goToEditDesign(listName); + editListDefinitionPage.getFieldsPanel().getField(st1SamplesField.getName()).setSampleType(sampleType1); + editListDefinitionPage.getFieldsPanel().getField(st2SamplesField.getName()).setSampleType(sampleType2); + editListDefinitionPage.clickSave(); + + log("Verify the list field row details and dropdown selection for expanded field rows"); + editListDefinitionPage = _listHelper.goToEditDesign(listName); + validateListSampleLookupField(editListDefinitionPage, allSamplesField.getName(), "All Samples", "All Samples"); + validateListSampleLookupField(editListDefinitionPage, st1SamplesField.getName(), sampleType1, sampleType1); + validateListSampleLookupField(editListDefinitionPage, st2SamplesField.getName(), sampleType2, sampleType2); + + log("Delete sample type 2 and verify the sample lookup fields again"); + DomainUtils.ensureDeleted(getProjectName(), "samples", sampleType2); + editListDefinitionPage = _listHelper.goToEditDesign(listName); + validateListSampleLookupField(editListDefinitionPage, allSamplesField.getName(), "All Samples", "All Samples"); + validateListSampleLookupField(editListDefinitionPage, st1SamplesField.getName(), sampleType1, sampleType1); + validateListSampleLookupField(editListDefinitionPage, st2SamplesField.getName(), sampleType2 + " Error: Invalid sample type", ""); + } + + @Test // GitHub Issue 788 + public void testInvalidSampleFieldFromJSON() throws Exception + { + File jsonFile = TestFileUtils.getSampleData("lists/BadSampleFieldLookup.fields.json"); + String listName = TestDataGenerator.randomDomainName("Sample Fields List", DomainUtils.DomainKind.IntList); + EditListDefinitionPage listDefinitionPage = _listHelper.beginCreateList(getProjectName(), listName); + listDefinitionPage.getFieldsPanel().setInferFieldFile(jsonFile); + validateListSampleLookupField(listDefinitionPage, "AllSamples", "New Field. All Samples", "All Samples"); + validateListSampleLookupField(listDefinitionPage, "SampleID", "New Field. NoSuchSampleType Error: Invalid sample type", ""); + listDefinitionPage.clickCancel(); + } + + private void validateListSampleLookupField(EditListDefinitionPage definitionPage, String fieldName, String rowDetails, String lookupValue) + { + DomainFieldRow fieldRow = definitionPage.getFieldsPanel().getField(fieldName); + fieldRow.expand(); // so that we can get the full row details message + checker().verifyEquals("Sample field row details not as expected", rowDetails, fieldRow.detailsMessage()); + checker().verifyEquals("Sample lookup select option not as expected", lookupValue, fieldRow.getSampleType()); + } + @Test public void testAddDomainField() throws Exception {