001/** 002 * Copyright 2004-2014 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 */ 016package org.kuali.hr.lm.leave.approval; 017 018import junit.framework.Assert; 019 020import org.junit.After; 021import org.junit.Before; 022import org.junit.Ignore; 023import org.junit.Test; 024import org.kuali.hr.KPMEWebTestCase; 025import org.kuali.hr.util.HtmlUnitUtil; 026import org.kuali.kpme.core.FunctionalTest; 027import org.kuali.kpme.tklm.utils.TkTestConstants; 028 029import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; 030import com.gargoylesoftware.htmlunit.html.HtmlElement; 031import com.gargoylesoftware.htmlunit.html.HtmlPage; 032 033@FunctionalTest 034public class LeaveRequestWebTest extends KPMEWebTestCase { 035 036 @Before 037 public void setUp() throws Exception { 038 super.setUp(); 039 } 040 041 @After 042 public void tearDown() throws Exception { 043 super.tearDown(); 044 } 045 046 @Test 047 @Ignore 048 public void testLeaveRequestPage() throws Exception { 049 // get the page and Login 050 HtmlPage leaveRequestPage = HtmlUnitUtil 051 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_REQUEST_PAGE_URL); 052 Assert.assertNotNull("Leave Request page not found" + leaveRequestPage); 053 054 // Check planned requests 055 Assert.assertTrue("Page does not contain planned leave ", leaveRequestPage 056 .asText().contains("Send for Approval")); 057 058 // check Approved Leaves 059 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage 060 .asText().contains("Approved Leave")); 061 062 // check disapproved Leaves 063 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage 064 .asText().contains("Disapprove")); 065 066 HtmlCheckBoxInput htmlElement = (HtmlCheckBoxInput) leaveRequestPage 067 .getElementByName("plannedLeaves[0].submit"); 068 leaveRequestPage = (HtmlPage) htmlElement.setValueAttribute("true"); 069 070 HtmlCheckBoxInput checkbox = (HtmlCheckBoxInput) HtmlUnitUtil 071 .getInputContainingText(leaveRequestPage, 072 "plannedLeaves[0].submit"); 073 checkbox.setChecked(true); 074 075 HtmlElement elementSubmit = leaveRequestPage.getElementByName("Submit"); 076 Assert.assertNotNull(elementSubmit); 077 078 HtmlUnitUtil.createTempFile(leaveRequestPage); 079 080 HtmlPage leaveRequestPage1 = elementSubmit.click(); 081 082 HtmlUnitUtil.createTempFile(leaveRequestPage1); 083 084 // check if submitted pending leave comes in the section of Requested 085 // leave 086 Assert.assertTrue("Page does not contain Pending leave ", leaveRequestPage1 087 .asText().contains("Send for Approval")); 088 089 } 090 091}