1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leave.web;
17
18 import java.util.Calendar;
19
20 import junit.framework.Assert;
21
22 import org.junit.After;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.kuali.hr.test.KPMETestCase;
26 import org.kuali.hr.time.test.HtmlUnitUtil;
27 import org.kuali.hr.time.test.TkTestConstants;
28 import org.kuali.hr.time.util.TKUtils;
29
30 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
31 import com.gargoylesoftware.htmlunit.WebClient;
32 import com.gargoylesoftware.htmlunit.html.HtmlButton;
33 import com.gargoylesoftware.htmlunit.html.HtmlPage;
34
35 public class LeaveBlockDisplayWebTest extends KPMETestCase {
36
37 @Before
38 public void setUp() throws Exception {
39 super.setUp();
40 }
41
42 @After
43 public void tearDown() throws Exception {
44 super.tearDown();
45 }
46
47 public void updateWebClient() {
48 WebClient webClient = getWebClient();
49 webClient.setJavaScriptEnabled(true);
50 webClient.setThrowExceptionOnScriptError(true);
51 webClient.setAjaxController(new NicelyResynchronizingAjaxController());
52 webClient.waitForBackgroundJavaScript(10000);
53 }
54
55 @Test
56 public void testLeaveBlockDisplayPage() throws Exception {
57
58 Calendar currentCalendar = Calendar.getInstance();
59 HtmlPage leaveBlockDisplayPage = HtmlUnitUtil
60 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL);
61 Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage);
62
63 updateWebClient();
64
65
66 Assert.assertTrue("Page is not current year ",
67 leaveBlockDisplayPage.asText().contains(Integer.toString(currentCalendar.get(Calendar.YEAR))));
68
69
70
71 Assert.assertTrue("Page does not contain planned leave ",
72 leaveBlockDisplayPage.asText().contains("Send for Approval"));
73
74
75 Assert.assertTrue("Page does not contain approved leaves ",
76 leaveBlockDisplayPage.asText().contains("Updated by others"));
77
78
79 Assert.assertTrue("Page does not contain approved leaves ",
80 leaveBlockDisplayPage.asText().contains("Updated by self"));
81
82
83 Assert.assertTrue("Page does not contain Document Status ",
84 leaveBlockDisplayPage.asText().contains("Document Status"));
85 Assert.assertTrue("Page does not contain 'FINAL' Document Status ",
86 leaveBlockDisplayPage.asText().contains("FINAL"));
87
88
89 Assert.assertTrue("Page does not contain Planning Status ",
90 leaveBlockDisplayPage.asText().contains("Planning Status"));
91
92
93 HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage
94 .getElementById("nav_lb_next");
95 leaveBlockDisplayPage = nextButton.click();
96
97
98 Assert.assertTrue("Page does not contain next year ",
99 leaveBlockDisplayPage.asText().contains(Integer.toString(currentCalendar.get(Calendar.YEAR)+1)));
100 }
101
102 }