View Javadoc

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