View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.main;
17  
18  import org.junit.Before;
19  import org.junit.BeforeClass;
20  import org.junit.Test;
21  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
22  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
23  import org.kuali.rice.testtools.selenium.WebDriverUtils;
24  import org.openqa.selenium.By;
25  import static edu.sampleu.main.PeopleFlowCreateNewAftBase.PeopleFlowDocInfo;
26  /**
27   * test that checks that rules can be added to agendas
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class AgendaEditorAndOrToggleSyncAft extends WebDriverLegacyITBase {
32      public static final String PEOPLE_FLOW_LINK_TEXT = "People Flow";
33      public static final String BOOKMARK_URL =
34              AutomatedFunctionalTestUtils.PORTAL
35                      + "?channelTitle=Agenda%20Lookup&channelUrl="
36                      + WebDriverUtils.getBaseUrlString()
37                      + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
38                      + "org.kuali.rice.krms.impl.repository.AgendaBo"
39                      + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS
40                      + "&returnLocation="
41                      + AutomatedFunctionalTestUtils.PORTAL_URL
42                      + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
43  
44      public static final String ID_TEXT = "T1001";
45  
46      private String getPeopleFlowId() throws Exception {
47          selectParentWindow();
48          waitAndClickMainMenu();
49          waitAndClickByLinkText(PEOPLE_FLOW_LINK_TEXT);
50          waitForPageToLoad();
51  
52          PeopleFlowDocInfo docInfo = peopleFlowCreateNew();
53          jGrowl("people flow id is created");
54  
55          selectParentWindow();
56          waitAndClickMainMenu();
57          waitAndClickByLinkText(PEOPLE_FLOW_LINK_TEXT);
58          waitForPageToLoad();
59          jGrowl("ready to search people flow");
60  
61          selectFrameIframePortlet();
62          selectByName("lookupCriteria[namespaceCode]", "KUALI - Kuali Systems");
63          waitClearAndType("lookupCriteria[name]", docInfo.getName());
64          waitAndClickByXpath("//button[contains(text(),'Search')]");
65          waitForTextPresent("edit");
66          jGrowl("search people flow search complete");
67  
68          String id = getTextByXpath("(//span[contains(@id,'line0_control')])[1]");
69          assertTrue(id != null);
70          jGrowl("people flow id is " + id);
71  
72          selectParentWindow();
73          waitAndClickMainMenu();
74          waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
75          waitForPageToLoad();
76  
77          return id;
78      }
79  
80      private PeopleFlowDocInfo peopleFlowCreateNew() throws Exception {
81          selectFrameIframePortlet();
82  
83          waitAndClickByLinkText("Create New");
84          String peopleFlowNamespace = "KUALI - Kuali Systems";
85          String peopleFlowName = "Document Name" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
86  
87          //Save docId
88          waitForElementPresentByXpath("//div[@data-label='Document Number']/span");
89          String docId = getTextByXpath("//div[@data-label='Document Number']/span");
90          assertTrue(docId != null);
91          jGrowlSticky("Doc Id is " + docId);
92  
93          clearTextByName("document.documentHeader.documentDescription");
94          waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document");
95          waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", peopleFlowNamespace);
96          clearTextByName("document.newMaintainableObject.dataObject.name");
97          waitAndTypeByName("document.newMaintainableObject.dataObject.name", peopleFlowName);
98  
99          jGrowl("Add Member kr");
100         clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName");
101         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr");
102         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].forceAction")).click();
103         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
104         Thread.sleep(3000);
105         checkForIncidentReport();
106 
107         jGrowl("Add Member admin");
108         clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority");
109         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority", "2");
110         clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName");
111         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin");
112         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
113         Thread.sleep(3000);
114 
115         waitAndClickButtonByExactText("Save");
116         waitForTextPresent("SAVED", WebDriverUtils.configuredImplicityWait() * 4);
117         waitForTextPresent(" Document was successfully saved.");
118 
119         waitAndClickButtonByExactText("Submit");
120         waitAndClickConfirmSubmitOk();
121         waitForTextPresent("ENROUTE");
122         waitForTextPresent("Document was successfully submitted.");
123 
124         return new PeopleFlowDocInfo(docId, peopleFlowNamespace, peopleFlowName);
125     }
126 
127     @Override
128     protected String getBookmarkUrl() {
129         return BOOKMARK_URL;
130     }
131 
132     @Override
133     protected void navigate() throws Exception {
134         waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
135         waitForPageToLoad();
136     }
137 
138     protected void testAgendaEditorAndOrToggleSync() throws Exception {
139         selectFrameIframePortlet();
140         waitClearAndType("lookupCriteria[name]", "SimpleAgendaCompoundProp");
141         waitAndClickByXpath("//button[contains(text(),'Search')]");
142         waitAndClickByXpath("//a[contains(text(),'edit')]");
143         selectFrameIframePortlet();
144         waitAndClickByXpath("//a/div[contains(text(),'CmpdTestRule: For testing compound props')]");
145         waitAndClickByXpath("//button[contains(text(),'Edit Rule')]");
146         selectFrameIframePortlet();
147         waitForTextPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )");
148         selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[1].data.proposition.compoundOpCode","OR");
149         selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[3].data.proposition.compoundOpCode","OR");
150         waitForTextNotPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )");
151         waitForTextPresent("( Campus Code = Muir OR Campus Code = Revelle OR Campus Code = Warren )");
152     }
153 
154     protected void testAgendaEditorEditRuleAddActionsBlank() throws Exception {
155         //Save & Submit
156         testFillRequiredDetails("",null);
157         waitForTextPresent("INITIATED");
158         waitAndClickButtonByExactText("Save");
159         waitForTextPresent("SAVED");
160         waitForTextPresent(" Document was successfully saved.");
161         waitAndClickButtonByExactText("Submit");
162         waitAndClickConfirmSubmitOk();
163         waitForTextPresent("ENROUTE");
164         waitForTextPresent("Document was successfully submitted.");
165 
166         //Blanket Approve
167         selectParentWindow();
168         waitAndClickMainMenu();
169         navigate();
170         testFillRequiredDetails("",null);
171         waitForTextPresent("INITIATED");
172         waitAndClickButtonByExactText("Blanket Approve");
173         waitAndClickConfirmBlanketApproveOk();
174     }
175 
176     protected void testAgendaEditorEditRuleAddActionsKrmsActionResolverType() throws Exception {
177         //Save & Submit
178         selectParentWindow();
179         waitAndClickMainMenu();
180         navigate();
181         testFillRequiredDetails("KrmsActionResolverType",null);
182         waitForTextPresent("INITIATED");
183         waitAndClickButtonByExactText("Save");
184         waitForTextPresent("SAVED");
185         waitForTextPresent(" Document was successfully saved.");
186         waitAndClickButtonByExactText("Submit");
187         waitAndClickConfirmSubmitOk();
188         waitForTextPresent("ENROUTE");
189         waitForTextPresent("Document was successfully submitted.");
190 
191         //Blanket Approve
192         selectParentWindow();
193         waitAndClickMainMenu();
194         navigate();
195         testFillRequiredDetails("KrmsActionResolverType",null);
196         waitForTextPresent("INITIATED");
197         waitAndClickButtonByExactText("Blanket Approve");
198         waitAndClickConfirmBlanketApproveOk();
199     }
200 
201     protected void testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(String peopleFlowId) throws Exception {
202         //Save & Submit
203         selectParentWindow();
204         waitAndClickMainMenu();
205         navigate();
206         testFillRequiredDetails("Notify PeopleFlow",peopleFlowId);
207         waitForTextPresent("INITIATED");
208         waitAndClickButtonByExactText("Save");
209         waitForTextPresent("SAVED");
210         waitForTextPresent(" Document was successfully saved.");
211         waitAndClickButtonByExactText("Submit");
212         waitAndClickConfirmSubmitOk();
213         waitForTextPresent("ENROUTE");
214         waitForTextPresent("Document was successfully submitted.");
215 
216         //Blanket Approve
217         selectParentWindow();
218         waitAndClickMainMenu();
219         navigate();
220         testFillRequiredDetails("Notify PeopleFlow",peopleFlowId);
221         waitForTextPresent("INITIATED");
222         waitAndClickButtonByExactText("Blanket Approve");
223         waitAndClickConfirmBlanketApproveOk();
224     }
225 
226     protected void testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(String peopleFlowId) throws Exception {
227         //Save & Submit
228         selectParentWindow();
229         waitAndClickMainMenu();
230         navigate();
231         testFillRequiredDetails("Route to PeopleFlow",peopleFlowId);
232         waitForTextPresent("INITIATED");
233         waitAndClickButtonByExactText("Save");
234         waitForTextPresent("SAVED");
235         waitForTextPresent(" Document was successfully saved.");
236         waitAndClickButtonByExactText("Submit");
237         waitAndClickConfirmSubmitOk();
238         waitForTextPresent("ENROUTE");
239         waitForTextPresent("Document was successfully submitted.");
240 
241         //Blanket Approve
242         selectParentWindow();
243         waitAndClickMainMenu();
244         navigate();
245         testFillRequiredDetails("Route to PeopleFlow",peopleFlowId);
246         waitForTextPresent("INITIATED");
247         waitAndClickButtonByExactText("Blanket Approve");
248         waitAndClickConfirmBlanketApproveOk();
249     }
250 
251     protected void testAgendaEditorEditRuleAddActionsValidationAction() throws Exception {
252         //Save & Submit
253         selectParentWindow();
254         waitAndClickMainMenu();
255         navigate();
256         testFillRequiredDetails("Validation Action",null);
257         waitForTextPresent("INITIATED");
258         waitAndClickButtonByExactText("Save");
259         waitForTextPresent("SAVED");
260         waitForTextPresent(" Document was successfully saved.");
261         waitAndClickButtonByExactText("Submit");
262         waitAndClickConfirmSubmitOk();
263         waitForTextPresent("ENROUTE");
264         waitForTextPresent("Document was successfully submitted.");
265 
266         //Blanket Approve
267         selectParentWindow();
268         waitAndClickMainMenu();
269         navigate();
270         testFillRequiredDetails("Validation Action",null);
271         waitForTextPresent("INITIATED");
272         waitAndClickButtonByExactText("Blanket Approve");
273         waitAndClickConfirmBlanketApproveOk();
274     }
275 
276     private void testFillRequiredDetails(String selectValue,String peopleFlowId) throws Exception {
277         selectFrameIframePortlet();
278         waitClearAndType("lookupCriteria[id]", ID_TEXT);
279         waitAndClickByXpath("//button[contains(text(),'Search')]");
280         waitAndClickByXpath("//a[contains(text(),'edit')]");
281         selectFrameIframePortlet();
282         waitAndClickByXpath("//a[@class='agendaNode ruleNode']");
283         waitAndClickByXpath("//button[contains(text(),'Edit Rule')]");
284         selectFrameIframePortlet();
285         selectByName("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.typeId", selectValue);
286 
287         if (selectValue.equals("KrmsActionResolverType") || selectValue.equalsIgnoreCase("Validation Action")){
288             waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "ActionName");
289         }
290 
291         waitForElementPresentByXpath("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]");
292 
293         if(selectValue.equalsIgnoreCase("Notify PeopleFlow") || selectValue.equalsIgnoreCase("Route to PeopleFlow")){
294             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]", peopleFlowId);
295             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowName]", "Document Name1412916151718sz");
296             waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "test");
297         }else if(selectValue.equalsIgnoreCase("Validation Action")) {
298             waitAndClickByName("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionTypeCode]");
299             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionMessage]","This is msg");
300         }
301         waitAndClickButtonByExactText("Update Rule");
302         acceptAlertIfPresent();
303     }
304 
305     protected void waitClearAndType(String name, String value) throws Exception {
306         clearTextByName(name);
307         waitAndTypeByName(name,value);
308     }
309 
310     @Test
311     public void testAgendaEditorAndOrToggleSyncBookmark() throws Exception {
312         testAgendaEditorAndOrToggleSync();
313         passed();
314     }
315 
316     @Test
317     public void testAgendaEditorAndOrToggleSyncNav() throws Exception {
318         testAgendaEditorAndOrToggleSync();
319         passed();
320     }
321 
322     @Test
323     public void testAgendaEditorAddActionsBookmark() throws Exception {
324         String peopleFlowId = getPeopleFlowId();
325         testAgendaEditorEditRuleAddActionsBlank();
326         testAgendaEditorEditRuleAddActionsKrmsActionResolverType();
327         testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId);
328         testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId);
329         testAgendaEditorEditRuleAddActionsValidationAction();
330         passed();
331     }
332 
333     @Test
334     public void testAgendaEditorAddActionsNav() throws Exception {
335         String peopleFlowId = getPeopleFlowId();
336         testAgendaEditorEditRuleAddActionsBlank();
337         testAgendaEditorEditRuleAddActionsKrmsActionResolverType();
338         testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId);
339         testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId);
340         testAgendaEditorEditRuleAddActionsValidationAction();
341         passed();
342     }
343 }
344