Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/org/labkey/test/tests/list/ListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,52 @@ public void doRenameFieldsTest()
assertTextBefore(newFieldName, origFieldName);
}


@Test
public void requiredFieldsTest()
{
log("Test changing required property of field");
String listName = "requiredColList";
String fieldA = "c$a";
String fieldB = "c_b";

_listHelper.createList(PROJECT_VERIFY, listName, "key",
new FieldDefinition(fieldA, ColumnType.String).setDescription("first column").setRequired(false),
new FieldDefinition(fieldB, ColumnType.String).setDescription("second column").setRequired(false)
);

// insert a row with a NULL value and NON-NULL value
Map<String, String> row = new HashMap<>();
row.put(fieldA, "not null");
row.put(fieldB, "");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a fieldC, that has a mixed value of empty and not empty, that also cannot be set to required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a second row to cover that makes sense.

_listHelper.insertNewRow(row, false);
row.put(fieldA, "still not null");
row.put(fieldB, "also not null");
_listHelper.insertNewRow(row, false);

// fieldA can be set to required==true
EditListDefinitionPage listDefinitionPage = _listHelper.goToEditDesign(listName);
listDefinitionPage.getFieldsPanel()
.getField(fieldA)
.setRequiredField(true);
listDefinitionPage.clickSave();

// fieldB can not be set to required==true
listDefinitionPage = _listHelper.goToEditDesign(listName);
listDefinitionPage.getFieldsPanel()
.getField(fieldB)
.setRequiredField(true);
List<String> errors = listDefinitionPage.clickSaveExpectingErrors();
assertEquals(2, errors.size());
assertEquals("The property \"" + fieldB + "\" cannot be required when it contains rows with blank values.", errors.get(0));
assertEquals("Please correct errors in " + listName + " before saving.", errors.get(1));

goToProjectHome();
clickAndWait(Locator.linkWithText(listName));
_listHelper.deleteList();
}


@Test
public void exportPhiFileColumn() throws Exception
{
Expand Down
Loading