View Javadoc
1   /**
2    * Copyright 2004-2015 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.lm.leave.approval;
17  
18  import junit.framework.Assert;
19  
20  import org.joda.time.DateTime;
21  import org.junit.After;
22  import org.junit.Before;
23  import org.junit.Test;
24  import org.kuali.hr.KPMEWebTestCase;
25  import org.kuali.hr.util.HtmlUnitUtil;
26  import org.kuali.kpme.core.FunctionalTest;
27  import org.kuali.kpme.tklm.utils.TkTestConstants;
28  
29  import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
30  import com.gargoylesoftware.htmlunit.WebClient;
31  import com.gargoylesoftware.htmlunit.html.HtmlButton;
32  import com.gargoylesoftware.htmlunit.html.HtmlPage;
33  
34  @FunctionalTest
35  public class LeaveBlockDisplayWebTest extends KPMEWebTestCase {
36      private static String YEAR = "2013";
37  
38  	@Before
39  	public void setUp() throws Exception {
40  		super.setUp();
41  	}
42  
43  	@After
44  	public void tearDown() throws Exception {
45  		super.tearDown();
46  	}
47  
48  	public void updateWebClient() {
49          WebClient webClient = getWebClient();
50          webClient.getOptions().setJavaScriptEnabled(true);
51  		webClient.getOptions().setThrowExceptionOnScriptError(true);
52  		webClient.setAjaxController(new NicelyResynchronizingAjaxController());
53  		webClient.waitForBackgroundJavaScript(10000);
54  	}
55  
56  	@Test
57  	public void testLeaveBlockDisplayPage() throws Exception {
58  		// get the page and Login
59  		HtmlPage leaveBlockDisplayPage = HtmlUnitUtil
60  				.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL);
61  		Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage);
62  
63  		updateWebClient();
64  
65  		// check page contains the current year
66  		Assert.assertTrue("Page is not current year ",
67  				leaveBlockDisplayPage.asText().contains(YEAR));
68  
69  		// Check Main section
70  		// depends on injection of test data for current year.
71  		Assert.assertTrue("Page does not contain planned leave ",
72  				leaveBlockDisplayPage.asText().contains("Send for Approval"));
73  
74  		// check Days Removed in correction section
75  		Assert.assertTrue("Page does not contain approved leaves ",
76  				leaveBlockDisplayPage.asText().contains("Updated by others"));
77  		
78  		// check Inactive Leave entries
79  		Assert.assertTrue("Page does not contain approved leaves ",
80  				leaveBlockDisplayPage.asText().contains("Updated by self"));
81  		
82  		// check page contains Document Status column
83  		Assert.assertTrue("Page does not contain Document Status ",
84  				leaveBlockDisplayPage.asText().contains("Document Status"));
85  		Assert.assertTrue("Page does not contain 'FINAL' Document Status ",
86  				leaveBlockDisplayPage.asText().contains("FINAL"));
87  		
88  		// check page contains Planning Status column
89  		Assert.assertTrue("Page does not contain Planning Status ",
90  				leaveBlockDisplayPage.asText().contains("Planning Status"));
91  		
92  		// Check for next year
93  		HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage
94  				.getElementById("nav_lb_next");
95  		leaveBlockDisplayPage = nextButton.click();
96  
97  		// check page contains the next year
98  		Assert.assertTrue("Page does not contain next year ",
99  				leaveBlockDisplayPage.asText().contains(String.valueOf(Integer.valueOf(YEAR) + 1)));
100 	}
101 
102 }