View Javadoc
1   /**
2    * Copyright 2005-2015 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         submit();
120 
121         return new PeopleFlowDocInfo(docId, peopleFlowNamespace, peopleFlowName);
122     }
123 
124     @Override
125     protected String getBookmarkUrl() {
126         return BOOKMARK_URL;
127     }
128 
129     @Override
130     protected void navigate() throws Exception {
131         waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
132         waitForPageToLoad();
133     }
134 
135     protected void testAgendaEditorAndOrToggleSync() throws Exception {
136         selectFrameIframePortlet();
137         waitClearAndType("lookupCriteria[name]", "SimpleAgendaCompoundProp");
138         waitAndClickByXpath("//button[contains(text(),'Search')]");
139         waitAndClickByXpath("//a[contains(text(),'edit')]");
140         selectFrameIframePortlet();
141         waitAndClickByXpath("//a/div[contains(text(),'CmpdTestRule: For testing compound props')]");
142         waitAndClickByXpath("//button[contains(text(),'Edit Rule')]");
143         selectFrameIframePortlet();
144         waitForTextPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )");
145         selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[1].data.proposition.compoundOpCode","OR");
146         selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[3].data.proposition.compoundOpCode","OR");
147         waitForTextNotPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )");
148         waitForTextPresent("( Campus Code = Muir OR Campus Code = Revelle OR Campus Code = Warren )");
149     }
150 
151     protected void testAgendaEditorEditRuleAddActionsBlank() throws Exception {
152         //Save & Submit
153         testFillRequiredDetails("", null);
154         save();
155         submit();
156 
157         //Blanket Approve
158         selectParentWindow();
159         waitAndClickMainMenu();
160         navigate();
161         testFillRequiredDetails("",null);
162         waitForTextPresent("INITIATED");
163         waitAndClickButtonByExactText("Blanket Approve");
164         waitAndClickConfirmBlanketApproveOk();
165     }
166 
167     protected void save() throws InterruptedException {
168         waitForTextPresent("INITIATED");
169         waitAndClickButtonByExactText("Save");
170         waitForProgressSaving();
171         waitForTextPresent("SAVED");
172         waitForTextPresent(" Document was successfully saved.");
173     }
174 
175     protected void testAgendaEditorEditRuleAddActionsKrmsActionResolverType() throws Exception {
176         //Save & Submit
177         selectParentWindow();
178         waitAndClickMainMenu();
179         navigate();
180         testFillRequiredDetails("KrmsActionResolverType", null);
181         save();
182         submit();
183 
184         //Blanket Approve
185         selectParentWindow();
186         waitAndClickMainMenu();
187         navigate();
188         testFillRequiredDetails("KrmsActionResolverType",null);
189         waitForTextPresent("INITIATED");
190         waitAndClickButtonByExactText("Blanket Approve");
191         waitAndClickConfirmBlanketApproveOk();
192     }
193 
194     protected void submit() throws InterruptedException {
195         waitAndClickButtonByExactText("Submit");
196         waitAndClickConfirmSubmitOk();
197         waitForTextPresent("ENROUTE");
198         waitForTextPresent("Document was successfully submitted.");
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         save();
208         submit();
209 
210         //Blanket Approve
211         selectParentWindow();
212         waitAndClickMainMenu();
213         navigate();
214         testFillRequiredDetails("Notify PeopleFlow",peopleFlowId);
215         waitForTextPresent("INITIATED");
216         waitAndClickButtonByExactText("Blanket Approve");
217         waitAndClickConfirmBlanketApproveOk();
218     }
219 
220     protected void testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(String peopleFlowId) throws Exception {
221         //Save & Submit
222         selectParentWindow();
223         waitAndClickMainMenu();
224         navigate();
225         testFillRequiredDetails("Route to PeopleFlow", peopleFlowId);
226         save();
227         submit();
228 
229         //Blanket Approve
230         selectParentWindow();
231         waitAndClickMainMenu();
232         navigate();
233         testFillRequiredDetails("Route to PeopleFlow",peopleFlowId);
234         waitForTextPresent("INITIATED");
235         waitAndClickButtonByExactText("Blanket Approve");
236         waitAndClickConfirmBlanketApproveOk();
237     }
238 
239     protected void testAgendaEditorEditRuleAddActionsValidationAction() throws Exception {
240         //Save & Submit
241         selectParentWindow();
242         waitAndClickMainMenu();
243         navigate();
244         testFillRequiredDetails("Validation Action",null);
245         save();
246         submit();
247 
248         //Blanket Approve
249         selectParentWindow();
250         waitAndClickMainMenu();
251         navigate();
252         testFillRequiredDetails("Validation Action",null);
253         waitForTextPresent("INITIATED");
254         waitAndClickButtonByExactText("Blanket Approve");
255         waitAndClickConfirmBlanketApproveOk();
256     }
257 
258     private void testFillRequiredDetails(String selectValue,String peopleFlowId) throws Exception {
259         selectFrameIframePortlet();
260         waitClearAndType("lookupCriteria[id]", ID_TEXT);
261         waitAndClickByXpath("//button[contains(text(),'Search')]");
262         waitAndClickByXpath("//a[contains(text(),'edit')]");
263         selectFrameIframePortlet();
264         waitAndClickByXpath("//a[@class='agendaNode ruleNode']");
265         waitAndClickByXpath("//button[contains(text(),'Edit Rule')]");
266         selectFrameIframePortlet();
267         selectByName("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.typeId", selectValue);
268 
269         if (selectValue.equals("KrmsActionResolverType") || selectValue.equalsIgnoreCase("Validation Action")){
270             waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "ActionName");
271         }
272 
273         waitForElementPresentByXpath("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]");
274 
275         if(selectValue.equalsIgnoreCase("Notify PeopleFlow") || selectValue.equalsIgnoreCase("Route to PeopleFlow")){
276             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]", peopleFlowId);
277             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowName]", "Document Name1412916151718sz");
278             waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "test");
279         }else if(selectValue.equalsIgnoreCase("Validation Action")) {
280             waitAndClickByName("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionTypeCode]");
281             waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionMessage]","This is msg");
282         }
283         waitAndClickButtonByExactText("Update Rule");
284         acceptAlertIfPresent();
285     }
286 
287     protected void waitClearAndType(String name, String value) throws Exception {
288         clearTextByName(name);
289         waitAndTypeByName(name,value);
290     }
291 
292     @Test
293     public void testAgendaEditorAndOrToggleSyncBookmark() throws Exception {
294         testAgendaEditorAndOrToggleSync();
295         passed();
296     }
297 
298     @Test
299     public void testAgendaEditorAndOrToggleSyncNav() throws Exception {
300         testAgendaEditorAndOrToggleSync();
301         passed();
302     }
303 
304     @Test
305     public void testAgendaEditorAddActionsBookmark() throws Exception {
306         String peopleFlowId = getPeopleFlowId();
307         testAgendaEditorEditRuleAddActionsBlank();
308         testAgendaEditorEditRuleAddActionsKrmsActionResolverType();
309         testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId);
310         testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId);
311         testAgendaEditorEditRuleAddActionsValidationAction();
312         passed();
313     }
314 
315     @Test
316     public void testAgendaEditorAddActionsNav() throws Exception {
317         String peopleFlowId = getPeopleFlowId();
318         testAgendaEditorEditRuleAddActionsBlank();
319         testAgendaEditorEditRuleAddActionsKrmsActionResolverType();
320         testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId);
321         testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId);
322         testAgendaEditorEditRuleAddActionsValidationAction();
323         passed();
324     }
325 }
326