001/** 002 * Copyright 2005-2015 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 org.kuali.rice.krad.demo.uif.library.elements; 017 018import java.io.File; 019import java.util.List; 020import org.junit.Test; 021import org.kuali.rice.testtools.selenium.WebDriverFileResourceAftBase; 022import org.openqa.selenium.By; 023 024/** 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027public class LibraryElementMultiFileUploadAft extends WebDriverFileResourceAftBase { 028 029 /** 030 * /kr-krad/kradsampleapp?viewId=Demo-MultiFileUploadView 031 */ 032 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-MultiFileUploadView"; 033 034 // values set by default for repeatable testing; left as configurable for load tests 035 protected List<File> fileUploadList; 036 037 @Override 038 protected String getBookmarkUrl() { 039 return BOOKMARK_URL; 040 } 041 042 @Override 043 protected void navigate() throws Exception { 044 waitAndClickLibraryLink(); 045 waitAndClickByLinkText("Elements"); 046 waitAndClickByLinkText("Multi-file Upload"); 047 } 048 049 protected void testElementMultiFileUpload() throws Exception { 050 fileUploadSetUpforText(); 051 fileIngesterByName("files"); 052 assertLinked(); 053 assertDelete(); 054 055 selectByName("exampleShown", "Max Size Multi-file Upload"); 056 fileUploadSetUpforPdf(); 057 fileIngesterByName("files1"); 058 waitForElementVisibleBy(By.linkText("test.pdf")); 059 assertTrue(isTextPresent("9.2 KB")); // file size 060 clickFirstTrashIcon(); 061 waitForElementNotPresent(By.linkText("test.pdf")); 062 063 selectByName("exampleShown", "Extra Fields Multi-file Upload"); 064 fileUploadSetUpforText(); 065 fileIngesterByName("files2"); 066 assertLinked(); 067 isElementPresentByName("files2[0].detail1"); // detail 1 extra field 068 isElementPresentByName("files2[0].detail2"); // detail 2 extra field 069 assertDelete(); 070 071 selectByName("exampleShown", "File Types Multi-file Upload"); 072 fileUploadSetUpforJpg(); 073 fileIngesterByName("files3"); 074 waitForElementVisibleBy(By.linkText("home.jpg")); 075 clickFirstTrashIcon(); 076 waitForElementNotPresent(By.linkText("home.jpg")); 077 } 078 079 private void assertLinked() throws InterruptedException { 080 waitForElementVisibleBy(By.linkText("test.txt")); 081 waitForElementVisibleBy(By.linkText("test1.txt")); 082 } 083 084 private void assertDelete() throws InterruptedException { 085 clickFirstTrashIcon(); 086 waitForElementNotPresent(By.linkText("test.txt")); 087 088 clickFirstTrashIcon(); 089 waitForElementNotPresent(By.linkText("test1.txt")); 090 } 091 092 private void clickFirstTrashIcon() throws InterruptedException { 093 jGrowl("Click trash icon"); 094 waitAndClickByXpath("//div[@id='Demo-MultiFileUploadView']//button[contains(@class,'icon-trash')]"); 095 waitAndClickConfirmDeleteYes(); 096 } 097 098 private void fileUploadSetUpforText() throws Exception { 099 setUpResourceDir("general", "txt"); 100 } 101 102 private void fileUploadSetUpforJpg() throws Exception { 103 setUpResourceDir("general", "jpg"); 104 } 105 106 private void fileUploadSetUpforPdf() throws Exception { 107 setUpResourceDir("general", "pdf"); 108 } 109 110 @Test 111 public void testElementMultiFileUploadBookmark() throws Exception { 112 testElementMultiFileUpload(); 113 passed(); 114 } 115 116 @Test 117 public void testElementMultiFileUploadNav() throws Exception { 118 testElementMultiFileUpload(); 119 passed(); 120 } 121}