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.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 037 @Before 038 public void setUp() throws Exception { 039 super.setUp(); 040 } 041 042 @After 043 public void tearDown() throws Exception { 044 super.tearDown(); 045 } 046 047 public void updateWebClient() { 048 WebClient webClient = getWebClient(); 049 webClient.setJavaScriptEnabled(true); 050 webClient.setThrowExceptionOnScriptError(true); 051 webClient.setAjaxController(new NicelyResynchronizingAjaxController()); 052 webClient.waitForBackgroundJavaScript(10000); 053 } 054 055 @Test 056 public void testLeaveBlockDisplayPage() throws Exception { 057 // get the page and Login 058 HtmlPage leaveBlockDisplayPage = HtmlUnitUtil 059 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL); 060 Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage); 061 062 updateWebClient(); 063 064 // check page contains the current year 065 Assert.assertTrue("Page is not current year ", 066 leaveBlockDisplayPage.asText().contains(Integer.toString(DateTime.now().getYear()))); 067 068 // Check Main section 069 // depends on injection of test data for current year. 070 Assert.assertTrue("Page does not contain planned leave ", 071 leaveBlockDisplayPage.asText().contains("Send for Approval")); 072 073 // check Days Removed in correction section 074 Assert.assertTrue("Page does not contain approved leaves ", 075 leaveBlockDisplayPage.asText().contains("Updated by others")); 076 077 // check Inactive Leave entries 078 Assert.assertTrue("Page does not contain approved leaves ", 079 leaveBlockDisplayPage.asText().contains("Updated by self")); 080 081 // check page contains Document Status column 082 Assert.assertTrue("Page does not contain Document Status ", 083 leaveBlockDisplayPage.asText().contains("Document Status")); 084 Assert.assertTrue("Page does not contain 'FINAL' Document Status ", 085 leaveBlockDisplayPage.asText().contains("FINAL")); 086 087 // check page contains Planning Status column 088 Assert.assertTrue("Page does not contain Planning Status ", 089 leaveBlockDisplayPage.asText().contains("Planning Status")); 090 091 // Check for next year 092 HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage 093 .getElementById("nav_lb_next"); 094 leaveBlockDisplayPage = nextButton.click(); 095 096 // check page contains the next year 097 Assert.assertTrue("Page does not contain next year ", 098 leaveBlockDisplayPage.asText().contains(Integer.toString(DateTime.now().getYear() + 1))); 099 } 100 101 }