Merge pull request #3339 from yashodha/CRM-14664
[civicrm-core.git] / tests / phpunit / WebTest / Generic / CheckDashboardTest.php
index a472c00d80cf342f423df6cffb9b5e360eff0f83..131a9a8904ae4a9073c6d8d813b55b0c620845f5 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  +--------------------------------------------------------------------+
 */
 
-
 require_once 'CiviTest/CiviSeleniumTestCase.php';
+
+/**
+ * Class WebTest_Generic_CheckDashboardTest
+ */
 class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
 
   protected function setUp() {
@@ -34,7 +37,6 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
   }
 
   function testCheckDashboardElements() {
-    $this->open($this->sboxPath);
 
     $this->webtestLogin();
 
@@ -48,8 +50,16 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
     // More dashlet tests can be added here using the functions modeled below
   }
 
+  /**
+   * @param $widgetConfigureID
+   * @param $widgetEnabledSelector
+   * @param $widgetTitle
+   */
   function _testAddDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle) {
     // Check if desired widget is already loaded on dashboard and remove it if it is so we can test adding it.
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(10);
     if ($this->isElementPresent($widgetEnabledSelector)) {
       $this->_testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector, $widgetTitle);
@@ -57,10 +67,19 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
     $this->click("link=Configure Your Dashboard");
     $this->waitForElementPresent("dashlets-header-col-0");
     $this->mouseDownAt($widgetConfigureID, "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(3);
     $this->mouseMoveAt("existing-dashlets-col-1", "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(3);
     $this->mouseUpAt("existing-dashlets-col-1", "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(3);
     $this->click("link=Done");
     $this->waitForElementPresent("link=Configure Your Dashboard");
@@ -70,23 +89,42 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
     $this->waitForElementPresent("css=li#widget-2 a.fullscreen-icon");
     $this->click("css=li#widget-2 a.fullscreen-icon");
     $this->waitForElementPresent("ui-id-1");
-    $this->assertTrue($this->isTextPresent($widgetTitle));
+    $this->waitForTextPresent("$widgetTitle");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(5);
-    $this->click("link=close");
+    $this->click("xpath=//*[@class='ui-button-text'][contains(text(), 'close')]");
   }
 
+  /**
+   * @param $widgetConfigureID
+   * @param $widgetEnabledSelector
+   */
   function _testRemoveDashboardElement($widgetConfigureID, $widgetEnabledSelector) {
     $this->click("link=Configure Your Dashboard");
     $this->waitForElementPresent("dashlets-header-col-0");
     $this->mouseDownAt("{$widgetConfigureID}", "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(1);
     $this->mouseMoveAt("available-dashlets", "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(1);
     $this->mouseUpAt("available-dashlets", "");
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(1);
     $this->click("link=Done");
     $this->waitForElementPresent("link=Configure Your Dashboard");
     // giving time for activity widget to load (and make sure it did NOT)
+    // Because it tends to cause problems, all uses of sleep() must be justified in comments
+    // Sleep should never be used for wait for anything to load from the server
+    // Justification for this instance: FIXME
     sleep(10);
     $this->assertFalse($this->isElementPresent($widgetEnabledSelector));
   }
@@ -111,7 +149,7 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
     }
     else {
       // click 'Delete Activity' link
-      $this->click("//table[@id='contact-activity-selector-dashlet']/tbody/tr[1]/td[9]/span//a[text()='Delete']");
+      $this->click("//table[@id='contact-activity-selector-dashlet']/tbody/tr[1]/td[8]/span//a[text()='Delete']");
     }
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $this->waitForElementPresent("_qf_Activity_next-bottom");
@@ -131,4 +169,3 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase {
   }
 }
 
-