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 edu.sampleu.admin;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.kuali.rice.testtools.selenium.WebDriverUtils;
22  import org.openqa.selenium.By;
23  import org.openqa.selenium.support.ui.Select;
24  
25  /**
26   * test that repeated ajax refreshes work
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class AgendaEditRuleRefreshAft extends WebDriverLegacyITBase {
30  
31      public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Agenda%20Lookup&channelUrl="
32              + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
33              + "org.kuali.rice.krms.impl.repository.AgendaBo"
34              + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS
35              + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
36  
37      @Override
38      protected String getBookmarkUrl() {
39          return BOOKMARK_URL;
40      }
41  
42      @Override
43      protected void navigate() throws Exception {
44          waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
45          waitForPageToLoad();
46      }
47  
48      protected void testAgendaEditRuleRefresh() throws Exception {
49          selectFrameIframePortlet();
50          waitAndClickSearchByText();
51          //        waitAndClickByXpath("//div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[1]"); //  jiraAwareWaitAndClick("id=32");
52          waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1000']",
53                  "Does user have edit permissions?"); // jiraAwareWaitAndClick("id=194_line0");
54          waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); // jiraAwareWaitAndClick("//li[@id='473_node_0_parent_root']/a");
55          waitAndClickByXpath("//li/a[@class='agendaNode logicNode whenTrueNode']");
56          waitAndClickByLinkText("[-] collapse all");
57  
58          // click refresh  several times
59          for (int i = 0; i < 6; i++) {
60              for (int second = 0;; second++) {
61                  if (second >= waitSeconds)
62                      jiraAwareFail(TIMEOUT_MESSAGE);
63                  try {
64                      if (isElementPresent(".kr-refresh-button"))
65                          break;
66                  } catch (Exception e) {}
67                  Thread.sleep(1000);
68              }
69              waitAndClick("button.kr-refresh-button");
70          }
71      }
72  
73      protected void testAgendaEditRuleCompoundOperation() throws Exception {
74          selectFrameIframePortlet();
75          waitAndClickSearchByText();
76          waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1001']",
77                  "Does user have edit permissions?");
78          waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']");
79          waitAndClickButtonByText("Edit Rule");
80          waitForTextPresent("Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren");
81  
82          waitAndSelectBy(By.xpath("//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[2]/div/div/select"), "OR");
83          waitForTextPresent("Campus Code = Muir OR Campus Code = Revelle OR Campus Code = Warren");
84          Select select = new Select(driver.findElement(By.xpath(
85                  "//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[4]/div/div/select")));
86          String selectedOption = select.getFirstSelectedOption().getText();
87          assertEquals("The second drop down should also be OR", "OR", selectedOption);
88  
89          waitAndSelectBy(By.xpath("//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[4]/div/div/select"), "AND");
90          waitForTextPresent("Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren");
91          Select select2 = new Select(driver.findElement(By.xpath(
92                  "//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[2]/div/div/select")));
93          String selectedOption2 = select2.getFirstSelectedOption().getText();
94          assertEquals("The first drop down should also be AND", "AND", selectedOption2);
95      }
96  
97      /**
98       * test that repeated ajax refreshes work
99       */
100     @Test
101     public void testAgendaEditRuleRefreshBookmark() throws Exception {
102         testAgendaEditRuleRefresh();
103         passed();
104     }
105 
106     /**
107      * test that repeated ajax refreshes work
108      */
109     @Test
110     public void testAgendaEditRuleRefreshNav() throws Exception {
111         testAgendaEditRuleRefresh();
112         passed();
113     }
114 
115     /**
116      * test to verify that compound operations are set correctly when changed.
117      */
118     @Test
119     public void testAgendaEditRuleCompoundOperationBookmark() throws Exception {
120         testAgendaEditRuleCompoundOperation();
121         passed();
122     }
123 
124     /**
125      * test to verify that compound operations are set correctly when changed.
126      */
127     @Test
128     public void testAgendaEditRuleCompoundOperationNav() throws Exception {
129         testAgendaEditRuleCompoundOperation();
130         passed();
131     }
132 }
133