1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.travel.application;
17
18 import org.apache.commons.lang.RandomStringUtils;
19 import org.junit.Test;
20 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21 import org.kuali.rice.testtools.selenium.WebDriverUtils;
22 import org.openqa.selenium.By;
23
24
25
26
27 public class DemoTravelCompanySuperUserTabAft extends WebDriverLegacyITBase {
28
29
30
31
32 public static final String BOOKMARK_URL = "/kr-krad/maintenance?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelCompany";
33
34
35
36
37 private static final String APPROVE="Approve";
38
39
40
41
42 private static final String DISAPPROVE="Disapprove";
43
44
45
46
47 private static final String TAKE_SELECTED_ACTIONS="Take Selected Actions";
48
49
50
51
52 public static final String DESCRIPTION_FIELD = "document.documentHeader.documentDescription";
53
54
55
56
57 public static final String COMPANY_NAME_FIELD = "document.newMaintainableObject.dataObject.travelCompanyName";
58
59 @Override
60 public String getBookmarkUrl() {
61 return BOOKMARK_URL;
62 }
63
64 protected void navigate() throws Exception {
65 waitAndClickDemoLink();
66 waitAndClickByLinkText("Travel Company Lookup");
67 waitAndClickByLinkText("Create New");
68 }
69
70 @Override
71 public String getUserName() {
72 if ((testName.getMethodName().equals("testDemoTravelCompanySuperUserTabNotAppearBookmark"))||
73 (testName.getMethodName().equals("testDemoTravelCompanySuperUserTabNotAppearNav"))) {
74 return "testUser2";
75 } else {
76 return super.getUserName();
77 }
78 }
79
80 protected void travelAccountCreateDocument() throws Exception {
81 waitForDocIdKrad();
82 waitAndTypeByName(DESCRIPTION_FIELD,"Travel Company Super User Test");
83 String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
84 waitAndTypeByName(COMPANY_NAME_FIELD, "Company Name " + randomCode);
85
86 waitAndClickByLinkText("Ad Hoc Recipients");
87 waitAndTypeByName("newCollectionLines['document.adHocRoutePersons'].id", "user1");
88 jGrowl("Click Add button");
89 waitAndClickById("Uif-AdHocPersonCollection_add");
90 waitForElementPresentByXpath(
91 "//div[@data-parent=\"Uif-AdHocPersonCollection\"]/div/span[contains(text(), 'user1']");
92 waitAndClickByLinkText("Ad Hoc Recipients");
93
94 submitSuccessfully(WebDriverUtils.configuredImplicityWait() * 8);
95 waitAndClickButtonByText("Reload");
96 waitForProgressLoading();
97 checkForDocErrorKrad();
98 waitForTextPresent("Document was successfully reloaded.");
99 }
100
101 protected void travelAccountCreateDocumentWith2Adhoc() throws Exception {
102 waitForDocIdKrad();
103 waitAndTypeByName(DESCRIPTION_FIELD,"Travel Company Super User Test");
104 String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
105 waitAndTypeByName(COMPANY_NAME_FIELD, "Company Name " + randomCode);
106
107 waitAndClickByLinkText("Ad Hoc Recipients");
108 waitAndTypeByName("newCollectionLines['document.adHocRoutePersons'].id", "user1");
109 jGrowl("Click Add button");
110 waitAndClickById("Uif-AdHocPersonCollection_add");
111 waitForElementPresentByXpath(
112 "//div[@data-parent=\"Uif-AdHocPersonCollection\"]/div/span[contains(text(), 'user1']");
113
114 waitAndTypeByName("newCollectionLines['document.adHocRoutePersons'].id", "user2");
115 jGrowl("Click Add button");
116 waitAndClickById("Uif-AdHocPersonCollection_add");
117 waitForElementPresentByXpath(
118 "//div[@data-parent=\"Uif-AdHocPersonCollection\"]/div/span[contains(text(), 'user2']");
119 waitAndClickByLinkText("Ad Hoc Recipients");
120
121 submitSuccessfully(WebDriverUtils.configuredImplicityWait() * 16);
122 waitAndClickButtonByText("Reload");
123 waitForProgressLoading();
124 checkForDocErrorKrad();
125 waitForTextPresent("Document was successfully reloaded.");
126 }
127
128 protected void testTravelAccountSuperUserApprove() throws Exception {
129 travelAccountCreateDocument();
130 waitAndClickByLinkText("Super User Actions");
131 waitAndTypeByName("document.superUserAnnotation","Reason for approval");
132 assertElementPresent(By.xpath("//section[@id = 'Uif-SuperUserActionRequests']//a[contains(text(), 'One, User')]"));
133 waitAndClickButtonByText(APPROVE);
134 waitForProgressLoading(WebDriverUtils.configuredImplicityWait() * 2);
135 waitForTextPresent("was superuser approved.");
136 reloadAndCheckDocStatus("FINAL");
137 }
138
139 protected void testTravelAccountSuperUserDisapprove() throws Exception {
140 travelAccountCreateDocument();
141 waitAndClickByLinkText("Super User Actions");
142 waitAndTypeByName("document.superUserAnnotation","Reason For disapproval");
143 assertElementPresent(By.xpath("//section[@id = 'Uif-SuperUserActionRequests']//a[contains(text(), 'One, User')]"));
144 waitAndClickButtonByText(DISAPPROVE);
145 waitForTextPresent("was superuser disapproved.");
146 reloadAndCheckDocStatus("DISAPPROVED");
147 }
148
149 protected void testTravelAccountSuperUserTakeActions() throws Exception {
150 travelAccountCreateDocumentWith2Adhoc();
151 waitAndClickByLinkText("Super User Actions");
152 waitAndTypeByName("document.superUserAnnotation","Reason For Taking Action for user1");
153
154
155 waitAndClickButtonByText(TAKE_SELECTED_ACTIONS);
156 waitForProgressLoading();
157 waitForTextPresent("Super User Actions: 1 error");
158 waitForTextPresent("Please select an action to perform");
159
160 checkByName("selectedCollectionLines['document.actionRequests']");
161 waitAndClickButtonByText(TAKE_SELECTED_ACTIONS);
162 waitForProgressLoading();
163 waitForTextPresent("Action request");
164 waitForTextPresent("was superuser approved in Document");
165
166
167
168
169 waitAndTypeByName("document.superUserAnnotation","Reason For Taking Action for user2");
170 checkByName("selectedCollectionLines['document.actionRequests']");
171 waitAndClickButtonByText(TAKE_SELECTED_ACTIONS);
172 waitForProgressLoading();
173 waitForTextPresent("Action request");
174 waitForTextPresent("was superuser approved in Document");
175
176 reloadAndCheckDocStatus("FINAL");
177 }
178
179 protected void testTravelAccountSuperUserErrors() throws Exception {
180 travelAccountCreateDocument();
181 waitAndClickByLinkText("Super User Actions");
182
183
184 checkByName("selectedCollectionLines['document.actionRequests']");
185 waitAndClickButtonByText(APPROVE);
186 waitForProgressLoading();
187 waitForTextPresent(
188 "button was selected but there are actions checked. Please either uncheck the actions or select the");
189 uncheckByName("selectedCollectionLines['document.actionRequests']");
190
191
192 waitAndClickButtonByText(APPROVE);
193 waitForProgressLoading();
194 waitForTextPresent("Annotation: Please provide an annotation to continue with the approval of this document");
195
196
197 waitAndClickButtonByText(DISAPPROVE);
198 waitForProgressLoading();
199 waitForTextPresent(
200 "Annotation: Please provide an annotation to continue with the disapproval of this document");
201
202
203
204 waitAndClickButtonByText(TAKE_SELECTED_ACTIONS);
205 waitForProgressLoading();
206 waitForTextPresent("Annotation: Please provide an annotation to continue taking these actions on the document");
207
208
209 waitAndTypeByName("document.superUserAnnotation", "Reason for disapproval");
210
211
212 checkByName("selectedCollectionLines['document.actionRequests']");
213 waitAndClickButtonByText(DISAPPROVE);
214 waitForProgressLoading();
215 waitForTextPresent(
216 "button was selected but there are actions checked. Please either uncheck the actions or select the");
217 uncheckByName("selectedCollectionLines['document.actionRequests']");
218
219
220 waitAndClickButtonByText(DISAPPROVE);
221 waitForProgressLoading();
222 reloadAndCheckDocStatus("DISAPPROVED");
223 }
224
225 protected void testTravelAccountSuperUserTabNotAppear() throws Exception {
226 travelAccountCreateDocument();
227
228
229 assertTextNotPresent("Super User Actions");
230 reloadAndCheckDocStatus("ENROUTE");
231 }
232
233 private void reloadAndCheckDocStatus(String docStatus) throws Exception {
234 waitAndClickButtonByText("Reload");
235 waitForProgressLoading();
236 waitForTextPresent("Document was successfully reloaded.");
237 assertTextPresent(docStatus);
238 }
239
240 @Test
241 public void testDemoTravelCompanySuperUserApproveBookmark() throws Exception {
242 testTravelAccountSuperUserApprove();
243 passed();
244 }
245
246 @Test
247 public void testDemoTravelCompanySuperUserApproveNav() throws Exception {
248 testTravelAccountSuperUserApprove();
249 passed();
250 }
251
252 @Test
253 public void testDemoTravelCompanySuperUserDisapproveBookmark() throws Exception {
254 testTravelAccountSuperUserDisapprove();
255 passed();
256 }
257
258 @Test
259 public void testDemoTravelCompanySuperUserDisapproveNav() throws Exception {
260 testTravelAccountSuperUserDisapprove();
261 passed();
262 }
263
264 @Test
265 public void testDemoTravelCompanySuperUserTakeActionsBookmark() throws Exception {
266 testTravelAccountSuperUserTakeActions();
267 passed();
268 }
269
270 @Test
271 public void testDemoTravelCompanySuperUserTakeActionsNav() throws Exception {
272 testTravelAccountSuperUserTakeActions();
273 passed();
274 }
275
276 @Test
277 public void testDemoTravelCompanySuperUserErrorsBookmark() throws Exception {
278 testTravelAccountSuperUserErrors();
279 passed();
280 }
281
282 @Test
283 public void testDemoTravelCompanySuperUserErrorsNav() throws Exception {
284 testTravelAccountSuperUserErrors();
285 passed();
286 }
287
288 @Test
289 public void testDemoTravelCompanySuperUserTabNotAppearBookmark() throws Exception {
290 testTravelAccountSuperUserTabNotAppear();
291 passed();
292 }
293
294 @Test
295 public void testDemoTravelCompanySuperUserTabNotAppearNav() throws Exception {
296 testTravelAccountSuperUserTabNotAppear();
297 passed();
298 }
299 }