X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviSeleniumTestCase.php;h=e99f4630e234d0c7cb7baa9c915f18c0045f31a1;hb=5fb5591baa1e6dfa18aacc22743ffda8e8834032;hp=800e2ebe1f4fcb671b141587573f809c86f94a3c;hpb=57550a570f4f538d3cc40939b678d9122156973c;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 800e2ebe1f..e99f4630e2 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -545,7 +545,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->fireEvent($fieldName, 'focus'); if ($editor == 'CKEditor') { if ($compressed) { - $this->click("{$fieldName}-plain"); + $this->click("{$fieldName}-plain"); } $this->waitForElementPresent("xpath=//div[@id='cke_{$fieldName}']//iframe"); $this->runScript("CKEDITOR.instances['{$fieldName}'].setData('

{$text}

');"); @@ -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 @@ -1868,12 +1869,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->click('_qf_FinancialType_next'); if ($option == 'new') { - $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."; + $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('crm-notification-container', $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()); } @@ -2007,7 +2003,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $return = $this->addCustomGroupField($customSets); $this->openCiviPage($pageUrl['url'], $pageUrl['args']); - foreach($return as $values) { foreach ($values as $entityType => $customData) { //initiate necessary variables @@ -2037,7 +2032,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->select2($elementName, $entityData); } } - //checking for proper custom data which is loading through ajax $this->waitForElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]", "The on the fly custom group has not been rendered for entity : {$entity} => {$entityData}"); @@ -2073,16 +2067,17 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // Save $this->click('_qf_Group_next-bottom'); - $this->waitForElementPresent('_qf_Field_cancel-bottom'); //Is custom group created? $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added."); + $this->click('css=a#newCustomField'); + $gid = $this->urlArg('gid'); + $this->waitForTextPresent("{$customGroupTitle} - New Field"); $fieldLabel = "custom_field_for_{$customSet['entity']}_{$customSet['subEntity']}" . substr(sha1(rand()), 0, 4); $this->type('label', $fieldLabel); $this->click('_qf_Field_next_new-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); $customGroupTitle = preg_replace('/\s/', '_', trim($customGroupTitle)); $return[] = array( @@ -2104,10 +2099,12 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->clickAt("//*[@class='select2-results']/li[1]/div"); } else { - if ($xpath) - $this->clickAt($fieldName); - else - $this->clickAt("//*[@id='$fieldName']/../div/a"); + if ($xpath) { + $this->clickAt($fieldName); + } + else { + $this->clickAt("//*[@id='$fieldName']/../div/a"); + } $this->waitForElementPresent("//*[@id='select2-drop']/div/input"); $this->keyDown("//*[@id='select2-drop']/div/input", " "); $this->type("//*[@id='select2-drop']/div/input", $label); @@ -2125,7 +2122,40 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->clickAt("xpath=//*[@id='$fieldid']/../div/ul//li/input"); $this->waitForElementPresent("xpath=//ul[@class='select2-results']"); $this->clickAt("xpath=//ul[@class='select2-results']//li/div[text()='$value']"); - $this->waitForText("xpath=//*[@id='$fieldid']/../div", $value); + $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 + */ + function enableDisablePopups($enabled = TRUE) { + $this->openCiviPage('admin/setting/preferences/display', 'reset=1'); + $isChecked = $this->isChecked('ajaxPopupsEnabled'); + if (($isChecked && !$enabled) || (!$isChecked && $enabled)) { + $this->click('ajaxPopupsEnabled'); + } + if ($enabled) { + $this->assertChecked('ajaxPopupsEnabled'); + } + else { + $this->assertNotChecked('ajaxPopupsEnabled'); } + $this->clickLink("_qf_Display_next-bottom"); } }