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  package edu.samplu.krad.compview;
17  
18  import edu.samplu.common.UpgradedSeleniumITBase;
19  import junit.framework.Assert;
20  import org.junit.Test;
21  
22  import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue;
23  
24  /**
25   * Selenium test that tests that tooltips are rendered on mouse over and focus events and hidden on
26   * mouse out and blur events
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class UifTooltipIT extends UpgradedSeleniumITBase {
31      private static final String NAME_FIELD_1 = "name=remoteFieldValuesMap[remoteField1]";
32      private static final String NAME_FIELD_2 = "name=remoteFieldValuesMap[remoteField2]";
33      @Override
34      public String getTestUrl() {
35          // open Other Examples page in kitchen sink view
36          return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10";
37      }
38  
39      @Test
40      public void testTooltip() throws Exception {
41          // check if tooltip opens on focus
42          fireEvent(NAME_FIELD_1, "focus");
43          fireEvent(NAME_FIELD_1, "over");
44          Assert.assertTrue(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")
45                  && isVisible("css=td.jquerybubblepopup-innerHtml"));
46          Assert.assertEquals("This tooltip is triggered by focus or and mouse over.", getText("css=td.jquerybubblepopup-innerHtml"));
47         
48          // check if tooltip closed on blur
49          fireEvent(NAME_FIELD_1, "blur");
50          Assert.assertFalse(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")
51                  && isVisible("css=td.jquerybubblepopup-innerHtml"));
52          //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
53          
54          // check if tooltip opens on mouse over
55          mouseOver(NAME_FIELD_2);
56          Assert.assertTrue(isVisible("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
57          
58          // check if tooltip closed on mouse out
59          mouseOut(NAME_FIELD_2);
60          Assert.assertFalse(isVisible("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
61          
62          // check that default tooltip does not display when there are an error message on the field
63          waitAndType(NAME_FIELD_1, "1");
64          fireEvent(NAME_FIELD_1, "blur");
65          fireEvent(NAME_FIELD_1, "focus");
66          waitAndType(NAME_FIELD_1, "1");
67          Thread.sleep(2000);
68          assertTrue("https://jira.kuali.org/browse/KULRICE-8141 Investigate why UifTooltipIT.testTooltip fails around jquerybubblepopup",
69                  isVisible("css=div.jquerybubblepopup.jquerybubblepopup-kr-error-cs") &&
70                !(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")) &&
71                  isVisible("css=img.uif-validationImage"));
72          // TODO figure out this last assert
73          //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
74      }
75  }