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 */
016package edu.sampleu.admin;
017
018import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
019import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
020import org.kuali.rice.testtools.selenium.WebDriverUtils;
021import org.apache.commons.lang.RandomStringUtils;
022import org.junit.Test;
023
024/**
025 * Tests whether the ENABLE_FIELD_LEVEL_HELP_IND parameter is being considered and loaded on each request.
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029public class DetailedDocSearchAft extends WebDriverLegacyITBase {
030    /*
031     * AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Search&channelUrl=" + WebDriverUtils
032     * .getBaseUrlString() + "/kew/DocumentSearch.do?docFormKey=88888888&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
033     */
034    
035    public static String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Search&channelUrl=" + WebDriverUtils
036            .getBaseUrlString() + "/kew/DocumentSearch.do?docFormKey=88888888&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
037
038    private String groupId = null;
039    
040    @Override
041    protected String getBookmarkUrl() {
042        return BOOKMARK_URL;
043    }
044
045    @Override
046    protected void navigate() throws Exception {
047       waitAndClickByXpath("//img[@alt='doc search']"); 
048    }
049
050    @Test
051    public void testAdvancedDocSearchNav() throws Exception {
052        advancedDocSearchAll();
053    }
054    
055    @Test
056    public void testAdvancedDocSearchBookmark() throws Exception {
057        advancedDocSearchAll();
058    }
059    
060    private void advancedDocSearchAll() throws Exception{
061        createGroupDocument();
062        selectTopFrame();
063        waitAndClickByXpath("//a[@title='Document Search']");
064        acceptAlertIfPresent();
065        selectFrameIframePortlet();
066        waitAndClickByName("toggleAdvancedSearch");
067        acceptAlertIfPresent();
068        searchByDocumentType();
069        searchByInitiator();
070        searchByApprover();
071        searchByViewer();
072        searchByGroupViewer();
073        searchByDocumentId();
074        searchByApplicationDocumentId();
075        searchByDocumentStatus();
076        searchByDateCreatedFrom();
077        searchByDateCreatedTo();
078        searchByDateApprovedFrom();
079        searchByDateApprovedTo();
080        searchByDateLastModifiedFrom();
081        searchByDateLastModifiedTo();
082        searchByDateLastFinalizedFrom();
083        searchByDateLastFinalizedTo();
084        searchByTitle();
085    }
086    
087    private void createGroupDocument() throws Exception{
088        waitAndClickAdministration();
089        selectFrameIframePortlet();
090        waitAndClickByLinkText("Group");
091        selectFrameIframePortlet();
092        waitAndClickByXpath("//a[@title='Create a new record']");
093        selectFrameIframePortlet();
094        String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
095        waitAndSelectByName("document.groupNamespace","KR-BUS - Service Bus");
096        waitAndTypeByName("document.documentHeader.documentDescription","Group");
097        waitAndTypeByName("document.groupName","Group 1"+randomCode);
098        groupId=waitForElementPresentByXpath("//div[@id='tab-Overview-div']/div[@class='tab-container']/table/tbody/tr/td").getText();
099        waitAndClickByXpath("//input[@name='methodToCall.route']");
100    }
101
102    private void searchByDocumentType() throws Exception {
103        selectFrameIframePortlet();
104        waitAndTypeByName("documentTypeName","ParameterMaintenanceDocument");
105        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
106        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
107        waitForTextPresent("Parameter Maintenance Document");
108        waitAndClickByName("methodToCall.clearValues");
109    }
110    
111    private void searchByInitiator() throws Exception {
112        selectFrameIframePortlet();
113        waitAndTypeByName("initiatorPrincipalName","admin");
114        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
115        waitForTextPresent("items retrieved");
116        waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
117        waitAndClickByName("methodToCall.clearValues");
118    }
119
120    private void searchByApprover() throws Exception {
121        selectFrameIframePortlet();
122        waitAndTypeByName("approverPrincipalName","admin");
123        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
124//        waitForTextPresent("items retrieved");
125//        waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
126//        waitAndClickByName("methodToCall.clearValues");
127    }
128
129    private void searchByViewer() throws Exception {
130        waitAndTypeByName("viewerPrincipalName","admin");
131        clearTextByName("approverPrincipalName");
132        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
133        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
134        waitForTextPresent("items retrieved");
135        waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
136        waitAndClickByName("methodToCall.clearValues");
137    }
138    
139    private void searchByGroupViewer() throws Exception {
140        waitAndClickByXpath("//input[@type='image' and @alt='Search Group Viewer Id']");
141        selectFrameIframePortlet();
142        waitAndTypeByName("id",groupId);
143        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
144        waitAndClickLinkContainingText("return value");
145        selectFrameIframePortlet();
146        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
147        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
148        waitForTextPresent("Component Maintenance Document");
149        waitForElementPresentByXpath("//a[contains(text(),'admin, admin')]");
150        waitAndClickByName("methodToCall.clearValues");
151    }
152    
153    private void searchByDocumentId() throws Exception {
154        waitAndTypeByName("documentId","2700");
155        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
156        waitForElementPresentByXpath("//a[contains(text(),'2700')]");
157        waitAndClickByName("methodToCall.clearValues");
158    }
159    
160    private void searchByApplicationDocumentId() throws Exception {
161        waitAndTypeByName("applicationDocumentId","7777777");
162        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
163        waitForElementPresentByXpath("//a[contains(text(),'3221')]");
164        waitAndClickByName("methodToCall.clearValues");
165    }
166    
167    private void searchByDocumentStatus() throws Exception {
168        selectByName("statusCode","Successful Statuses");
169        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
170        waitForTextPresent("FINAL");
171        waitAndClickByName("methodToCall.clearValues");
172    }
173    
174    private void searchByDateCreatedFrom() throws Exception {
175        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","04/17/2005");
176        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
177        waitForTextPresent("items retrieved");
178        waitAndClickByName("methodToCall.clearValues");
179    }
180    
181    private void searchByDateCreatedTo() throws Exception {
182        waitAndTypeByName("dateCreated","04/17/2014");
183        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
184        waitForTextPresent("items retrieved");
185        waitAndClickByName("methodToCall.clearValues");
186    }
187    
188    private void searchByDateApprovedFrom() throws Exception {
189        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateApproved","04/17/2005");
190        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
191        waitForTextPresent("items retrieved");
192        waitAndClickByName("methodToCall.clearValues");
193    }
194    
195    private void searchByDateApprovedTo() throws Exception {
196        waitAndTypeByName("dateApproved","04/17/2014");
197        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
198        waitForTextPresent("items retrieved");
199        waitAndClickByName("methodToCall.clearValues");
200    }
201    
202    private void searchByDateLastModifiedFrom() throws Exception {
203        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateLastModified","04/17/2005");
204        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
205        waitForTextPresent("items retrieved");
206        waitAndClickByName("methodToCall.clearValues");
207    }
208 
209    private void searchByDateLastModifiedTo() throws Exception {
210        waitAndTypeByName("dateLastModified","04/17/2014");
211        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
212        waitForTextPresent("items retrieved");
213        waitAndClickByName("methodToCall.clearValues");
214    }
215    
216    private void searchByDateLastFinalizedFrom() throws Exception {
217        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateFinalized","04/17/2005");
218        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
219        waitForTextPresent("items retrieved");
220        waitAndClickByName("methodToCall.clearValues");
221    }
222
223    private void searchByDateLastFinalizedTo() throws Exception {
224        waitAndTypeByName("dateFinalized","04/17/2014");
225        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
226        waitForTextPresent("items retrieved");
227        waitAndClickByName("methodToCall.clearValues");
228    }
229    
230    private void searchByTitle() throws Exception {
231        waitAndTypeByName("title","Travel Doc 2 - dfads");
232        waitAndTypeByName("rangeLowerBoundKeyPrefix_dateCreated","03/24/2000");
233        waitAndClickByXpath("//td/input[@type='image' and @name='methodToCall.search']");
234        waitForTextPresent("Travel Doc 2 - dfads");
235        waitAndClickByName("methodToCall.clearValues");
236    }
237}