001 /**
002 * Copyright 2004-2013 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 */
016 package org.kuali.hr.lm.leave.web;
017
018 import junit.framework.Assert;
019
020 import org.junit.After;
021 import org.junit.Before;
022 import org.junit.Ignore;
023 import org.junit.Test;
024 import org.kuali.hr.test.KPMETestCase;
025 import org.kuali.hr.time.test.HtmlUnitUtil;
026 import org.kuali.hr.time.test.TkTestConstants;
027
028 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
029 import com.gargoylesoftware.htmlunit.WebClient;
030 import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
031 import com.gargoylesoftware.htmlunit.html.HtmlElement;
032 import com.gargoylesoftware.htmlunit.html.HtmlPage;
033
034 public class LeaveRequestWebTest extends KPMETestCase {
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 }