Skip to content

Commit 016020f

Browse files
Merge 26.3 to 26.4
2 parents c6230ab + a9b1c39 commit 016020f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

src/org/labkey/test/tests/list/ListTest.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,52 @@ public void doRenameFieldsTest()
14031403
assertTextBefore(newFieldName, origFieldName);
14041404
}
14051405

1406+
1407+
@Test
1408+
public void requiredFieldsTest()
1409+
{
1410+
log("Test changing required property of field");
1411+
String listName = "requiredColList";
1412+
String fieldA = "c$a";
1413+
String fieldB = "c_b";
1414+
1415+
_listHelper.createList(PROJECT_VERIFY, listName, "key",
1416+
new FieldDefinition(fieldA, ColumnType.String).setDescription("first column").setRequired(false),
1417+
new FieldDefinition(fieldB, ColumnType.String).setDescription("second column").setRequired(false)
1418+
);
1419+
1420+
// insert a row with a NULL value and NON-NULL value
1421+
Map<String, String> row = new HashMap<>();
1422+
row.put(fieldA, "not null");
1423+
row.put(fieldB, "");
1424+
_listHelper.insertNewRow(row, false);
1425+
row.put(fieldA, "still not null");
1426+
row.put(fieldB, "also not null");
1427+
_listHelper.insertNewRow(row, false);
1428+
1429+
// fieldA can be set to required==true
1430+
EditListDefinitionPage listDefinitionPage = _listHelper.goToEditDesign(listName);
1431+
listDefinitionPage.getFieldsPanel()
1432+
.getField(fieldA)
1433+
.setRequiredField(true);
1434+
listDefinitionPage.clickSave();
1435+
1436+
// fieldB can not be set to required==true
1437+
listDefinitionPage = _listHelper.goToEditDesign(listName);
1438+
listDefinitionPage.getFieldsPanel()
1439+
.getField(fieldB)
1440+
.setRequiredField(true);
1441+
List<String> errors = listDefinitionPage.clickSaveExpectingErrors();
1442+
assertEquals(2, errors.size());
1443+
assertEquals("The property \"" + fieldB + "\" cannot be required when it contains rows with blank values.", errors.get(0));
1444+
assertEquals("Please correct errors in " + listName + " before saving.", errors.get(1));
1445+
1446+
goToProjectHome();
1447+
clickAndWait(Locator.linkWithText(listName));
1448+
_listHelper.deleteList();
1449+
}
1450+
1451+
14061452
@Test
14071453
public void exportPhiFileColumn() throws Exception
14081454
{

0 commit comments

Comments
 (0)