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 org.kuali.rice.krad.labs.lookups;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20  import org.openqa.selenium.By;
21  import org.openqa.selenium.WebElement;
22  
23  import java.util.List;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class LabsLookupDefaultCreateNewBlanketApproveAft extends LabsLookupBase {
29  
30      /**
31       * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true
32       */
33      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true";
34      
35      @Override
36      protected String getBookmarkUrl() {
37          return BOOKMARK_URL;
38      }
39  
40      @Override
41      public String getUserName() {
42          return "admin"; // must have blanket approve rights
43      }
44  
45      @Override
46      protected void navigate() throws Exception {
47          navigateToLookup("Lookup Default");
48      }
49  
50      @Test
51      public void testLabsLookupDefaultCreateNewBlanketApproveBookmark() throws Exception {
52          String account = uniqueAccount();
53          testLabsLookupDefaultCreateNewBlanketApprove(account);
54          passed();
55      }
56  
57      private String uniqueAccount() {
58          return "z" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
59      }
60  
61      @Test
62      public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountBookmark() throws Exception {
63          testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(uniqueAccount());
64          passed();
65      }
66  
67      @Test
68      public void testLabsLookupDefaultCreateNewBlanketApproveNav() throws Exception {
69          testLabsLookupDefaultCreateNewBlanketApprove(uniqueAccount());
70          passed();
71      }
72  
73      @Test
74      public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountNav() throws Exception {
75          testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(uniqueAccount());
76          passed();
77      }
78  
79      protected void testLabsLookupDefaultCreateNewBlanketApprove(String account)throws Exception {
80          navigateToCreateNew();
81          waitAndTypeByName("document.documentHeader.documentDescription","Labs Default LookUp Created " + account);
82          waitAndTypeByName("document.newMaintainableObject.dataObject.number", account);
83          waitAndTypeByName("document.newMaintainableObject.dataObject.name",account);
84          waitAndTypeByName("document.newMaintainableObject.dataObject.foId","fran");
85  //        waitAndTypeByName("document.newMaintainableObject.dataObject.createDate", "01/01/2012"); // no longer input field
86          waitAndClickByXpath("//input[@value='CAT']");
87  
88          waitAndClickByLinkText("Notes and Attachments (0)");
89          waitAndTypeByXpath("//textarea[@maxlength='800']","My Note " + account);
90          waitAndClickByXpath("//button[@title='Add a Note']");
91          waitAndClickByLinkText("Ad Hoc Recipients");
92          waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input","admin");
93          waitAndClickAdHocPersonAdd();
94          waitForTextPresent("admin, admin");
95          waitAndClickByXpath("//button[@id='Uif-AdHocPersonCollection_add']");
96          waitAndClickBlanketApprove();
97  //        waitForElementPresent("img[src*=\"info.png\"]"); // Loading to quick?
98  
99  // Blanket submit has been updated to go to the hub page so error messages and doc state are no longer testable
100 //        if (isElementPresentByXpath("//li[@class='uif-errorMessageItem']")) {
101 //            failOnDocErrors();
102 //        }
103 //
104 //        assertTextPresent(new String[] {"Document was successfully approved.", "ENROUTE"});
105     }
106 
107     protected void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(String account)throws Exception {
108         navigateToCreateNew();
109         waitAndTypeByName("document.documentHeader.documentDescription","Labs Default LookUp Created " + account);
110         waitAndTypeByName("document.newMaintainableObject.dataObject.number", account);
111         waitAndTypeByName("document.newMaintainableObject.dataObject.name", account);
112         waitAndTypeByName("document.newMaintainableObject.dataObject.foId","fran");
113 //        waitAndTypeByName("document.newMaintainableObject.dataObject.createDate", "01/01/2012"); // no longer an input field
114         waitAndClickByXpath("//input[@value='CAT']");
115 
116         waitAndTypeByXpath("//div[@data-label='Travel Sub Account Number']/input","1");
117         waitAndTypeByXpath("//div[@data-label='Sub Account Name']/input","Sub Account");
118         waitAndClickButtonByText("Add");
119 
120         waitAndClickByLinkText("Notes and Attachments (0)");
121         waitAndTypeByXpath("//textarea[@maxlength='800']","My Note " + account);
122         waitAndClickByXpath("//button[@title='Add a Note']");
123         waitAndClickByLinkText("Ad Hoc Recipients");
124         waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input","admin");
125         waitAndClickAdHocPersonAdd();
126         waitForTextPresent("admin, admin");
127         waitAndClickByXpath("//button[@id='Uif-AdHocPersonCollection_add']");
128         waitAndClickBlanketApprove();
129 //        waitForElementPresent("img[src*=\"info.png\"]"); // Loading to quick?
130 // Blanket approve now redirects to the hub so error messagea and doc status are no longer testable https://jira.kuali.org/browse/KULRICE-11463
131 //        if (isElementPresentByXpath("//li[@class='uif-errorMessageItem']")) {
132 //            failOnDocErrors();
133 //        }
134 //
135 //        assertTextPresent(new String[] {"Document was successfully approved.", "ENROUTE"});
136     }
137 }