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.UpgradedSeleniumITBase;
20  import junit.framework.Assert;
21  import org.junit.Test;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class ServerErrorsIT extends UpgradedSeleniumITBase {
27  
28      @Override
29      public String getTestUrl() {
30          return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
31      }
32  
33      @Test
34      public void testServerErrorsIT() throws Exception {
35          waitAndClick("//button[contains(.,'Get Error Messages')]");
36          waitForPageToLoad();
37  //        Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
38          Thread.sleep(1000);
39          assertElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem");
40          waitIsVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]");
41          assertElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-errorMessageItem");
42          assertElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Error\"]");
43          waitAndClick("//a[contains(.,'\"Section 1 Title\"')]");
44          mouseOver("//a[contains(.,'Field 1')]");
45          assertElementPresent("css=.uif-errorHighlight");
46          waitAndClick("//a[contains(.,'Field 1')]");
47          waitIsVisible("css=.jquerybubblepopup-innerHtml");
48  
49          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems");
50          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
51          waitAndType("name=field1", "");
52          fireEvent("name=field1", "blur");
53          fireEvent("name=field1", "focus");
54          waitIsVisible("css=.jquerybubblepopup-innerHtml");
55  
56          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
57          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems");
58          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field");
59          keyDown("name=field1", "t");
60          keyPress("name=field1", "t");
61          keyUp("name=field1", "t");
62          for (int second = 0; ; second++) {
63              if (second >= 60) {
64                  Assert.fail("timeout");
65              }
66              try {
67                  if (!isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
68                      break;
69                  }
70              } catch (Exception e) {
71              }
72              Thread.sleep(1000);
73          }
74  
75          waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
76          Assert.assertFalse(isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
77      }
78  }