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.junit.After;
21  import org.junit.Before;
22  import org.junit.Ignore;
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.html.HtmlCheckBoxInput;
30  import com.gargoylesoftware.htmlunit.html.HtmlElement;
31  import com.gargoylesoftware.htmlunit.html.HtmlPage;
32  
33  @FunctionalTest
34  public class LeaveRequestWebTest extends KPMEWebTestCase {
35  
36  	@Before
37  	public void setUp() throws Exception {
38  		super.setUp();
39  	}
40  
41  	@After
42  	public void tearDown() throws Exception {
43  		super.tearDown();
44  	}
45  
46  	@Test
47      @Ignore
48  	public void testLeaveRequestPage() throws Exception {
49  		// get the page and Login
50  		HtmlPage leaveRequestPage = HtmlUnitUtil
51  				.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_REQUEST_PAGE_URL);
52  		Assert.assertNotNull("Leave Request page not found" + leaveRequestPage);
53  
54  		// Check planned requests
55  		Assert.assertTrue("Page does not contain planned leave ", leaveRequestPage
56  				.asText().contains("Send for Approval"));
57  
58  		// check Approved Leaves
59  		Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
60  				.asText().contains("Approved Leave"));
61  
62  		// check disapproved Leaves
63  		Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
64  				.asText().contains("Disapprove"));
65  
66  		HtmlCheckBoxInput htmlElement = (HtmlCheckBoxInput) leaveRequestPage
67  				.getElementByName("plannedLeaves[0].submit");
68  		leaveRequestPage = (HtmlPage) htmlElement.setValueAttribute("true");
69  
70  		HtmlCheckBoxInput checkbox = (HtmlCheckBoxInput) HtmlUnitUtil
71  				.getInputContainingText(leaveRequestPage,
72  						"plannedLeaves[0].submit");
73  		checkbox.setChecked(true);
74  
75  		HtmlElement elementSubmit = leaveRequestPage.getElementByName("Submit");
76  		Assert.assertNotNull(elementSubmit);
77  
78  		HtmlUnitUtil.createTempFile(leaveRequestPage);
79  
80  		HtmlPage leaveRequestPage1 = elementSubmit.click();
81  
82  		HtmlUnitUtil.createTempFile(leaveRequestPage1);
83  
84  		// check if submitted pending leave comes in the section of Requested
85  		// leave
86  		Assert.assertTrue("Page does not contain Pending leave ", leaveRequestPage1
87  				.asText().contains("Send for Approval"));
88  
89  	}
90  
91  }