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 org.junit.Test;
22  
23  import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class ServerWarningsIT extends UpgradedSeleniumITBase {
29      @Override
30      public String getTestUrl() {
31          return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
32      }
33  
34  	@Test
35  	public void testServerWarningsIT() throws Exception {
36  		waitAndClick("//button[contains(.,'Get Warning Messages')]");
37  		waitForPageToLoad();
38  		assertTrue( "css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] not visible https://jira.kuali.org/browse/KULRICE-8140",
39                  isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]"));
40  		assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem not present",
41                  isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem"));
42  		assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] not visible", isVisible(
43                  "css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
44  		assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem not present",
45                  isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem"));
46  		assertTrue("css=div[data-role=\"InputField\"] img[alt=\"Warning\"] not present", isElementPresent(
47                  "css=div[data-role=\"InputField\"] img[alt=\"Warning\"]"));
48  		mouseOver("//a[contains(.,'Field 1')]");
49  		assertTrue("css=.uif-warningHighlight no present when //a[contains(.,'Field 1')] is moused over",
50                  isElementPresent("css=.uif-warningHighlight"));
51  		waitAndClick("//a[contains(.,'Field 1')]");
52          waitForElementVisible("css=.jquerybubblepopup-innerHtml", " after click on //a[contains(.,'Field 1')]");
53  
54  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems not visible", isVisible(
55                  "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
56  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible",
57                  isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
58          typeBlurFocus("name=field1", "");
59          fireEvent("name=field1","hover");
60          waitForElementVisible("css=.jquerybubblepopup-innerHtml", " not visible after typing nothing in name=field1 then firing blur and focus events");
61  
62  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events",
63                  isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
64  
65          waitForElementVisible("css=.jquerybubblepopup-innerHtml> .uif-clientMessageItems", " not visible after typing nothing in name=field1 then firing blur and focus events");
66  
67  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events",
68                  isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field"));
69  
70          typeBlurFocus("name=field1", "b");
71          fireEvent("name=field1","hover");
72          waitForElementVisible("css=.jquerybubblepopup-innerHtml> .uif-serverMessageItems", " not visible after typing b in name=field1 then firing blur and focus events https://jira.kuali.org/browse/KULRICE-8140 Investigate Server Warnings");
73  
74  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing b in name=field1 then firing blur and focus events",
75                  isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
76  		assertTrue("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems", !isElementPresent(
77                  "css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
78  
79  		waitAndType("name=field1", "");
80  		fireEvent("name=field1", "focus");
81  		fireEvent("name=field1", "blur");
82  		fireEvent("name=field1","hover");
83  		assertTrue("css=.uif-hasError is not present after typing nothing in name=field1 and then firing focus and blur events",
84                  isElementPresent("css=.uif-hasError"));
85  		assertTrue( "css=img[src*=\"error.png\"] is not present after typing nothing in name=field1 and then firing focus and blur events",
86                  isElementPresent("css=img[src*=\"error.png\"]"));
87  	}
88  
89      private void typeBlurFocus(String name, String text) throws InterruptedException{
90          waitAndType(name, text);
91          fireEvent(name, "blur");
92          fireEvent(name, "focus");
93      }
94  }