View Javadoc

1   /**
2    * Copyright 2004-2013 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 org.kuali.hr.time.util;
17  
18  import org.junit.After;
19  import org.junit.Before;
20  import org.junit.Ignore;
21  import org.junit.Test;
22  import org.kuali.kpme.core.FunctionalTest;
23  
24  import com.thoughtworks.selenium.DefaultSelenium;
25  import com.thoughtworks.selenium.SeleneseTestCase;
26  
27  @Ignore
28  @FunctionalTest
29  public class UICalendarTest extends SeleneseTestCase {
30      @Before
31      public void setUp() throws Exception {
32          selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://ci.kpme.kuali.org:9080/");
33  //        selenium = new DefaultSelenium("localhost", 4444, "*firefox /Applications/Firefox.app/Contents/MacOS/firefox-bin", "http://ci.kpme.kuali.org:9080/");
34          // set speed to 1 sec between each action. this is mainly for the ajax call to get the earn code.
35          selenium.setSpeed("1000");
36          try {
37              selenium.start();
38          } catch (Exception e) {
39  
40          }
41      }
42  
43      /**
44       * Test adding and deleting a timeblock
45       *
46       * @throws Exception
47       */
48      @Test
49      public void testAddAndDeleteTimeBlock() throws Exception {
50          openPageAndLogin("/tk-dev/TimeDetail.do");
51          selenium.waitForPageToLoad("5000");
52          selenium.click("id=day_9");
53          selenium.select("id=assignment", "value=1_1234_1");
54          selenium.type("id=beginTimeField", "08:00 AM");
55          selenium.type("id=endTimeField", "05:00 PM");
56          selenium.click("//button[@type='button']");
57          selenium.waitForPageToLoad("5000");
58          selenium.click("class=event-delete");
59          selenium.waitForPageToLoad("3000");
60          verifyFalse(selenium.isTextPresent("08:00 AM"));
61          verifyFalse(selenium.isTextPresent("05:00 PM"));
62      }
63  
64      /**
65       * This is to test that the entry fields for time / hours / amount should be correspondent with the selected earn code
66       *
67       * @throws Exception
68       */
69      @Test
70      public void testTestEarnCodeSwitch() throws Exception {
71          openPageAndLogin("/tk-dev/TimeDetail.do");
72          selenium.click("id=day_10");
73          selenium.select("id=assignment", "label=work area description : $0.00 Rcd 1 TEST-DEPT");
74          // verify the time entry fields are presented when the earn code type is "TIME"
75          verifyTrue(selenium.isTextPresent("exact:In:"));
76          verifyTrue(selenium.isTextPresent("exact:Out:"));
77          verifyTrue(selenium.isTextPresent("RGH : REGULAR"));
78          // verify the time entry fields are presented when the earn code type is "HOURS"
79          selenium.select("id=earnCode", "label=SCK : SICK");
80          verifyTrue(selenium.isTextPresent("exact:Hours:"));
81          // verify the time entry fields are presented when the earn code type is "AMOUNT"
82          selenium.select("id=earnCode", "label=TIP : Tips");
83          verifyTrue(selenium.isTextPresent("exact:Amount:"));
84      }
85  
86      /**
87       * Test clocking in and out
88       *
89       * @throws Exception
90       */
91      @Test
92      public void testTestClockInAndOut() throws Exception {
93          openPageAndLogin("/tk-dev/Clock.do");
94          selenium.waitForPageToLoad("3000");
95          selenium.select("id=assignment", "label=work area description : $0.00 Rcd 1 TEST-DEPT");
96          // clock in
97          selenium.click("id=clock-button");
98          selenium.waitForPageToLoad("3000");
99          // verify the clock out button is presented
100         verifyEquals("Clock Out", selenium.getValue("id=clock-button"));
101         // clock out
102         selenium.click("id=clock-button");
103         // go to the time detail page and make sure clocking in/out is successful
104         selenium.click("link=Time Detail");
105         selenium.waitForPageToLoad("3000");
106         verifyTrue(selenium.isTextPresent("exact:RGN: REGULAR"));
107     }
108 
109     @After
110     public void tearDown() throws Exception {
111         selenium.stop();
112     }
113 
114     private void openPageAndLogin(String pageLink) {
115         selenium.open(pageLink);
116         selenium.type("__login_user", "admin");
117         selenium.click("//input[@name='login']");
118         selenium.waitForPageToLoad("2000");
119     }
120 }
121 
122