View Javadoc
1   /**
2    * Copyright 2005-2016 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  public class LabsValidationAft extends LabsKitchenSinkBase {
24  
25      /**
26       * /kr-krad/uicomponents?viewId=UifCompView&pageId=UifCompView-Page3#UifCompView-Page3
27       */
28      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&pageId=UifCompView-Page3#UifCompView-Page3";
29  
30      @Override
31      protected String getBookmarkUrl() {
32          return BOOKMARK_URL;
33      }
34  
35  	@Override
36  	protected void navigate() throws Exception {
37  		navigateToKitchenSink("Validation");
38  	}
39  	
40  	@Test
41      public void testValidationBookmark() throws Exception {
42          testValidation();
43          passed();
44      }
45  
46      @Test
47      public void testValidationNav() throws Exception {
48          testValidation();
49          passed();
50      }
51      
52      protected void testValidation() throws InterruptedException 
53      {
54      	//Minmax length and value
55      	waitAndTypeByName("field9","a");
56      	waitAndTypeByName("field10","1");
57      	fireMouseOverEventByName("field9");
58      	assertTextPresent("  Please enter at least 2 characters.");
59      	waitAndTypeByName("field9","");
60      	fireMouseOverEventByName("field10");
61      	assertTextPresent("  Value must be greater than 2");
62      	waitAndTypeByName("field10","51");
63          //need to change focus for error message to change
64          waitAndTypeByName("field9","");
65      	fireMouseOverEventByName("field10");
66      	assertTextPresent("  Value cannot be greater than 50");
67      	
68      	//Required Constraint
69      	assertElementPresentByXpath("//textarea[@name='field3' and @aria-required='true']");
70      	assertElementPresentByXpath("//input[@name='field4' and @aria-required='true']");
71      	assertElementPresentByXpath("//select[@name='field5' and @aria-required='true']");
72      	
73      	//PreRequisite constraint
74      	waitAndTypeByName("field6","a");
75          waitAndClickSaveByText();
76      	waitForElementPresentByXpath("//input[@name='field7' and @class='form-control input-sm uif-textControl dependsOn-field6 required error']");
77      	waitForElementPresentByXpath("//input[@name='field8' and @class='form-control input-sm uif-textControl dependsOn-field6 prConstraint-field81 required error']");
78      
79      	//Must Occur Constraints
80      	waitAndTypeByName("field14","a");
81      	fireMouseOverEventByName("field14");
82      	waitAndTypeByName("field18","a");
83      	assertTextPresent("  1-2 of the following must occur: (Field 1A) OR (Field 2A and Field 2B)");
84      	waitAndTypeByName("field15","a");
85      	waitAndTypeByName("field16","a");
86      	waitAndTypeByName("field17","a");
87      	waitAndTypeByName("field18","");
88      	fireMouseOverEventByName("field18");
89      	assertTextPresent("  The following must occur: (Field 3A) OR (Field 4A and Field 4B)");
90      	
91      	//Case constraint
92      	waitAndClickByXpath("//input[@name='field24' and @value='case1']");
93      	waitAndTypeByName("field25","");
94      	waitAndTypeByName("field26","");
95      	assertElementPresentByXpath("//input[@name='field25' and @class='form-control input-sm uif-textControl dependsOn-field24 required error']");
96      }
97  }