001 /**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.admin;
017
018 import org.junit.Test;
019 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021 import org.kuali.rice.testtools.selenium.WebDriverUtils;
022 import org.openqa.selenium.By;
023 import org.openqa.selenium.WebElement;
024
025 import java.util.List;
026
027 import static org.junit.Assert.assertEquals;
028
029 /**
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class DocSearchAft extends WebDriverLegacyITBase {
033
034 public static String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Type&channelUrl=" + WebDriverUtils
035 .getBaseUrlString() + "/kr/lookup.do?methodToCall=start&businessObjectClassName=org.kuali.rice.kew.doctype.bo.DocumentType&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
036
037 String docId;
038 String parentName;
039
040 @Override
041 protected String getBookmarkUrl() {
042 return BOOKMARK_URL;
043 }
044
045 public void createAndSaveDoc() throws Exception{
046 waitForTitleToEqualKualiPortalIndex();
047 waitAndClickByLinkText("Administration");
048 waitForTitleToEqualKualiPortalIndex();
049 waitAndClickByLinkText("Document Type");
050 waitForTitleToEqualKualiPortalIndex();
051 selectFrame("iframeportlet");
052 waitAndClickByXpath("//img[contains(@alt,'create new')]");
053 waitForElementPresentByXpath("//*[@name='methodToCall.route' and @alt='submit']","save button does not exist on the page");
054 waitForElementPresentByXpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
055 docId = driver.findElement(By.xpath("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]")).getText();
056 waitAndTypeByXpath("//input[@id='document.documentHeader.documentDescription']", "Creating new Document Type");
057 String parentDocType = "//input[@name='methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:document.newMaintainableObject.parentDocType.name,documentTypeId:document.newMaintainableObject.docTypeParentId,))).((`document.newMaintainableObject.parentDocType.name:name,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + getBaseUrlString() + "/kr/lookup.do;::::).anchor4']";
058 waitAndClickByXpath(parentDocType);
059 waitAndClickByXpath("//input[@name='methodToCall.search' and @value='search']");
060 waitForPageToLoad();
061 parentName= driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[3]")).getText();
062 waitAndClickByLinkText("return value");
063 String docTypeName = "TestDocType " + AutomatedFunctionalTestUtils.DTS;
064 waitForElementPresentByXpath("//input[@id='document.newMaintainableObject.name']");
065 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.name']", docTypeName);
066 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedDocHandlerUrl']", "${kr.url}/maintenance.do?methodToCall=docHandler");
067 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.actualNotificationFromAddress']", "NFA");
068 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.label']", "TestDocument Label");
069 waitAndTypeByXpath("//input[@id='document.newMaintainableObject.unresolvedHelpDefinitionUrl']", "default.htm?turl=WordDocuments%2Fdocumenttype.htm");
070 waitAndClickByXpath("//input[@name='methodToCall.save' and @alt='save']");
071 // TODO wait for save confirmation
072 //checkForIncidentReport();
073 selectTopFrame();
074 }
075 @Test
076 public void testBasicDocSearchBookmark() throws Exception {
077 createAndSaveDoc();
078 waitAndClickByXpath("//a/img[@alt='doc search']");
079 waitForPageToLoad();
080 selectFrame("iframeportlet");
081 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
082 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
083 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
084 waitAndTypeByName("documentTypeName", "DocumentTypeDocument");
085 waitAndTypeByName("initiatorPrincipalName", "admin");
086 waitAndTypeByName("documentId", docId);
087 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
088 //waitAndTypeByName("dateCreated", "10/13/2010");
089 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
090 assertEquals(docId, waitFor(By.xpath("//table[@id='row']/tbody/tr[1]/td[1]/a")).getText());
091 //Thread.sleep(2000);
092 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
093 assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).getAttribute("value"));
094 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
095 assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).getAttribute("value"));
096 assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).getAttribute("value"));
097 assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).getAttribute("value"));
098 waitAndClickByXpath("//a[@title='cancel']");
099 }
100
101 @Test
102 public void testBasicFullDocSearchBookmark() throws Exception {
103 waitAndClickByXpath("//a/img[@alt='doc search']");
104 waitForPageToLoad();
105 selectFrame("iframeportlet");
106 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
107 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
108 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
109 waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "1/1/1900"); // remove default today's date
110 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
111 waitForTextPresent("Export options:");
112 }
113
114 @Test
115 public void testDetailedDocSearchBookmark() throws Exception{
116 createAndSaveDoc();
117 waitAndClickByXpath("//a/img[@alt='doc search']");
118 waitForPageToLoad();
119 selectFrame("iframeportlet");
120 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
121 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
122 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
123 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
124 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='basic search']", "DocSearchAft.testDetailedDocSearch");
125 //waitAndTypeByName("documentTypeName", parentName);
126 waitAndTypeByName("initiatorPrincipalName", "admin");
127 waitAndTypeByName("documentId", docId);
128 //waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated", "10/01/2010");
129 //waitAndTypeByName("dateCreated", "10/13/2010");
130 assertElementPresentByName("approverPrincipalName", "Approver input field is not there in the detailed search");
131 //waitAndTypeByName("approverPrincipalName", "director");
132 assertElementPresentByName("viewerPrincipalName", "Viewer input field is not there in the detailed search");
133 //waitAndTypeByName("viewerPrincipalName", "superviser");
134 assertElementPresentByXpath("//select[@id='statusCode']", "Document Status select field is not there in the detailed search");
135 selectByXpath("//select[@id='statusCode']", "- SAVED");
136 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
137 waitForPageToLoad();
138 assertTrue(driver.findElement(By.id("row")).getText().contains("SAVED"));
139 assertElementPresentByXpath("//table[@id='row']/tbody/tr[1]/td[contains(a,'admin')]");
140 //Thread.sleep(2000);
141 waitAndClickByXpath("//input[@name='methodToCall.clearValues' and @alt='clear']");
142 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentTypeName']")).waitAndGetAttribute("value"));
143 assertEquals("", driver.findElement(By.xpath("//input[@name='initiatorPrincipalName']")).getAttribute("value"));
144 //assertEquals("", driver.findElement(By.xpath("//input[@name='documentId']")).waitAndGetAttribute("value"));
145 //assertEquals("", driver.findElement(By.xpath("//input[@name='rangeLowerBoundKeyPrefix_dateCreated']")).waitAndGetAttribute("value"));
146 //assertEquals("", driver.findElement(By.xpath("//input[@name='dateCreated']")).waitAndGetAttribute("value"));
147 waitAndClickByXpath("//a[@title='cancel']");
148 passed();
149 }
150
151 @Test
152 public void testSuperUserSearchBookmark() throws Exception{
153 createAndSaveDoc();
154 waitAndClickByXpath("//a/img[@alt='doc search']");
155 waitForPageToLoad();
156 selectFrame("iframeportlet");
157 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
158 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
159 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
160 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
161 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='non-superuser search']", "DocSearchAft.testSuperUserSearch");
162 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
163 waitAndClickByXpath("//table[@id='row']/tbody/tr[1]/td[1]/a");
164 selectTopFrame();
165 Thread.sleep(3000);
166 switchToWindow("Kuali :: Superuser Document Service");
167 waitForPageToLoad();
168 //Thread.sleep(4000);
169
170 waitAndClickByXpath("//input[@src='images/buttonsmall_complete.gif']");
171 waitForElementPresentByName("methodToCall.approve","approve button does not exist on the page");
172 assertElementPresentByName("methodToCall.disapprove","disapprove button does not exist on the page");
173 assertElementPresentByName("methodToCall.cancel","cancel button does not exist on the page");
174 waitAndClickByName("methodToCall.approve","approve button does not exist on the page");
175 waitAndClickByXpath("//a[@href='DocumentSearch.do']/img[@alt='cancel']");
176 waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
177 waitForPageToLoad();
178 assertEquals("FINAL", driver.findElement(By.xpath("//table[@id='row']/tbody/tr[1]/td[4]")).getText());
179 passed();
180 }
181
182 @Test
183 public void testClearSavedSearchesBookmark() throws Exception{
184 waitAndClickByXpath("//a/img[@alt='doc search']");
185 waitForPageToLoad();
186 selectFrame("iframeportlet");
187 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
188 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
189 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
190 waitAndClickByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
191 waitForPageToLoad();
192 WebElement select1 = findElement(By.xpath("//select[@id='savedSearchToLoadAndExecute']"));
193 List<WebElement> options = select1.findElements(By.tagName("option"));
194 int count= options.size();
195 assertEquals(5,count);
196 passed();
197 }
198
199 @Test
200 public void testAjaxPageReloadBookmark() throws Exception{
201 waitAndClickByXpath("//a/img[@alt='doc search']");
202 waitForPageToLoad();
203 selectFrame("iframeportlet");
204 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='detailed search']");
205 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='superuser search']");
206 waitForElementPresentByXpath("//div[@class='lookupcreatenew']/input[@alt='clear saved searches search']");
207 waitForElementPresentByXpath("//select[@id='savedSearchToLoadAndExecute']");
208 waitAndTypeByName("documentTypeName", "KualiNotification");
209 Thread.sleep(2000);
210 fireEvent("documentTypeName", "blur");
211 waitForElementPresentByName("documentAttribute.notificationContentType");
212 assertElementPresentByName("documentAttribute.notificationChannel");
213 assertElementPresentByName("documentAttribute.notificationProducer");
214 assertElementPresentByName("documentAttribute.notificationPriority");
215 assertElementPresentByName("documentAttribute.notificationRecipients");
216 assertElementPresentByName("documentAttribute.notificationSenders");
217 waitAndClickByXpath("//a[@title='cancel']");
218 passed();
219 }
220 }