View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.travel.krad.test;
18  
19  import edu.samplu.common.ITUtil;
20  import org.junit.Test;
21  
22  import static junit.framework.Assert.assertEquals;
23  import static junit.framework.Assert.assertTrue;
24  import static junit.framework.Assert.fail;
25  import edu.samplu.common.WebDriverITBase;
26  
27  /**
28   * test that dirty fields check happens for all pages in a view
29   * 
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class DirtyFieldsCheckIT extends WebDriverITBase {
33  	@Override
34  	public String getTestUrl() {
35  		// open Other Examples page in kitchen sink view
36  		return "/kr-krad/uicomponents?viewId=UifCompView_KNS&methodToCall=start&readOnlyFields=field91";
37  	}
38  
39  	@Test
40  	public void testDirtyFieldsCheck() throws Exception {
41  		checkForIncidentReport(getTestUrl());
42  		Thread.sleep(5000);
43  		
44  		waitAndTypeByName("field1", "test 1");
45  		waitAndTypeByName("field102", "test 2");
46  		
47  		assertCancelConfirmation(); 
48  	
49  		// testing manually
50  		waitForElementPresentByName("field100");
51  		waitAndTypeByName("field100", "here");
52  		waitAndTypeByName("field103", "there");
53  		
54  	    // 'Validation' navigation link
55  		assertCancelConfirmation();
56  	
57  		// testing manually
58  		waitForElementPresentByName("field106");
59  		// //Asserting text-field style to uppercase. This style would display
60  		// input text in uppercase.
61  		assertEquals("text-transform: uppercase;",getAttributeByName("field112", "style"));
62  		assertCancelConfirmation(); 
63  		waitForElementPresentByName("field101");
64  		assertEquals("val", getAttributeByName("field101","value")); 
65  		clearTextByName("field101");
66  		waitAndTypeByName("field101", "1");
67  		waitAndTypeByName("field104", "");
68  
69  		assertEquals("1", getAttributeByName("field101","value"));
70  		waitAndTypeByName("field104", "2");
71  		// 'Progressive Disclosure' navigation link
72  		assertCancelConfirmation();
73  									
74  	}
75  
76  	private void assertCancelConfirmation() throws InterruptedException {
77  		waitAndClickByLinkText("Cancel");
78  		dismissAlert();
79  	}
80  }