View Javadoc
1   /**
2    * Copyright 2005-2016 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.Before;
19  import org.junit.Test;
20  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class LabsLookupDefaultCreateNewBlanketApproveAft extends LabsLookupBase {
26  
27      /**
28       * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true";
31  
32      protected String[][] inputVerifyDetails;
33  
34      @Before
35      @Override
36      public void testSetUp() {
37          super.testSetUp();
38          getDescriptionUnique(); // init uniqueString
39          inputVerifyDetails = new String[][]{
40                  {"Travel Account Name:", uniqueString},
41                  {"Travel Account Number:", "z" + uniqueString.substring(4, 13)},
42                  {"Fiscal Officer User ID:", "fran"},
43                  {"Fiscal Officer:", "fran"},
44                  {"Fiscal Officer Name:", "fran"},
45                  {"Code And Description:", "CAT - Clearing"}
46          };
47      }
48  
49      @Override
50      protected void blanketApproveSuccessfully() throws InterruptedException {
51          waitAndClickBlanketApprove();
52          waitAndClickConfirmBlanketApproveOk();
53          acceptAlertIfPresent(); // LabsLookupDefaultCreateNewBlanketApproveAft
54          waitForProgressLoading();
55  // Blanket submit has been updated to go to the hub page so error messages and doc state are no longer testable
56  //        checkForDocErrorKrad();
57  //        waitForTextPresent("Document was successfully approved.");
58      }
59  
60  
61      @Override
62      protected String getBookmarkUrl() {
63          return BOOKMARK_URL;
64      }
65  
66      @Override
67      public String getUserName() {
68          return "admin"; // must have blanket approve rights
69      }
70  
71      @Override
72      protected String getDescriptionUnique() {
73          // "z" + to keep these at the bottom of the search results so as not to interfere with other AFTs.
74          if (uniqueString == null) {
75              uniqueString = "z" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
76          }
77          return getDescriptionBase() + " " + uniqueString;
78      }
79  
80      @Override
81      protected void navigate() throws Exception {
82          navigateToLookup("Lookup Default");
83      }
84  
85      @Test
86      public void testLabsLookupDefaultCreateNewBlanketApproveBookmark() throws Exception {
87          testLabsLookupDefaultCreateNewBlanketApprove();
88          passed();
89      }
90  
91      @Test
92      public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountBookmark() throws Exception {
93          testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount();
94          passed();
95      }
96  
97      @Test
98      public void testLabsLookupDefaultCreateNewBlanketApproveNav() throws Exception {
99          testLabsLookupDefaultCreateNewBlanketApprove();
100         passed();
101     }
102 
103     @Test
104     public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountNav() throws Exception {
105         testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount();
106         passed();
107     }
108 
109     protected void testLabsLookupDefaultCreateNewBlanketApprove()throws Exception {
110         navigateToCreateNew();
111 
112         // TODO method that accepts full array
113         // TODO flag requires or determine via UI (*) what is required (could miss changes)
114         waitAndTypeLabeledInput("Description:", getDescriptionUnique());
115         waitAndTypeLabeledInput(inputVerifyDetails[0][0], inputVerifyDetails[0][1]);
116         waitAndTypeLabeledInput("Travel Account Number:", inputVerifyDetails[1][1]);
117         waitAndTypeLabeledInput("Fiscal Officer User ID:", inputVerifyDetails[2][1]);
118         waitAndClickByXpath("//input[@value='CAT']");
119 
120         // TODO convenience method
121         waitAndClickByLinkText("Notes and Attachments (0)");
122         waitAndTypeByXpath("//textarea[@maxlength='800']", "My Note " + uniqueString);
123         waitAndClickByXpath("//button[@title='Add a Note']");
124         waitForProgressLoading();
125 
126         // TODO convenience method
127         waitAndClickByLinkText("Ad Hoc Recipients");
128         waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input", "admin");
129         waitAndClickAdHocPersonAdd();
130         waitForTextPresent("admin, admin");
131 
132         blanketApproveSuccessfully();
133 
134         // search based on name and verify
135         open(getBaseUrlString() + LabsLookupDefaultAft.BOOKMARK_URL);
136         waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]);
137         waitAndClickSearchByText();
138         waitForProgressLoading();
139         waitAndClickLinkContainingText(inputVerifyDetails[1][1]); // "Travel Account Number:"
140         waitForProgressLoading();
141         gotoLightBox();
142         assertLabeledTextPresent(inputVerifyDetails);
143     }
144 
145     protected void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount()throws Exception {
146         navigateToCreateNew();
147 
148         waitAndTypeLabeledInput("Description:", getDescriptionUnique());
149         waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]);
150         waitAndTypeLabeledInput("Travel Account Number:", inputVerifyDetails[1][1]);
151         waitAndTypeLabeledInput("Fiscal Officer User ID:", inputVerifyDetails[2][1]);
152         waitAndClickByXpath("//input[@value='CAT']");
153 
154         waitAndTypeLabeledInput("Travel Sub Account Number:", uniqueString.substring(0,7) + "sa");
155         waitAndTypeLabeledInput("Sub Account Name:", "Sub Account " + uniqueString);
156         waitAndClickButtonByText("Add");
157         waitForProgressAddingLine();
158 
159         waitAndClickByLinkText("Notes and Attachments (0)");
160         waitAndTypeByXpath("//textarea[@maxlength='800']", "My Note " + uniqueString);
161         waitAndClickByXpath("//button[@title='Add a Note']");
162         waitForProgressLoading();
163 
164         waitAndClickByLinkText("Ad Hoc Recipients");
165         waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input", "admin");
166         waitAndClickAdHocPersonAdd();
167         waitForTextPresent("admin, admin");
168 
169         blanketApproveSuccessfully();
170 
171         // search based on name and verify
172         open(getBaseUrlString() + LabsLookupDefaultAft.BOOKMARK_URL);
173         waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]);
174         waitAndClickSearchByText();
175         waitForProgressLoading();
176         waitAndClickLinkContainingText(inputVerifyDetails[1][1]); // "Travel Account Number:"
177         waitForProgressLoading();
178         gotoLightBox();
179         assertLabeledTextPresent(inputVerifyDetails);
180         // Travel Sub Account Number should be uppercased via UI
181         assertTextPresent(new String[]{(uniqueString.substring(0,7) + "sa").toUpperCase(), "Sub Account " + uniqueString});
182     }
183 }