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.WebDriverLegacyITBase;
019    
020    import junit.framework.Assert;
021    import org.junit.Test;
022    
023    import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue;
024    
025    /**
026     * Selenium test that tests that tooltips are rendered on mouse over and focus events and hidden on
027     * mouse out and blur events
028     * 
029     * @author Kuali Rice Team (rice.collab@kuali.org)
030     */
031    public class UifTooltipLegacyIT extends WebDriverLegacyITBase {
032        private static final String NAME_FIELD_1 = "field1";
033        private static final String NAME_FIELD_2 = "field2";
034        @Override
035        public String getTestUrl() {
036            // open Other Examples page in kitchen sink view
037            return "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page10";
038        }
039    
040        @Test
041        public void testTooltip() throws Exception {
042            // check if tooltip opens on focus
043            fireEvent(NAME_FIELD_1, "focus");
044            fireMouseOverEventByName(NAME_FIELD_1);
045            Assert.assertTrue(isVisible("div.jquerybubblepopup.jquerybubblepopup-black")
046                    && isVisible("td.jquerybubblepopup-innerHtml"));
047            Assert.assertEquals("This tooltip is triggered by focus or and mouse over.", getText("td.jquerybubblepopup-innerHtml"));
048           
049            // check if tooltip closed on blur
050            fireEvent(NAME_FIELD_1, "blur");
051            Assert.assertFalse(isVisible("div.jquerybubblepopup.jquerybubblepopup-black")
052                    && isVisible("td.jquerybubblepopup-innerHtml"));
053            //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
054            
055            // check if tooltip opens on mouse over
056            fireMouseOverEventByName(NAME_FIELD_2);
057            Assert.assertTrue(isVisibleByXpath("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
058            
059            // check if tooltip closed on mouse out
060            waitAndTypeByName(NAME_FIELD_2,"a");
061            Thread.sleep(5000);
062            Assert.assertFalse(isVisibleByXpath("//td[contains(.,\"This is a tool-tip with different position and tail options\")]"));
063            
064            // check that default tooltip does not display when there are an error message on the field
065            waitAndTypeByName(NAME_FIELD_1, "1");
066            fireEvent(NAME_FIELD_1, "blur");
067            fireEvent(NAME_FIELD_1, "focus");
068            fireMouseOverEventByName(NAME_FIELD_1);
069            Thread.sleep(5000);
070            assertTrue("https://jira.kuali.org/browse/KULRICE-8141 Investigate why UifTooltipIT.testTooltip fails around jquerybubblepopup",
071                    isVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-kr-error-cs']") &&
072                    !(isVisibleByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black']")) &&
073                    isVisibleByXpath("//img[@class='uif-validationImage']"));
074            // TODO figure out this last assert
075            //Assert.assertFalse(isVisible("//td[contains(.,\"This tooltip is triggered by focus or and mouse over.\")]"));
076        }
077    }