@@ -1396,6 +1396,45 @@ public void doRenameFieldsTest()
13961396 assertTextBefore (newFieldName , origFieldName );
13971397 }
13981398
1399+
1400+ @ Test
1401+ public void requiredFieldsTest ()
1402+ {
1403+ log ("Test changing required property of field" );
1404+ String listName = "requiredColList" ;
1405+ String fieldA = "c$a" ;
1406+ String fieldB = "c_b" ;
1407+
1408+ _listHelper .createList (PROJECT_VERIFY , listName , "key" ,
1409+ new FieldDefinition (fieldA , ColumnType .String ).setDescription ("first column" ).setRequired (false ),
1410+ new FieldDefinition (fieldB , ColumnType .String ).setDescription ("second column" ).setRequired (false )
1411+ );
1412+
1413+ // insert a row with a NULL value and NON-NULL value
1414+ Map <String , String > row = new HashMap <>();
1415+ row .put (fieldA , "not null" );
1416+ row .put (fieldB , "" );
1417+ _listHelper .insertNewRow (row , false );
1418+
1419+ // fieldA can be set to required==true
1420+ EditListDefinitionPage listDefinitionPage = _listHelper .goToEditDesign (listName );
1421+ listDefinitionPage .getFieldsPanel ()
1422+ .getField (fieldA )
1423+ .setRequiredField (true );
1424+ listDefinitionPage .clickSave ();
1425+
1426+ // fieldB can not be set to required==true
1427+ listDefinitionPage = _listHelper .goToEditDesign (listName );
1428+ listDefinitionPage .getFieldsPanel ()
1429+ .getField (fieldB )
1430+ .setRequiredField (true );
1431+ List <String > errors = listDefinitionPage .clickSaveExpectingErrors ();
1432+ assertEquals (2 , errors .size ());
1433+ assertEquals ("The property \" " + fieldB + "\" cannot be required when it contains rows with blank values." , errors .get (0 ));
1434+ assertEquals ("Please correct errors in " + listName + " before saving." , errors .get (1 ));
1435+ }
1436+
1437+
13991438 @ Test
14001439 public void exportPhiFileColumn () throws Exception
14011440 {
0 commit comments