From dcba1580fbf0ccfac841eae5c6a600cb29e48a58 Mon Sep 17 00:00:00 2001 From: Dave Greenberg Date: Mon, 15 Sep 2014 20:06:58 -0400 Subject: [PATCH] CRM-15197 - Fix for WebTest_Contribute_UpdateContributionTest::testChangePremium ---------------------------------------- * CRM-15197: https://issues.civicrm.org/jira/browse/CRM-15197 --- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 11 +++++++++-- .../WebTest/Contribute/UpdateContributionTest.php | 10 ++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 785feee753..4955b22775 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -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 */ diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 5b00f5be6e..3a09d2d46e 100755 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -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")); -- 2.25.1