1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.calendar;
17
18
19 import com.gargoylesoftware.htmlunit.html.*;
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.kuali.hr.test.KPMETestCase;
23 import org.kuali.hr.time.test.HtmlUnitUtil;
24 import org.kuali.hr.time.test.TkTestConstants;
25
26 public class CalendarMaintTest extends KPMETestCase {
27
28 public static final String TEST_USER = "admin";
29 private static final String CAL_NAME_REQUIRED = "Calendar Name (Calendar Name) is a required field.";
30 private static final String CAL_DESP_REQUIRED = "Calendar Descriptions (Calendar Descriptions) is a required field.";
31 private static final String CAL_TYPES_REQUIRED = "Calendar Types (Calendar Types) is a required field.";
32 private static final String FLSA_DAY_REQUIRED = "FLSA Begin Day is a required field.";
33 private static final String FLSA_TIME_REQUIRED = "FLSA Begin Time is a required field.";
34
35 @Test
36 public void testDisplayCalendarTypeRadioOptions() throws Exception {
37
38
39 HtmlPage calendarPage = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.CALENDAR_MAINT_URL);
40 HtmlPage resultPage = HtmlUnitUtil.clickInputContainingText(calendarPage, "search");
41 HtmlUnitUtil.createTempFile(resultPage);
42 Assert.assertTrue("Lookup page contains:\n" + "The both radio button is not present", resultPage.asText().contains("Both"));
43
44
45 HtmlPage calendarMaintPage = HtmlUnitUtil.clickAnchorContainingText(resultPage, "edit");
46 HtmlUnitUtil.createTempFile(calendarMaintPage);
47 Assert.assertFalse("Maintenance page contains:\n" + "The both radio button is present", calendarMaintPage.asText().contains("Both"));
48
49 }
50
51 @Test
52 public void testRequiredFields() throws Exception {
53 String baseUrl = TkTestConstants.Urls.CALENDAR_MAINT_NEW_URL;
54 HtmlPage page = HtmlUnitUtil.gotoPageAndLogin(getWebClient(), baseUrl);
55 Assert.assertNotNull(page);
56
57 HtmlForm form = page.getFormByName("KualiForm");
58 Assert.assertNotNull("Search form was missing from page.", form);
59
60 HtmlInput input = HtmlUnitUtil.getInputContainingText(form, "methodToCall.route");
61 Assert.assertNotNull("Could not locate submit button", input);
62
63 HtmlElement element = page.getElementByName("methodToCall.route");
64 page = element.click();
65 Assert.assertFalse("page text contains: Incident Report", page.asText().contains("Incident Report"));
66 Assert.assertTrue("page text does not contain:\n" + CAL_NAME_REQUIRED, page.asText().contains(CAL_NAME_REQUIRED));
67 Assert.assertTrue("page text does not contain:\n" + CAL_DESP_REQUIRED, page.asText().contains(CAL_DESP_REQUIRED));
68 Assert.assertTrue("page text does not contain:\n" + CAL_TYPES_REQUIRED, page.asText().contains(CAL_TYPES_REQUIRED));
69 Assert.assertFalse("page text contains:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
70 Assert.assertFalse("page text contains:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
71
72 setFieldValue(page, "document.newMaintainableObject.calendarName", "testCal");
73 setFieldValue(page, "document.newMaintainableObject.calendarDescriptions", "testDes");
74
75 setFieldValue(page, "document.newMaintainableObject.calendarTypesLeave", "on");
76 page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
77 Assert.assertFalse("page text contains:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
78 Assert.assertFalse("page text contains:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
79
80
81 setFieldValue(page, "document.newMaintainableObject.calendarTypesPay", "on");
82 page = ((HtmlElement)page.getElementByName("methodToCall.route")).click();
83 Assert.assertTrue("page text does not contain:\n" + FLSA_DAY_REQUIRED, page.asText().contains(FLSA_DAY_REQUIRED));
84 Assert.assertTrue("page text does not contain:\n" + FLSA_TIME_REQUIRED, page.asText().contains(FLSA_TIME_REQUIRED));
85 }
86 }