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.krad.validationmessagesview;
18  
19  import edu.samplu.common.ITUtil;
20  import edu.samplu.common.UpgradedSeleniumITBase;
21  import junit.framework.Assert;
22  import org.junit.Test;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class ServerInfoIT extends UpgradedSeleniumITBase {
28      @Override
29      public String getTestUrl() {
30          return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
31      }
32  
33  	@Test
34  	public void testServerInfoIT() throws Exception {
35  		waitAndClick("//button[contains(.,'Get Info Messages')]");
36          waitIsVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]");
37  		Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]"));
38  		Assert.assertTrue(isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem"));
39  		Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
40  		Assert.assertTrue(isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem"));
41  		Assert.assertTrue(isElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Information\"]"));
42  		mouseOver("//a[contains(.,'Field 1')]");
43  		Assert.assertTrue(isElementPresent("css=.uif-infoHighlight"));
44  		waitAndClick("//a[contains(.,'Field 1')]");
45  		for (int second = 0;; second++) {
46  			if (second >= 60) Assert.fail("timeout");
47  			try { if (isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
48  			Thread.sleep(1000);
49  		}
50  
51  		Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
52  		Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
53  		waitAndType("name=field1", "");
54  		fireEvent("name=field1", "blur");
55  		fireEvent("name=field1", "focus");
56  		for (int second = 0;; second++) {
57  			if (second >= 60) Assert.fail("timeout");
58  			try { if (isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
59  			Thread.sleep(1000);
60  		}
61  
62  		Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
63  		for (int second = 0;; second++) {
64  			if (second >= 60) Assert.fail("timeout");
65  			try { if (isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
66  			Thread.sleep(1000);
67  		}
68  
69  		Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field"));
70  		waitAndType("name=field1", "b");
71          fireEvent("name=field1", "blur");
72          fireEvent("name=field1", "focus");
73          for (int second = 0;; second++) {
74  			if (second >= 60) Assert.fail("timeout");
75  			try { if (!isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
76  			Thread.sleep(1000);
77  		}
78          fireEvent("name=field1", "blur");
79  
80  		Assert.assertTrue(!isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
81  		Assert.assertFalse(isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
82  		waitAndType("name=field1", "");
83  		fireEvent("name=field1", "focus");
84  		fireEvent("name=field1", "blur");
85  		Assert.assertTrue(isElementPresent("css=.uif-hasError"));
86  		Assert.assertTrue(isElementPresent("css=img[src*=\"error.png\"]"));
87  	}
88  }