View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.labs.kitchensink;
17  
18  import org.junit.Test;
19  
20  /**
21   * @author Kuali Rice Team (rice.collab@kuali.org)
22   */
23  
24  public class LabsValidationAft extends LabsKitchenSinkBase {
25  
26      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&formKey=3a7bea98-8033-4aab-9b02-23298a5aaa23&cacheKey=kowztgm0mjejnru33fel0cmdnd&pageId=UifCompView-Page3#UifCompView-Page3";
27  
28      @Override
29      protected String getBookmarkUrl() {
30          return BOOKMARK_URL;
31      }
32  
33  	@Override
34  	protected void navigate() throws Exception {
35  		navigateToKitchenSink("Validation");
36  	}
37  	
38  	@Test
39      public void testValidationBookmark() throws Exception {
40          testValidation();
41          passed();
42      }
43  
44      @Test
45      public void testValidationNav() throws Exception {
46          testValidation();
47          passed();
48      }
49      
50      protected void testValidation() throws InterruptedException 
51      {
52      	//Minmax length and value
53      	waitAndTypeByName("field9","a");
54      	waitAndTypeByName("field10","1");
55      	fireMouseOverEventByName("field9");
56      	assertTextPresent("  Please enter at least 2 characters.");
57      	waitAndTypeByName("field9","");
58      	fireMouseOverEventByName("field10");
59      	assertTextPresent("  Value must be greater than 2");
60      	waitAndTypeByName("field10","51");
61      	fireMouseOverEventByName("field10");
62      	assertTextPresent("  Value cannot be greater than 50");
63      	
64      	//Required Constraint
65      	assertElementPresentByXpath("//textarea[@name='field3' and @aria-required='true']");
66      	assertElementPresentByXpath("//input[@name='field4' and @aria-required='true']");
67      	assertElementPresentByXpath("//select[@name='field5' and @aria-required='true']");
68      	
69      	//PreRequisite constraint
70      	waitAndTypeByName("field6","a");
71          waitAndClickSaveByText();
72      	waitForElementPresentByXpath("//input[@name='field7' and @class='form-control input-sm uif-textControl dependsOn-field6 required error']");
73      	waitForElementPresentByXpath("//input[@name='field8' and @class='form-control input-sm uif-textControl dependsOn-field6 prConstraint-field81 required error']");
74      
75      	//Must Occur Constraints
76      	waitAndTypeByName("field14","a");
77      	fireMouseOverEventByName("field14");
78      	waitAndTypeByName("field18","a");
79      	assertTextPresent("  1-2 of the following must occur: (Field 1A) OR (Field 2A and Field 2B)");
80      	waitAndTypeByName("field15","a");
81      	waitAndTypeByName("field16","a");
82      	waitAndTypeByName("field17","a");
83      	waitAndTypeByName("field18","");
84      	fireMouseOverEventByName("field18");
85      	assertTextPresent("  The following must occur: (Field 3A) OR (Field 4A and Field 4B)");
86      	
87      	//Case constraint
88      	waitAndClickByXpath("//input[@name='field24' and @value='case1']");
89      	waitAndTypeByName("field25","");
90      	waitAndTypeByName("field26","");
91      	assertElementPresentByXpath("//input[@name='field25' and @class='form-control input-sm uif-textControl dependsOn-field24 required error']");
92      }
93  }