001    /**
002     * Copyright 2004-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 org.kuali.hr.time.util;
017    
018    import org.junit.After;
019    import org.junit.Before;
020    import org.junit.Ignore;
021    import org.junit.Test;
022    
023    import com.thoughtworks.selenium.DefaultSelenium;
024    import com.thoughtworks.selenium.SeleneseTestCase;
025    
026    @Ignore
027    public class UICalendarTest extends SeleneseTestCase {
028        @Before
029        public void setUp() throws Exception {
030            selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://ci.kpme.kuali.org:9080/");
031    //        selenium = new DefaultSelenium("localhost", 4444, "*firefox /Applications/Firefox.app/Contents/MacOS/firefox-bin", "http://ci.kpme.kuali.org:9080/");
032            // set speed to 1 sec between each action. this is mainly for the ajax call to get the earn code.
033            selenium.setSpeed("1000");
034            try {
035                selenium.start();
036            } catch (Exception e) {
037    
038            }
039        }
040    
041        /**
042         * Test adding and deleting a timeblock
043         *
044         * @throws Exception
045         */
046        @Test
047        public void testAddAndDeleteTimeBlock() throws Exception {
048            openPageAndLogin("/tk-dev/TimeDetail.do");
049            selenium.waitForPageToLoad("5000");
050            selenium.click("id=day_9");
051            selenium.select("id=assignment", "value=1_1234_1");
052            selenium.type("id=beginTimeField", "08:00 AM");
053            selenium.type("id=endTimeField", "05:00 PM");
054            selenium.click("//button[@type='button']");
055            selenium.waitForPageToLoad("5000");
056            selenium.click("class=event-delete");
057            selenium.waitForPageToLoad("3000");
058            verifyFalse(selenium.isTextPresent("08:00 AM"));
059            verifyFalse(selenium.isTextPresent("05:00 PM"));
060        }
061    
062        /**
063         * This is to test that the entry fields for time / hours / amount should be correspondent with the selected earn code
064         *
065         * @throws Exception
066         */
067        @Test
068        public void testTestEarnCodeSwitch() throws Exception {
069            openPageAndLogin("/tk-dev/TimeDetail.do");
070            selenium.click("id=day_10");
071            selenium.select("id=assignment", "label=work area description : $0.00 Rcd 1 TEST-DEPT");
072            // verify the time entry fields are presented when the earn code type is "TIME"
073            verifyTrue(selenium.isTextPresent("exact:In:"));
074            verifyTrue(selenium.isTextPresent("exact:Out:"));
075            verifyTrue(selenium.isTextPresent("RGH : REGULAR"));
076            // verify the time entry fields are presented when the earn code type is "HOURS"
077            selenium.select("id=earnCode", "label=SCK : SICK");
078            verifyTrue(selenium.isTextPresent("exact:Hours:"));
079            // verify the time entry fields are presented when the earn code type is "AMOUNT"
080            selenium.select("id=earnCode", "label=TIP : Tips");
081            verifyTrue(selenium.isTextPresent("exact:Amount:"));
082        }
083    
084        /**
085         * Test clocking in and out
086         *
087         * @throws Exception
088         */
089        @Test
090        public void testTestClockInAndOut() throws Exception {
091            openPageAndLogin("/tk-dev/Clock.do");
092            selenium.waitForPageToLoad("3000");
093            selenium.select("id=assignment", "label=work area description : $0.00 Rcd 1 TEST-DEPT");
094            // clock in
095            selenium.click("id=clock-button");
096            selenium.waitForPageToLoad("3000");
097            // verify the clock out button is presented
098            verifyEquals("Clock Out", selenium.getValue("id=clock-button"));
099            // clock out
100            selenium.click("id=clock-button");
101            // go to the time detail page and make sure clocking in/out is successful
102            selenium.click("link=Time Detail");
103            selenium.waitForPageToLoad("3000");
104            verifyTrue(selenium.isTextPresent("exact:RGN: REGULAR"));
105        }
106    
107        @After
108        public void tearDown() throws Exception {
109            selenium.stop();
110        }
111    
112        private void openPageAndLogin(String pageLink) {
113            selenium.open(pageLink);
114            selenium.type("__login_user", "admin");
115            selenium.click("//input[@name='login']");
116            selenium.waitForPageToLoad("2000");
117        }
118    }
119    
120