1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leave.approval;
17
18 import junit.framework.Assert;
19
20 import org.joda.time.DateTime;
21 import org.junit.After;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.kuali.hr.KPMEWebTestCase;
25 import org.kuali.hr.util.HtmlUnitUtil;
26 import org.kuali.kpme.core.FunctionalTest;
27 import org.kuali.kpme.tklm.utils.TkTestConstants;
28
29 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
30 import com.gargoylesoftware.htmlunit.WebClient;
31 import com.gargoylesoftware.htmlunit.html.HtmlButton;
32 import com.gargoylesoftware.htmlunit.html.HtmlPage;
33
34 @FunctionalTest
35 public class LeaveBlockDisplayWebTest extends KPMEWebTestCase {
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 HtmlPage leaveBlockDisplayPage = HtmlUnitUtil
59 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_BLOCK_DISPLAY_URL);
60 Assert.assertNotNull("Leave Request page not found" + leaveBlockDisplayPage);
61
62 updateWebClient();
63
64
65 Assert.assertTrue("Page is not current year ",
66 leaveBlockDisplayPage.asText().contains(Integer.toString(DateTime.now().getYear())));
67
68
69
70 Assert.assertTrue("Page does not contain planned leave ",
71 leaveBlockDisplayPage.asText().contains("Send for Approval"));
72
73
74 Assert.assertTrue("Page does not contain approved leaves ",
75 leaveBlockDisplayPage.asText().contains("Updated by others"));
76
77
78 Assert.assertTrue("Page does not contain approved leaves ",
79 leaveBlockDisplayPage.asText().contains("Updated by self"));
80
81
82 Assert.assertTrue("Page does not contain Document Status ",
83 leaveBlockDisplayPage.asText().contains("Document Status"));
84 Assert.assertTrue("Page does not contain 'FINAL' Document Status ",
85 leaveBlockDisplayPage.asText().contains("FINAL"));
86
87
88 Assert.assertTrue("Page does not contain Planning Status ",
89 leaveBlockDisplayPage.asText().contains("Planning Status"));
90
91
92 HtmlButton nextButton = (HtmlButton) leaveBlockDisplayPage
93 .getElementById("nav_lb_next");
94 leaveBlockDisplayPage = nextButton.click();
95
96
97 Assert.assertTrue("Page does not contain next year ",
98 leaveBlockDisplayPage.asText().contains(Integer.toString(DateTime.now().getYear() + 1)));
99 }
100
101 }