CRM-15197 - Fix for WebTest_Contribute_UpdateContributionTest::testChangePremium
authorDave Greenberg <dave@civicrm.org>
Tue, 16 Sep 2014 00:06:58 +0000 (20:06 -0400)
committerDave Greenberg <dave@civicrm.org>
Tue, 16 Sep 2014 00:06:58 +0000 (20:06 -0400)
----------------------------------------
* CRM-15197:
  https://issues.civicrm.org/jira/browse/CRM-15197

tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/Contribute/UpdateContributionTest.php

index 785feee753a33133067b7e516c044f134fd6e246..4955b22775af3d5e71e6b98020128968f712126c 100644 (file)
@@ -1874,8 +1874,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     else {
       $text = "The financial type \"{$financialType['name']}\" has been updated.";
     }
-    $this->waitForElementPresent("xpath=//div[@class='notify-content']");
-    $this->assertElementContainsText('crm-notification-container', $text);
+    $this->assertSuccessMsg($text);
   }
 
   /**
@@ -2142,6 +2141,14 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $this->waitForElementPresent("css=.crm-status-box-outer.status-success");
   }
   
+  /**
+   * Wait for unobtrusive status message as set by CRM.status
+   */
+  function assertSuccessMsg($text) {
+    $this->waitForElementPresent("css=div.success");
+    $this->assertElementContainsText("css=div.success", $text);
+  }
+  
   /**
    * function to enable or disable Pop-ups via Display Preferences
    */
index 5b00f5be6e0f56c47f7b230e15c3e7feb3bb1063..3a09d2d46e3134c5cf8f59d82638cc2c11f81da9 100755 (executable)
@@ -172,7 +172,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $this->clickLink("_qf_Contribution_upload");
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-   // verify if Membership is created
+   // verify if Contribution is created
    $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    //click through to the Contribution edit screen
    $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));
@@ -183,6 +183,12 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $this->select('product_name_0', "label=$premiumName2 ( $sku2 )");
    // Clicking save.
    $this->clickLink("_qf_Contribution_upload", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
+   $this->assertSuccessMsg("The contribution record has been saved.");
+   // Opening View page and cancelling to give the DB time to get updated prior to Assert statements below. dgg
+   $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
+   $this->clickLink("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", "_qf_ContributionView_cancel-bottom", FALSE);
+   $this->waitForElementPresent("_qf_ContributionView_cancel-bottom");
+   $this->clickLink("_qf_ContributionView_cancel-bottom", "xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']", FALSE);
 
    //Assertions
    $actualAmount = $this->_getPremiumActualCost($contId, $to, $from, $cost2, "'civicrm_contribution'");
@@ -239,7 +245,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase {
    $this->clickLink("_qf_Contribution_upload");
    // Is status message correct?
    $this->waitForText('crm-notification-container', "The contribution record has been saved.");
-   // verify if Membership is created
+   // verify if Contribution is created
    $this->waitForElementPresent("xpath=//div[@class='view-content']//table[@class='selector row-highlight']//tbody/tr[1]/td[8]/span/a[text()='View']");
    //click through to the Contribution edit screen
    $contId = explode('&id=', $this->getAttribute("xpath=//div[@class='view-content']//table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='Edit']@href"));