Merge pull request #2003 from lcdservices/CRM-13781
[civicrm-core.git] / tests / phpunit / WebTest / Case / CaseDashboardTest.php
index 95af874ea586d6f4ff680206e02472176ce56b0e..dce579ae6f62af3aba6eae7ff07dbb271b7c2a68 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.4                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2013                                |
  +--------------------------------------------------------------------+
@@ -24,7 +24,6 @@
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
 class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
 
@@ -33,38 +32,27 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
   }
 
   function testAllOrMyCases() {
-
-    $this->open($this->sboxPath);
-
     // Log in as admin first to verify permissions for CiviCase
-    $this->webtestLogin();
+    $this->webtestLogin('true');
 
     // Enable CiviCase module if necessary
-    $this->openCiviPage('admin/setting/component', 'reset=1', '_qf_Component_next-bottom');
-    $enabledComponents = $this->getSelectOptions("enableComponents-t");
-    if (!in_array("CiviCase", $enabledComponents)) {
-      $this->addSelection("enableComponents-f", "label=CiviCase");
-      $this->click("//option[@value='CiviCase']");
-      $this->click("add");
-      $this->click("_qf_Component_next-bottom");
-      $this->waitForPageToLoad($this->getTimeoutMsec());
-    }
+    $this->enableComponents("CiviCase");
 
     // let's give full CiviCase permissions to demo user (registered user).
     $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase');
     $this->changePermissions($permission);
 
-    // Go directly to the URL of the screen that you will be testing (Dashboard).
-    $this->openCiviPage('case', 'reset=1', 'css=a.button');
+    // Log in as normal user
+    $this->webtestLogin();
+
+    $this->openCiviPage('case', 'reset=1');
 
     // Should default to My Cases
     $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.');
     // The header text of the table changes too
-    $this->assertElementContainsText('crm-container', "Summary of Case Involvement");
+    $this->assertElementContainsText('crm-container', "Summary of Involvement");
 
-    $this->click("name=allupcoming value=1");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("css=a.button");
+    $this->clickLink("name=allupcoming value=1", "css=a.button");
 
     $this->assertTrue($this->isChecked("name=allupcoming value=1"), 'Selection of All Cases failed.');
     $this->assertElementContainsText('crm-container', "Summary of All Cases");
@@ -73,30 +61,22 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase {
     $this->openCiviPage('case', 'reset=1', 'css=a.button');
 
     // Click on find my cases and check if right radio is checked
-    $this->click("name=find_my_cases");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("css=input.form-submit");
+    $this->clickLink("name=find_my_cases", "css=input.form-submit");
     $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Find my cases button not properly setting search form value to my cases.');
 
     // Go back to dashboard
     $this->openCivipage('case', 'reset=1', 'css=a.button');
 
     // Click on a drilldown cell and check if right radio is checked
-    $this->click("css=a.crm-case-summary-drilldown");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("css=input.form-submit");
+    $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
     $this->assertTrue($this->isChecked("name=case_owner value=1"), 'Drilldown on dashboard summary cells not properly setting search form value to all cases.');
 
     // Go back to dashboard and reset to my cases
     $this->openCiviPage('case', 'reset=1', 'css=a.button');
-    $this->click("name=allupcoming value=0");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("css=a.button");
+    $this->clickLink("name=allupcoming value=0", "css=a.button");
 
     // Click on a drilldown cell and check if right radio is checked
-    $this->click("css=a.crm-case-summary-drilldown");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
-    $this->waitForElementPresent("css=input.form-submit");
+    $this->clickLink("css=a.crm-case-summary-drilldown", "css=input.form-submit");
     $this->assertTrue($this->isChecked("name=case_owner value=2"), 'Drilldown on dashboard summary cells not properly setting search form value to my cases.');
   }
 }