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.UpgradedSeleniumITBase;
20  import org.junit.Test;
21  
22  import static junit.framework.Assert.assertTrue;
23  import static junit.framework.Assert.fail;
24  /**
25   * test that dirty fields check happens for all pages in a view
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class DirtyFieldsCheckIT extends UpgradedSeleniumITBase {
30      @Override
31      public String getTestUrl() {
32          return PORTAL;
33      }
34  
35  	@Test
36  	public void testDirtyFieldsCheck() throws Exception {
37  		selenium.click("link=KRAD");
38  		selenium.waitForPageToLoad("30000");
39  		selenium.click("link=Uif Components (Kitchen Sink)");
40  		selenium.waitForPageToLoad("30000");
41  //		selenium.selectFrame("iframeportlet");
42          Thread.sleep(3000);
43  		selenium.focus("id=u73_control");
44  		selenium.type("id=u73_control", "test 1");
45  		selenium.focus("id=u103_control");
46  		selenium.type("id=u103_control", "test 2");
47  		// 'Other Fields' navigation link
48  		selenium.click("id=u967");
49          assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
50          Thread.sleep(3000);
51          for (int second = 0;; second++) {
52              if (second >= 60) fail("timeout");
53              try { if (selenium.isElementPresent("id=u51_control")) break; } catch (Exception e) {}
54              Thread.sleep(1000);
55          }
56          selenium.focus("id=u51_control");
57  		selenium.type("id=u51_control", "here");
58          selenium.focus("id=u81_control");
59  		selenium.type("id=u81_control", "there");
60  		// 'Validation' navigation link
61  		selenium.click("id=u970");
62          assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
63          Thread.sleep(3000);
64          for (int second = 0;; second++) {
65              if (second >= 60) fail("timeout");
66              try { if (selenium.isElementPresent("id=u114_control")) break; } catch (Exception e) {}
67              Thread.sleep(1000);
68          }
69          selenium.focus("id=u114_control");
70  		selenium.type("id=u114_control", "this");
71          selenium.focus("id=u144_control");
72  		selenium.type("id=u144_control", "that");
73  		// 'Validation - Regex' navigation link
74  		selenium.click("id=u973");
75          assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
76          Thread.sleep(2000);
77          for (int second = 0;; second++) {
78              if (second >= 60) fail("timeout");
79              try { if (selenium.isElementPresent("id=u44_control")) break; } catch (Exception e) {}
80              Thread.sleep(1000);
81          }
82          selenium.focus("id=u44_control");
83  		selenium.type("id=u44_control", "1");
84          selenium.focus("id=u74_control");
85  		selenium.type("id=u74_control", "2");
86          // 'Progressive Disclosure' navigation link
87  		selenium.click("id=u976");
88  		assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
89  	}
90  }