001 /** 002 * Copyright 2005-2013 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.samplu.krad.library.collections; 017 018 import org.junit.Test; 019 020 import org.kuali.rice.testtools.selenium.SmokeTestBase; 021 022 /** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public class DemoLibraryCollectionFeaturesRowGroupingSmokeTest extends SmokeTestBase { 026 027 /** 028 * /kr-krad/kradsampleapp?viewId=Demo-TableLayoutGrouping-View 029 */ 030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-TableLayoutGrouping-View"; 031 032 @Override 033 protected String getBookmarkUrl() { 034 return BOOKMARK_URL; 035 } 036 037 @Override 038 protected void navigate() throws Exception { 039 waitAndClickById("Demo-LibraryLink", ""); 040 waitAndClickByLinkText("Collection Features"); 041 waitAndClickByLinkText("Row Grouping"); 042 } 043 044 protected void testCollectionFeaturesRowGroupingBaseFunctionality() throws Exception { 045 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow a']"); 046 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='a']"); 047 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow b']"); 048 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='b']"); 049 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow c']"); 050 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section1']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='c']"); 051 } 052 053 protected void testCollectionFeaturesRowGrouping2FieldGrouping() throws Exception { 054 selectByName("exampleShown", "2 Field Grouping"); 055 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow 2001-fall']"); 056 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-groupvalue='2001-fall']"); 057 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow 2001-spring']"); 058 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-groupvalue='2001-spring']"); 059 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow 2002-fall']"); 060 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section2']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-groupvalue='2002-fall']"); 061 } 062 063 protected void testCollectionFeaturesRowGroupingOmitGroupField() throws Exception { 064 selectByName("exampleShown", "Omit Group Field"); 065 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow a']"); 066 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='a']"); 067 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow b']"); 068 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='b']"); 069 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow c']"); 070 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='c']"); 071 if(isElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section3']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-groupvalue]")) 072 { 073 fail("Group Field Not Omited."); 074 } 075 } 076 077 protected void testCollectionFeaturesRowGroupingAddToGrouped() throws Exception { 078 selectByName("exampleShown", "Add to Grouped"); 079 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section4']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow a']"); 080 assertElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section4']/div[@class='dataTables_wrapper']/table/tbody/tr[@data-group='a']/td/div/span[contains(text(), 'A')]"); 081 } 082 083 protected void testCollectionFeaturesRowGroupingPrefixOption() throws Exception { 084 selectByName("exampleShown", "Prefix option"); 085 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section5']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow a']/td[contains(text(),'Lines with value A')]"); 086 } 087 088 protected void testCollectionFeaturesRowGroupingCustomGroupTitle() throws Exception { 089 selectByName("exampleShown", "Custom Group title"); 090 waitForElementPresentByXpath("//div[@id='Demo-TableLayoutGrouping-Section6']/div[@class='dataTables_wrapper']/table/tbody/tr[@class='uif-groupRow letter-a-in-item']/td[contains(text(),'Letter A in item')]"); 091 } 092 093 @Test 094 public void testCollectionFeaturesRowGroupingBookmark() throws Exception { 095 testCollectionFeaturesRowGroupingBaseFunctionality(); 096 testCollectionFeaturesRowGrouping2FieldGrouping(); 097 testCollectionFeaturesRowGroupingOmitGroupField(); 098 testCollectionFeaturesRowGroupingAddToGrouped(); 099 testCollectionFeaturesRowGroupingPrefixOption(); 100 testCollectionFeaturesRowGroupingCustomGroupTitle(); 101 passed(); 102 } 103 104 @Test 105 public void testCollectionFeaturesRowGroupingNav() throws Exception { 106 testCollectionFeaturesRowGroupingBaseFunctionality(); 107 testCollectionFeaturesRowGrouping2FieldGrouping(); 108 passed(); 109 } 110 }