Merge pull request #4149 from mepps/update-coffee-mug-premium
[civicrm-core.git] / tests / phpunit / CiviTest / CiviSeleniumTestCase.php
index 2de3b3cee144698edc1c5b20856dfd36a7d2b90a..e99f4630e234d0c7cb7baa9c915f18c0045f31a1 100644 (file)
@@ -784,6 +784,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     $this->type('billing_city-5', 'San Bernadino');
     $this->select('billing_country_id-5', 'value=1228');
     $this->click('billing_state_province_id-5');
+    $this->waitForVisible('billing_state_province_id-5');
     $this->select('billing_state_province_id-5', 'label=California');
     $this->type('billing_postal_code-5', '93245');
 
@@ -1474,10 +1475,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     // Is status message correct?
     $this->waitForText('crm-notification-container', "Activity '$subject' has been saved.");
 
-    $this->waitForElementPresent("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[2]/td[8]/span/a[text()='View']");
+    $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']");
 
     // click through to the Activity view screen
-    $this->click("xpath=//div[@id='contact-activity-selector-activity_wrapper']//table/tbody/tr[2]/td[8]/span/a[text()='View']");
+    $this->click("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody/tr[2]/td[8]/span/a[text()='View']");
     $this->waitForElementPresent('_qf_Activity_cancel-bottom');
 
     // parse URL to grab the activity id
@@ -1871,9 +1872,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $text = "Your Financial \"{$financialType['name']}\" Type has been created, along with a corresponding income account \"{$financialType['name']}\". That income account, along with standard financial accounts \"Accounts Receivable\", \"Banking Fees\" and \"Premiums\" have been linked to the financial type. You may edit or replace those relationships here.";
     }
     else {
-      $text = "The financial type '{$financialType['name']}' has been saved.";
+      $text = "The financial type \"{$financialType['name']}\" has been updated.";
     }
-    $this->waitForText("xpath=//div[@class='notify-content']", $text);
+    $this->assertSuccessMsg($text);
   }
 
   /**
@@ -1899,19 +1900,14 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   function addProfile($profileTitle, $profileFields) {
     $this->openCiviPage('admin/uf/group', "reset=1");
 
-    $this->click('link=Add Profile');
-
-    // Add membership custom data field to profile
-    $this->waitForElementPresent('_qf_Group_cancel-bottom');
+    $this->clickLink('link=Add Profile', '_qf_Group_cancel-bottom');
     $this->type('title', $profileTitle);
-    $this->click('_qf_Group_next-bottom');
+    $this->clickLink('_qf_Group_next-bottom', "xpath=//a/span[text()='Add Field']");
 
-    $this->waitForElementPresent('_qf_Field_cancel-bottom');
-    //$this->assertTrue($this->isTextPresent("Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."));
+    $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
 
     foreach ($profileFields as $field) {
       $this->waitForElementPresent('field_name_0');
-      // $this->waitForPageToLoad($this->getTimeoutMsec());
       $this->click("id=field_name_0");
       $this->select("id=field_name_0", "label=" . $field['type']);
       $this->waitForElementPresent('field_name_1');
@@ -1920,7 +1916,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $this->waitForElementPresent('label');
       $this->type("id=label", $field['label']);
       $this->click("id=_qf_Field_next_new-top");
-      $this->waitForPageToLoad($this->getTimeoutMsec());
+      $this->waitForElementPresent("xpath=//select[@id='field_name_1'][@style='display: none;']");
       //$this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '" . $field['name'] . "' has been saved to '" . $profileTitle . "'. You can add another profile field."));
     }
   }
@@ -1934,7 +1930,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
    * @param $financialType
    */
   function addPremium($name, $sku, $amount, $price, $cost, $financialType) {
-    $this->waitForElementPresent("_qf_ManagePremiums_upload-bottom");
+    $this->waitForElementPresent("_qf_ManagePremiums_next-bottom");
     $this->type("name", $name);
     $this->type("sku", $sku);
     $this->click("CIVICRM_QFID_noImage_16");
@@ -1944,7 +1940,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     if ($financialType) {
       $this->select("financial_type_id", "label={$financialType}");
     }
-    $this->click("_qf_ManagePremiums_upload-bottom");
+    $this->click("_qf_ManagePremiums_next-bottom");
     $this->waitForPageToLoad($this->getTimeoutMsec());
   }
 
@@ -2129,6 +2125,21 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
       $this->assertElementContainsText("xpath=//*[@id='$fieldid']/preceding-sibling::div[1]/", $value);
     }
   }
+
+  /**
+   * Wait for unobtrusive status message as set by CRM.status
+   */
+  function waitForStatusMsg() {
+    $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
@@ -2145,7 +2156,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
     else {
       $this->assertNotChecked('ajaxPopupsEnabled');
     }
-    $this->click("_qf_Display_next-bottom");
-    $this->waitForPageToLoad($this->getTimeoutMsec());    
+    $this->clickLink("_qf_Display_next-bottom");
   }
 }