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.demo.travel.application;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kew.api.action.ActionRequestType;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  /**
25   * Tests the copy action in a transactional document.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class DemoTravelAuthorizationCopyAft extends WebDriverLegacyITBase {
30  
31      /**
32       * /kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization
33       */
34      public static final String BOOKMARK_URL = "/kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization";
35  
36      private static final String DOCUMENT_DESCRIPTION_FIELD = "document.documentHeader.documentDescription";
37      private static final String CONTACT_NUMBER_FIELD = "document.cellPhoneNumber";
38  
39      private static final String DOCUMENT_DESCRIPTION_VALUE = "Test Pessimistic Locking";
40      private static final String CONTACT_NUMBER_VALUE = "555-555-5555";
41  
42      @Override
43      protected String getBookmarkUrl() {
44          return BOOKMARK_URL;
45      }
46  
47      @Override
48      protected void navigate() throws Exception {
49          waitAndClickDemoLink();
50          waitAndClickByLinkText("Travel Authorization Document");
51      }
52  
53      /**
54       * Tests whether a document is locked for editing for any other user opening it before it has been routed.
55       *
56       * @throws Exception for any test exceptions
57       */
58      protected void testCopy() throws Exception {
59          String documentNumber = createTravelAuthorization();
60  
61          waitForElementNotPresent(By.cssSelector("div[data-label = 'Copied from Document Number']"));
62  
63          waitAndClick(By.cssSelector("button[data-submit_data = '{\\\"methodToCall\\\":\\\"copy\\\"}']"));
64  
65          assertElementPresent(By.cssSelector("div[data-label = 'Copied from Document Number']"));
66          WebElement element = findElement(By.xpath("//div[@data-label = 'Copied from Document Number']/span"));
67          assertEquals("Copied document number does not match old document", documentNumber, element.getText());
68      }
69  
70      private String createTravelAuthorization() throws Exception {
71          String documentNumber = waitForDocIdKrad();
72  
73          waitAndTypeByName(DOCUMENT_DESCRIPTION_FIELD, DOCUMENT_DESCRIPTION_VALUE);
74  
75          waitAndTypeByName(CONTACT_NUMBER_FIELD, CONTACT_NUMBER_VALUE);
76  
77          waitAndClick(By.cssSelector("div[data-label = 'Primary Destination Id'] button"));
78          gotoLightBox();
79          waitAndClickButtonByText(SEARCH);
80          waitAndClickByLinkText(RETURN_VALUE_LINK_TEXT);
81  
82          saveSuccessfully();
83  
84          return documentNumber;
85      }
86  
87      @Test
88      public void testCopyBookmark() throws Exception {
89          testCopy();
90          passed();
91      }
92  
93      @Test
94      public void testCopyNav() throws Exception {
95          testCopy();
96          passed();
97      }
98  
99  }