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 */
016 package org.kuali.hr.lm.leave.approval;
017
018 import junit.framework.Assert;
019
020 import org.joda.time.DateTime;
021 import org.junit.After;
022 import org.junit.Before;
023 import org.junit.Test;
024 import org.kuali.hr.KPMEWebTestCase;
025 import org.kuali.hr.util.HtmlUnitUtil;
026 import org.kuali.kpme.core.FunctionalTest;
027 import org.kuali.kpme.tklm.utils.TkTestConstants;
028
029 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
030 import com.gargoylesoftware.htmlunit.WebClient;
031 import com.gargoylesoftware.htmlunit.html.HtmlButton;
032 import com.gargoylesoftware.htmlunit.html.HtmlPage;
033
034 @FunctionalTest
035 public class LeaveBlockDisplayWebTest extends KPMEWebTestCase {
036 private static String YEAR = "2013";
037
038 @Before
039 public void setUp() throws Exception {
040 super.setUp();
041 }
042
043 @After
044 public void tearDown() throws Exception {
045 super.tearDown();
046 }
047
048 public void updateWebClient() {
049 WebClient webClient = getWebClient();
050 webClient.setJavaScriptEnabled(true);
051 webClient.setThrowExceptionOnScriptError(true);
052 webClient.setAjaxController(new NicelyResynchronizingAjaxController());
053 webClient.waitForBackgroundJavaScript(10000);
054 }
055
056 @Test
057 public void testLeaveBlockDisplayPage() throws Exception {
058 // get the page and Login
059 HtmlPage leaveBlockDisplayPage = HtmlUnitUtil
060 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL);
061 Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage);
062
063 updateWebClient();
064
065 // check page contains the current year
066 Assert.assertTrue("Page is not current year ",
067 leaveBlockDisplayPage.asText().contains(YEAR));
068
069 // Check Main section
070 // depends on injection of test data for current year.
071 Assert.assertTrue("Page does not contain planned leave ",
072 leaveBlockDisplayPage.asText().contains("Send for Approval"));
073
074 // check Days Removed in correction section
075 Assert.assertTrue("Page does not contain approved leaves ",
076 leaveBlockDisplayPage.asText().contains("Updated by others"));
077
078 // check Inactive Leave entries
079 Assert.assertTrue("Page does not contain approved leaves ",
080 leaveBlockDisplayPage.asText().contains("Updated by self"));
081
082 // check page contains Document Status column
083 Assert.assertTrue("Page does not contain Document Status ",
084 leaveBlockDisplayPage.asText().contains("Document Status"));
085 Assert.assertTrue("Page does not contain 'FINAL' Document Status ",
086 leaveBlockDisplayPage.asText().contains("FINAL"));
087
088 // check page contains Planning Status column
089 Assert.assertTrue("Page does not contain Planning Status ",
090 leaveBlockDisplayPage.asText().contains("Planning Status"));
091
092 // Check for next year
093 HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage
094 .getElementById("nav_lb_next");
095 leaveBlockDisplayPage = nextButton.click();
096
097 // check page contains the next year
098 Assert.assertTrue("Page does not contain next year ",
099 leaveBlockDisplayPage.asText().contains(String.valueOf(Integer.valueOf(YEAR) + 1)));
100 }
101
102 }