001 /*
002 * Copyright 2006-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.krad.compview;
017
018 import edu.samplu.common.UpgradedSeleniumITBase;
019 import junit.framework.Assert;
020 import org.junit.Test;
021
022 import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue;
023
024 /**
025 * Selenium test that tests that tooltips are rendered on mouse over and focus events and hidden on
026 * mouse out and blur events
027 *
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030 public class UifTooltipIT extends UpgradedSeleniumITBase {
031 private static final String NAME_FIELD_1 = "name=remoteFieldValuesMap[remoteField1]";
032 private static final String NAME_FIELD_2 = "name=remoteFieldValuesMap[remoteField2]";
033 @Override
034 public String getTestUrl() {
035 // open Other Examples page in kitchen sink view
036 return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10";
037 }
038
039 @Test
040 public void testTooltip() throws Exception {
041 // check if tooltip opens on focus
042 fireEvent(NAME_FIELD_1, "focus");
043 fireEvent(NAME_FIELD_1, "over");
044 Assert.assertTrue(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")
045 && isVisible("css=td.jquerybubblepopup-innerHtml"));
046 Assert.assertEquals("This tooltip is triggered by focus or and mouse over.", getText("css=td.jquerybubblepopup-innerHtml"));
047
048 // check if tooltip closed on blur
049 fireEvent(NAME_FIELD_1, "blur");
050 Assert.assertFalse(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")
051 && isVisible("css=td.jquerybubblepopup-innerHtml"));
052 //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
053
054 // check if tooltip opens on mouse over
055 mouseOver(NAME_FIELD_2);
056 Assert.assertTrue(isVisible("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
057
058 // check if tooltip closed on mouse out
059 mouseOut(NAME_FIELD_2);
060 Assert.assertFalse(isVisible("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
061
062 // check that default tooltip does not display when there are an error message on the field
063 waitAndType(NAME_FIELD_1, "1");
064 fireEvent(NAME_FIELD_1, "blur");
065 fireEvent(NAME_FIELD_1, "focus");
066 waitAndType(NAME_FIELD_1, "1");
067 Thread.sleep(2000);
068 assertTrue("https://jira.kuali.org/browse/KULRICE-8141 Investigate why UifTooltipIT.testTooltip fails around jquerybubblepopup",
069 isVisible("css=div.jquerybubblepopup.jquerybubblepopup-kr-error-cs") &&
070 !(isVisible("css=div.jquerybubblepopup.jquerybubblepopup-black")) &&
071 isVisible("css=img.uif-validationImage"));
072 // TODO figure out this last assert
073 //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
074 }
075 }