From efb29358e53fbbc80df81b7541662e5db73d760d Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 19 Mar 2013 17:40:54 -0700 Subject: [PATCH] Fix some uses of sleep, comment the rest --- .../phpunit/CiviTest/CiviSeleniumTestCase.php | 23 ++- tests/phpunit/WebTest/Activity/IcalTest.php | 3 + .../Campaign/OfflineContributionTest.php | 3 + .../Campaign/SurveyUsageScenarioTest.php | 3 + .../WebTest/Case/CaseCustomFieldsTest.php | 21 +++ .../WebTest/Contact/CustomDataAddTest.php | 15 +- .../WebTest/Contact/InlineFieldsEditTest.php | 5 +- .../WebTest/Contact/MergeContactsTest.php | 23 +-- .../Contact/MultipleContactSubTypes.php | 131 ++++++------------ .../WebTest/Contact/ProfileChecksumTest.php | 6 + .../WebTest/Contact/RelationshipAddTest.php | 4 +- .../phpunit/WebTest/Contact/SignatureTest.php | 45 +++--- .../Contact/TaskActionAddToGroupTest.php | 3 + .../WebTest/Contribute/AddPricesetTest.php | 3 + .../Contribute/ContactContextAddTest.php | 4 +- .../Contribute/OnBehalfOfOrganization.php | 12 ++ .../phpunit/WebTest/Contribute/PCPAddTest.php | 1 - .../Contribute/UpdateContributionTest.php | 3 + tests/phpunit/WebTest/Event/AddEventTest.php | 7 +- .../phpunit/WebTest/Event/TellAFriendTest.php | 4 +- .../Export/ExportCiviSeleniumTestCase.php | 4 + .../Financial/FinancialAccountTypeTest.php | 3 + .../Financial/FinancialBatchExport.php | 9 +- .../WebTest/Generic/CheckDashboardTest.php | 27 ++++ .../Import/ImportCiviSeleniumTestCase.php | 13 +- .../Mailing/AddMessageTemplateTest.php | 3 + .../Member/BatchUpdateViaProfileTest.php | 3 + .../WebTest/Member/ContactContextAddTest.php | 6 + .../Member/InheritedMembershipTest.php | 5 +- .../Member/OfflineAutoRenewMembershipTest.php | 3 + .../OfflineMembershipAddPricesetTest.php | 3 + .../Member/OfflineMembershipRenewTest.php | 23 ++- .../OnlineAutoRenewMembershipGCTest.php | 10 +- .../Member/OnlineAutoRenewMembershipTest.php | 7 +- .../OnlineMembershipAddPricesetTest.php | 3 + .../WebTest/Profile/BatchUpdateTest.php | 42 ++++++ .../Profile/MultiRecordProfileAddTest.php | 9 ++ tests/phpunit/WebTest/Profile/SearchTest.php | 3 + .../WebTest/Report/LoggingReportTest.php | 12 ++ 39 files changed, 342 insertions(+), 165 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index e3d88036cd..8ef7908e28 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -538,6 +538,14 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { return $elements; } + /** + * Returns a single argument from the url query + */ + function urlArg($arg, $url = NULL) { + $elements = $this->parseURL($url); + return isset($elements['queryString'][$arg]) ? $elements['queryString'][$arg] : NULL; + } + /** * Define a payment processor for use by a webtest. Default is to create Dummy processor * which is useful for testing online public forms (online contribution pages and event registration) @@ -1056,11 +1064,8 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } // parse URL to grab the contribution page id - $elements = $this->parseURL(); - $pageId = $elements['queryString']['id']; - // pass $pageId back to any other tests that call this class - return $pageId; + return $this->urlArg('id'); } /** @@ -1299,9 +1304,10 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // click through to the Activity view screen $this->click("xpath=//div[@id='Activities']//table/tbody/tr[2]/td[9]/span/a[text()='View']"); $this->waitForElementPresent('_qf_Activity_cancel-bottom'); - $elements = $this->parseURL(); - $activityID = $elements['queryString']['id']; - return $activityID; + + // parse URL to grab the activity id + // pass id back to any other tests that call this class + return $this->urlArg('id'); } static @@ -1742,6 +1748,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { ); $this->select('account_relationship', "label={$accountRelationship}"); + // 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(2); $this->select('financial_account_id', "label={$financialAccountTitle}"); $this->click('_qf_FinancialTypeAccount_next'); diff --git a/tests/phpunit/WebTest/Activity/IcalTest.php b/tests/phpunit/WebTest/Activity/IcalTest.php index a0bb17009f..9611d972b3 100644 --- a/tests/phpunit/WebTest/Activity/IcalTest.php +++ b/tests/phpunit/WebTest/Activity/IcalTest.php @@ -62,6 +62,9 @@ class WebTest_Activity_IcalTest extends CiviSeleniumTestCase { $this->select("activity_type_id", "value=1"); $this->click("token-input-assignee_contact_id"); + // 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: tokeninput has a slight delay sleep(1); $this->type("token-input-assignee_contact_id", "$firstName1"); $this->typeKeys("token-input-assignee_contact_id", "$firstName1"); diff --git a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php index 4d513d37a7..4b9e1461fd 100644 --- a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php @@ -151,6 +151,9 @@ class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase { if ($past) { $this->click("include-past-campaigns"); + // 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 + // FIXME: Use a better method for waiting for this AJAX call - sleep is not going to work! sleep(2); } diff --git a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php index 526ea88b69..3686085043 100644 --- a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php +++ b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php @@ -551,6 +551,9 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { $this->click("//table[@id='voterRecords']/tbody//tr[@id='row_{$id1}']/td[5]/input[6]/../label[text()='$label2']"); $this->select("field_{$id1}_result", $optionLabel1); $this->click("interview_voter_button_{$id1}"); + // 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); // Survey Report $this->openCiviPage("report/survey/detail", "reset=1", '_qf_SurveyDetails_submit'); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index 0d2965a440..847d089bbf 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -46,6 +46,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->type("title", $customGrp1); $this->select("extends[0]", "value=Case"); + // 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->select("extends_1", "value=2"); $this->click("_qf_Group_next-bottom"); @@ -112,6 +115,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->type("activity_subject", $subject); $this->select("case_type_id", "label={$caseTypeLabel}"); + // 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->select("status_id", "label={$caseStatusLabel}"); @@ -138,6 +144,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->openCiviPage('case', 'reset=1', "xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Open Case']"); $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); + // 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); $openCaseData = array( @@ -165,6 +174,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $cusId_2 = 'custom_' . $customId[1] . '_1'; $cusId_3 = 'custom_' . $customId[2] . '_1'; $this->click("css=#{$customGrp1} a.button"); + // 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(2); $this->waitForElementPresent("{$cusId_1}"); $custFname = "Miky" . substr(sha1(rand()), 0, 7); @@ -174,9 +186,15 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->type("{$cusId_2}", $custMname); $this->type("{$cusId_3}", $custLname); $this->click("_qf_CustomData_upload"); + // 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(2); $this->openCiviPage('case', 'reset=1'); $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[8]/a[text()='Change Custom Data']"); + // 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); $openCaseChangeData = array( "Client" => $displayName, @@ -190,6 +208,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { ); $this->webtestVerifyTabularData($openCaseChangeData); $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Done']"); + // 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(2); $this->_testAdvansearchCaseData($customId, $custFname, $custMname, $custLname); $this->_testDeleteCustomData($customGrpId1, $customId); diff --git a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php index b6be9c0534..00017bb649 100644 --- a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php +++ b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php @@ -237,19 +237,15 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { } function testCustomDataChangeLog(){ - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. $this->webtestLogin(); //enable logging $this->openCiviPage('admin/setting/misc', 'reset=1'); $this->click("CIVICRM_QFID_1_logging"); $this->click("_qf_Miscellaneous_next-top"); - // adding sleep here since enabling logging takes lot of time - // increased the time since we now also add a lot of triggers and create tables - // the first time around - sleep(40); + + // Increase timeout by quadruple since enabling logging takes a long time + $this->waitForPageToLoad($this->getTimeoutMsec() * 4); $this->waitForTextPresent("Changes Saved"); // Create new Custom Field Set @@ -341,8 +337,9 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { $this->openCiviPage('admin/setting/misc', 'reset=1'); $this->click("CIVICRM_QFID_0_logging"); $this->click("_qf_Miscellaneous_next-top"); - //adding sleep here since disabling logging takes lot of time - sleep(20); + + // Increase timeout by triple since disabling logging takes a long time + $this->waitForPageToLoad($this->getTimeoutMsec() * 3); $this->waitForTextPresent("Changes Saved"); } diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index 44c3f18534..8b7fcf5e43 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -63,6 +63,9 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { // Custom data $this->click('css=div.crm-custom-set-block-1 .collapsible-title'); + // Because it tends to cause problems, all uses of sleep() must be justified in comments + // NOTE: Sleep should never be used for wait for anything to load from the server + // Justification for this instance: opening an accordion is predictable sleep(1); $this->openInlineForm('custom-set-content-1'); $dateFieldId = $this->getAttribute("xpath=//div[@id='constituent_information']/table/tbody/tr[3]/td[@class='html-adjust']/input@id"); @@ -140,7 +143,7 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { $this->type('street_address-1', 'Test Org Street'); $this->type('city-1', 'Test Org City'); $this->click('_qf_Edit_next'); - sleep(2); + $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('selected_shared_address-2'); $this->waitForTextPresent('Test Org Street'); $this->inlineEdit('address-block-2', array( diff --git a/tests/phpunit/WebTest/Contact/MergeContactsTest.php b/tests/phpunit/WebTest/Contact/MergeContactsTest.php index e06de201ff..771bacbca9 100644 --- a/tests/phpunit/WebTest/Contact/MergeContactsTest.php +++ b/tests/phpunit/WebTest/Contact/MergeContactsTest.php @@ -133,10 +133,8 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { // Select the contacts to be merged $this->select("name=option51_length", "value=100"); - $this->waitForTextPresent("$firstName $lastName"); - // sleep seems to work here, not sure why - sleep(3); + $this->waitForElementPresent("xpath=//a[text()='$firstName $lastName']/../../td[4]/a[text()='merge']"); $this->click("xpath=//a[text()='$firstName $lastName']/../../td[4]/a[text()='merge']"); $this->waitForElementPresent('_qf_Merge_cancel-bottom'); @@ -566,11 +564,20 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { )); $this->chooseOkOnNextConfirmation(); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(5); + $this->waitForElementPresent('civicrm-footer'); + $this->assertElementContainsText('crm-notification-container', "safe mode"); + + // If we are still on the dedupe table page, count unmerged contacts + if ($this->isElementPresent("//table[@class='pagerDisplay']")) { + // Wait for datatable to load + $this->waitForElementPresent("//table[@class='pagerDisplay']/tbody/tr"); + $unMergedContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr"); + } + else { + $unMergedContacts = 0; + } - $unMergedContacts = $this->getXpathCount("//table[@class='pagerDisplay']/tbody/tr"); $mergedContacts = $totalContacts - $unMergedContacts; - $this->assertElementContainsText('crm-notification-container', "safe mode"); //check the existence of merged contacts $contactEmails = array( @@ -579,7 +586,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { 3 => "{$firstName3}.{$lastName3}@example.com" ); - foreach( $contactEmails as $key => $value ) { + foreach($contactEmails as $key => $value) { $this->click('sort_name_navigation'); $this->type('css=input#sort_name_navigation', $value); $this->typeKeys('css=input#sort_name_navigation', $value); @@ -589,7 +596,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { // Visit contact summary page. $this->click("css=div.ac_results-inner li"); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(2); + $this->waitForElementPresent('civicrm-footer'); } } diff --git a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php index 62ff4697fc..d34f88b2d1 100644 --- a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php +++ b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php @@ -91,21 +91,14 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { $indExternalId = substr(sha1(rand()), 0, 4); $this->type("external_identifier", $indExternalId); - //checking for presence of contact data specific custom data - if ($this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForStudent}']") && $this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForParent}']") && !$this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForStaff}']")) { - $assertCheckForCustomGroup = TRUE; - } - else { - $assertCheckForCustomGroup = FALSE; - } + $this->waitForElementPresent("customData$customGroupIdForStudent"); + $this->waitForElementPresent("customData$customGroupIdForParent"); - $this->assertTrue($assertCheckForCustomGroup, "The Check for contact sub-type specific custom group failed"); + // Make sure our staff custom set does NOT show up + $this->assertFalse($this->isElementPresent("customData$customGroupIdForStaff"), "A custom field showed up for the wrong subtype!"); - if ($assertCheckForCustomGroup) { - - $this->type("xpath=//div[@id='customData{$customGroupIdForStudent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStudent}"); - $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}"); - } + $this->type("xpath=//div[@id='customData{$customGroupIdForStudent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStudent}"); + $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}"); //address section $this->click("addressBlock"); @@ -118,7 +111,7 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { $this->click("address_1_country_id"); $this->select("address_1_country_id", "value=" . $this->webtestGetValidCountryID()); - if ($this->isTextPresent("Latitude")) { + if ($this->isElementPresent("address_1_geo_code_1")) { $this->type("address_1_geo_code_1", "1234"); $this->type("address_1_geo_code_2", "5678"); } @@ -133,7 +126,7 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { $this->click("address_2_country_id"); $this->select("address_2_country_id", "value=" . $this->webtestGetValidCountryID()); - if ($this->isTextPresent("Latitude")) { + if ($this->isElementPresent("address_2_geo_code_1")) { $this->type("address_2_geo_code_1", "1234"); $this->type("address_2_geo_code_2", "5678"); } @@ -176,116 +169,70 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { //checking the contact sub-type of newly created individual $this->assertElementContainsText('crm-notification-container', "Contact Saved"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='contact-summary']/div[@id='contactTopBar']/table/tbody/tr/td[@class='crm-contact_type_label'][text()='{$selection1}, {$selection2}']")); - - //custom data check - if ($this->isElementPresent("{$groupTitleForStudent}_0")) { - $groupidSt = "{$groupTitleForStudent}_0"; - } - else { - $groupidSt = "{$groupTitleForStudent}_1"; - } + $this->assertElementContainsText('css=.crm-contact_type_label', "Student"); + $this->assertElementContainsText('css=.crm-contact_type_label', "Parent"); //custom data check - if ($this->isElementPresent("{$groupTitleForParent}_0")) { - $groupidPa = "{$groupTitleForParent}_0"; - } - else { - $groupidPa = "{$groupTitleForParent}_1"; - } - - $this->click($groupidSt); - $this->click($groupidPa); - $this->assertTrue($this->isTextPresent("dummy text for customData{$customGroupIdForParent}")); $this->assertTrue($this->isTextPresent("dummy text for customData{$customGroupIdForStudent}")); - //editing contact sub-type - $this->click("xpath=//ul[@id='actions']/li[2]/a"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - $this->waitForElementPresent('_qf_Contact_upload_view-bottom'); - $selectedValues = $this->getSelectedValues("contact_sub_type"); - if (in_array($selection1, $selectedValues) && in_array($selection2, $selectedValues)) { - $checkSelection = TRUE; - } - else { - $checkSelection = FALSE; - } + // Get contact id + $cid = $this->urlArg('cid'); - $this->assertTrue($checkSelection, 'Assertion failed for multiple selection of contact sub-type'); + //editing contact sub-type + $this->openCiviPage('contact/add', "reset=1&action=update&cid=$cid"); //edit contact sub-type $this->removeSelection("contact_sub_type", "value={$selection1}"); $this->addSelection('contact_sub_type', "value={$selection3}"); - //checking for presence of contact data specific custom data - if (!$this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForStudent}']") && $this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForParent}']") && $this->isElementPresent("xpath=//div[@id='customData{$customGroupIdForStaff}']")) { - $assertCheckForCustomGroup = TRUE; - } - else { - $assertCheckForCustomGroup = FALSE; - } - - $this->assertTrue($assertCheckForCustomGroup, "The Check for contact sub-type specific custom group failed after de-selecting Student and selecting staff"); + $this->waitForElementPresent("customData$customGroupIdForStaff"); - if ($assertCheckForCustomGroup) { + // Make sure our staff custom set does NOT show up + $this->assertFalse($this->isElementPresent("customData$customGroupIdForStudent"), "A custom field showed up for the wrong subtype!"); - $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}"); - $this->type("xpath=//div[@id='customData{$customGroupIdForStaff}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStaff}"); - } + $this->type("xpath=//div[@id='customData{$customGroupIdForParent}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForParent}"); + $this->type("xpath=//div[@id='customData{$customGroupIdForStaff}']/table/tbody/tr//td/input", "dummy text for customData{$customGroupIdForStaff}"); $this->click("_qf_Contact_upload_view-bottom"); - sleep(5); + $this->waitForPageToLoad($this->getTimeoutMsec()); // Check confirmation alert. $this->assertTrue((bool)preg_match("/One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed. Click OK to proceed, or Cancel to review your changes before saving./", $this->getConfirmation())); $this->chooseOkOnNextConfirmation(); - sleep(10); - - $this->waitForElementPresent("xpath=//div[@id='contact-summary']/div[@id='contactTopBar']"); - $this->assertTrue($this->isElementPresent("xpath=//div[@id='contact-summary']/div[@id='contactTopBar']/table/tbody/tr/td[@class='crm-contact_type_label'][text()='{$selection2}, {$selection3}']")); + $this->waitForPageToLoad($this->getTimeoutMsec()); - //custom data check - if ($this->isElementPresent("{$groupTitleForParent}_0")) { - $groupidPa = "{$groupTitleForParent}_0"; - } - else { - $groupidPa = "{$groupTitleForParent}_1"; - } + // Verify contact types + $this->assertElementContainsText('crm-notification-container', "Contact Saved"); + $this->assertElementNotContainsText('css=.crm-contact_type_label', "Student"); + $this->assertElementContainsText('css=.crm-contact_type_label', "Staff"); + $this->assertElementContainsText('css=.crm-contact_type_label', "Parent"); //custom data check - if ($this->isElementPresent("{$groupTitleForStaff}_0")) { - $groupidSta = "{$groupTitleForStaff}_0"; - } - else { - $groupidSta = "{$groupTitleForStaff}_1"; - } - - $this->click($groupidSta); - $this->click($groupidPa); - $this->assertTrue($this->isTextPresent("dummy text for customData{$customGroupIdForParent}")); $this->assertTrue($this->isTextPresent("dummy text for customData{$customGroupIdForStaff}")); } + /** + * Add custom fields for a contact sub-type + */ function _addCustomData($contactSubType) { - - $this->openCiviPage("admin/custom/group", "reset=1"); - - //add new custom data - $customGroupTitle = "Custom group For {$contactSubType}" . substr(sha1(rand()), 0, 4); - $this->click("//a[@id='newCustomDataGroup']/span"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage("admin/custom/group", "action=add&reset=1"); //fill custom group title + $customGroupTitle = "Custom group For {$contactSubType}" . substr(sha1(rand()), 0, 4); $this->click("title"); $this->type("title", $customGroupTitle); //custom group extends - $this->click("extends[0]"); - $this->select("extends[0]", "value=Individual"); - $this->addSelection("extends[1]", "label={$contactSubType}"); + $this->click("extends_0"); + $this->select("extends_0", "value=Individual"); + $this->addSelection("extends_1", "label={$contactSubType}"); + + // Don't collapse + $this->uncheck('collapse_display'); + + // Save $this->click('_qf_Group_next-bottom'); $this->waitForElementPresent('_qf_Field_cancel-bottom'); diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index 197754a982..0a52c52deb 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -158,9 +158,15 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->openCiviPage("admin/uf/group/field/add", "reset=1&action=add&gid=$profileId"); $this->select("field_name[0]", "value={$values['type']}"); + // 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->select("field_name[1]", "value={$key}"); if (isset($values['location'])) { + // 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->select("field_name[2]", "value={$values['location']}"); } diff --git a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php index de2d5f651e..09a0b8bb23 100644 --- a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php +++ b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php @@ -315,7 +315,9 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent("relationship_type_id"); $this->select('relationship_type_id', "label={$params['label_a_b']}"); - //wait untill new contact dialog select is built + // 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: wait until new contact dialog select is built sleep(2); // create a new organization diff --git a/tests/phpunit/WebTest/Contact/SignatureTest.php b/tests/phpunit/WebTest/Contact/SignatureTest.php index 8fea0223cf..577a2d0282 100644 --- a/tests/phpunit/WebTest/Contact/SignatureTest.php +++ b/tests/phpunit/WebTest/Contact/SignatureTest.php @@ -32,8 +32,8 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { parent::setUp(); } - /* - * Test Signature in TinyMC. + /** + * Test Signature in TinyMC. */ function testTinyMCE() { $this->webtestLogin(); @@ -44,14 +44,12 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $name = $this->getText("xpath=//div[@class='crm-summary-display_name']"); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactId = $matches[1]; + $contactId = $this->urlArg('cid'); // Select Your Editor $this->_selectEditor('TinyMCE'); - $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}"); + $this->openCiviPage("contact/add", "reset=1&action=update&cid=$contactId"); $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); // HTML format message @@ -72,10 +70,10 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->click("//a[@id='crm-contact-actions-link']/span"); $this->click('link=Send an Email'); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(10); + $this->waitForElementPresent('subject'); $this->click('subject'); - $subject = 'Subject_' . substr(sha1(rand()), 0, 7); + $subject = 'Subject_' . substr(sha1(rand()), 0, 8); $this->type('subject', $subject); // Is signature correct? in Editor @@ -86,9 +84,12 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { // Go for Activity Search $this->_checkActivity($subject, $signature); + + // Set Editor back to default so we don't break other tests + $this->_selectEditor('CKEditor'); } - /* + /** * Test Signature in CKEditor. */ function testCKEditor() { @@ -109,7 +110,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->openCiviPage("contact/add", "reset=1&action=update&cid={$contactId}"); $this->click("//tr[@id='Email_Block_1']/td[1]/div[2]/div[1]"); - + // HTML format message $signature = 'Contact Signature in html'; $this->fireEvent('email_1_signature_html', 'focus'); @@ -127,7 +128,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->click("//a[@id='crm-contact-actions-link']/span"); $this->click('link=Send an Email'); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(10); + $this->waitForElementPresent('subject'); $this->click('subject'); $subject = 'Subject_' . substr(sha1(rand()), 0, 7); @@ -143,19 +144,22 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->_checkActivity($subject, $signature); } - /* + /** * Helper function to select Editor. */ function _selectEditor($editor) { $this->openCiviPage('admin/setting/preferences/display', 'reset=1'); - // Select your Editor - $this->click('editor_id'); - $this->select('editor_id', "label=$editor"); - $this->click('_qf_Display_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + // Change editor if not already selected + if ($this->getSelectedLabel('editor_id') != $editor) { + $this->click('editor_id'); + $this->select('editor_id', "label=$editor"); + $this->click('_qf_Display_next-bottom'); + $this->waitForPageToLoad($this->getTimeoutMsec()); + } } - /* + + /** * Helper function for Check Signature in Editor. */ function _checkSignature($fieldName, $signature, $editor) { @@ -170,7 +174,8 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->verifyText('//html/body', preg_quote("{$signature}")); $this->selectFrame('relative=top'); } - /* + + /** * Helper function for Check Signature in Activity. */ function _checkActivity($subject, $signature) { @@ -188,7 +193,7 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_ActivityView_next-bottom'); // Is signature correct? in Activity - $this->assertTrue($this->isTextPresent($signature)); + $this->assertTextPresent($signature); } } diff --git a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php index 76b2447daf..7f678fb3de 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php +++ b/tests/phpunit/WebTest/Contact/TaskActionAddToGroupTest.php @@ -70,6 +70,9 @@ class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase { // Click "check all" box and act on "Add to group" action $this->click('toggleSelect'); $this->select("task", "label=Add Contacts to Group"); + // 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("Go"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index 5596d8da06..c57fea010e 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -212,6 +212,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { ); $this->select('account_relationship', "label={$accountRelationship}"); + // 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(2); $this->select('financial_account_id', "label={$financialAccountTitle}"); $this->click('_qf_FinancialTypeAccount_next'); diff --git a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php index e8d096ed15..ef66abe8a5 100644 --- a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php @@ -147,9 +147,9 @@ class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase { // Clicking save. $this->click("_qf_Contribution_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(5); + $this->waitForElementPresent('civicrm-footer'); // Is status message correct? - $this->assertTrue($this->isTextPresent("The contribution record has been saved")); + $this->assertElementContainsText('crm-notification-container', "The contribution record has been saved"); $this->waitForElementPresent("xpath=//div[@id='Contributions']//table/tbody/tr/td[8]/span/a[text()='View']"); diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index f0292aea93..eadf5f6daf 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -396,6 +396,9 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->select('custom_pre_id', "label={$profileTitle}"); $this->click('_qf_Custom_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); + // 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->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page"); @@ -403,6 +406,9 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->select('custom_post_id', "label={$profileTitle}"); $this->click('_qf_Custom_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); + // 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->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page"); @@ -427,6 +433,9 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->check('is_organization'); $this->click('_qf_Settings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); + // 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->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up"); @@ -1207,6 +1216,9 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("onbehalf_organization_name"); $this->waitForElementPresent("css=div.ac_results-inner li"); $this->click("css=div.ac_results-inner li"); + // 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('onbehalf_member_campaign_id'); $this->select('onbehalf_member_campaign_id', "label={$title}"); diff --git a/tests/phpunit/WebTest/Contribute/PCPAddTest.php b/tests/phpunit/WebTest/Contribute/PCPAddTest.php index 45be1e4502..d21749d6d8 100755 --- a/tests/phpunit/WebTest/Contribute/PCPAddTest.php +++ b/tests/phpunit/WebTest/Contribute/PCPAddTest.php @@ -129,7 +129,6 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { $this->type("cms_pass", $pass); $this->type("cms_confirm_pass", $pass); } -// sleep(20); $this->click("_qf_PCPAccount_next-bottom"); $this->waitForElementPresent("_qf_Campaign_upload-bottom"); diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 85959074f7..6bd71189d9 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -492,6 +492,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { } $this->click("_qf_ContributionView_cancel-top"); $this->waitForPageToLoad($this->getTimeoutMsec()); + // 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(4); } } diff --git a/tests/phpunit/WebTest/Event/AddEventTest.php b/tests/phpunit/WebTest/Event/AddEventTest.php index 485bb5b3ab..abee5ed6bd 100644 --- a/tests/phpunit/WebTest/Event/AddEventTest.php +++ b/tests/phpunit/WebTest/Event/AddEventTest.php @@ -145,8 +145,14 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); $this->click("xpath=//a[@id='quickconfig']"); $this->waitForElementPresent('popupContainer'); + // 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("xpath=//div[@class='ui-dialog-buttonset']/button[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); //Assert quick config change and discount deletion @@ -297,7 +303,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { //check if pay later option is disabled $this->click('CIVICRM_QFID_1_is_monetary'); - sleep(3); $this->waitForElementPresent('is_pay_later'); $this->assertNotChecked('is_pay_later'); } diff --git a/tests/phpunit/WebTest/Event/TellAFriendTest.php b/tests/phpunit/WebTest/Event/TellAFriendTest.php index 0a673bddaa..9c63f8ceed 100644 --- a/tests/phpunit/WebTest/Event/TellAFriendTest.php +++ b/tests/phpunit/WebTest/Event/TellAFriendTest.php @@ -103,9 +103,7 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { $this->click('_qf_Form_submit'); $this->waitForPageToLoad($this->getTimeoutMsec()); - //to wait for thank you message to appear - sleep(5); - $this->assertTrue($this->isTextPresent($thankYouMsg)); + $this->waitForTextPresent($thankYouMsg); // Log in using webtestLogin() method $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php index c739bc57ff..a9bc270cf2 100644 --- a/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Export/ExportCiviSeleniumTestCase.php @@ -49,6 +49,10 @@ class ExportCiviSeleniumTestCase extends CiviSeleniumTestCase { // Download file. // File will automatically download without confirmation. $this->click($selector); + // 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 + // FIXME: consider doing the following assertion in a while loop + // with a more reasonable sleep time of 2 seconds per loop iteration sleep(20); // File was downloaded? diff --git a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php index 97c4da1108..8d74cd370a 100644 --- a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php +++ b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php @@ -137,6 +137,9 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1][text()='Banking Fees']/../td[7]/span/a[text()='Edit']"); $this->waitForElementPresent('_qf_FinancialTypeAccount_next'); $this->select('account_relationship', "value=select"); + // 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->select('account_relationship', "label=Accounts Receivable Account is"); $this->select('financial_account_id', "label=Accounts Receivable"); diff --git a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php index bd4061aa50..a3d83c5b9d 100644 --- a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php +++ b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php @@ -86,11 +86,14 @@ class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase { function _testAssignBatch($numberOfTrxn) { $this->select( "xpath=//div[@id='crm-transaction-selector-assign_length']/label/select[@name='crm-transaction-selector-assign_length']", "value=$numberOfTrxn" ); + // 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('toggleSelect'); $this->select('trans_assign', 'value=Assign'); $this->click('Go'); - sleep(5); + $this->waitForPageToLoad($this->getTimeoutMsec()); } function _testExportBatch($setTitle, $batchId, $exportFormat) { @@ -98,12 +101,12 @@ class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase { if ($exportFormat == 'CSV') { $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[2]"); $this->click('_qf_FinancialBatch_next-botttom'); - sleep(5); + $this->waitForPageToLoad($this->getTimeoutMsec()); } else { $this->click("xpath=//form[@id='FinancialBatch']/div[2]/table[@class='form-layout']/tbody/tr/td/input[1]"); $this->click('_qf_FinancialBatch_next-botttom'); - sleep(5); + $this->waitForPageToLoad($this->getTimeoutMsec()); } $this->openCiviPage("dashboard", "reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php index fb9e01f0e3..081669ebb9 100644 --- a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php +++ b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php @@ -49,6 +49,9 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase { 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); @@ -56,10 +59,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,6 +82,9 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase { $this->click("css=li#widget-2 a.fullscreen-icon"); $this->waitForElementPresent("ui-id-1"); $this->assertTrue($this->isTextPresent($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"); } @@ -78,14 +93,26 @@ 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(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)); } diff --git a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php index 7b299df126..68ab6a87b2 100644 --- a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php @@ -143,8 +143,7 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { // Submit form. $this->click('_qf_Preview_next-bottom'); - - sleep(10); + $this->waitForPageToLoad($this->getTimeoutMsec()); // Visit summary page. $this->waitForElementPresent("_qf_Summary_next"); @@ -233,7 +232,10 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { // Select contact subtype if (isset($other['contactSubtype'])) { if ($contactType != 'Individual') { - // wait for contact subtypes to repopulate. + // 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 + // FIXME: this is bad, using sleep to wait for AJAX + // Need to use a better way to wait for contact subtypes to repopulate sleep(5); } $this->waitForElementPresent("subType"); @@ -358,13 +360,12 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { // Submit form. $this->click('_qf_Preview_next'); - sleep(2); + $this->waitForPageToLoad($this->getTimeoutMsec()); // Check confirmation alert. $this->assertTrue((bool)preg_match("/^Are you sure you want to Import now[\s\S]$/", $this->getConfirmation())); $this->chooseOkOnNextConfirmation(); - - sleep(10); + $this->waitForPageToLoad($this->getTimeoutMsec()); // Visit summary page. $this->waitForElementPresent("_qf_Summary_next"); diff --git a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php index 3828fe9cec..e907ebf102 100644 --- a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php +++ b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php @@ -138,6 +138,9 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { $this->click("template"); $this->select("template", "label=$msgTitle"); + // 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("xpath=id('Upload')/div[2]/fieldset[@id='compose_id']/div[2]/div[1]"); $this->click('subject'); diff --git a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php index 337c86909a..17b98ece2c 100644 --- a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php +++ b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php @@ -163,6 +163,9 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}"); // Wait for membership type select to reload $this->waitForTextPresent($memTypeParams['membership_type']); + // 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->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}"); diff --git a/tests/phpunit/WebTest/Member/ContactContextAddTest.php b/tests/phpunit/WebTest/Member/ContactContextAddTest.php index 609648c045..743f940c67 100644 --- a/tests/phpunit/WebTest/Member/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Member/ContactContextAddTest.php @@ -71,6 +71,9 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}"); // Wait for membership type select to reload $this->waitForTextPresent($memTypeParams['membership_type']); + // 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->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}"); @@ -196,6 +199,9 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { // Wait for membership type select to reload $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']); + // 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->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}"); diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index 4b873f8875..497bf2b16e 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -240,6 +240,9 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->getConfirmation() )); $this->chooseOkOnNextConfirmation(); + // 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); //verify inherited membership has been removed @@ -257,7 +260,7 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->getConfirmation() )); $this->chooseOkOnNextConfirmation(); - sleep(10); + $this->waitForPageToLoad($this->getTimeoutMsec()); //verify membership $this->click('css=li#tab_member a'); diff --git a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php index 3a7210e633..9b8e03819d 100644 --- a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php @@ -85,6 +85,9 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase // since country is not pre-selected for offline mode $this->select("billing_country_id-5", "label=United States"); //wait for states to populate the select box + // 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(2); $this->click('billing_state_province_id-5'); $this->webtestAddBillingDetails($firstName, NULL, $lastName); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php index d4ab55bea5..98b9ad0eae 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php @@ -127,6 +127,9 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $i = 2; foreach($options as $index => $values){ $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}"); + // 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->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input",$values['membership_num_terms']); $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input",$values['label']); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index 6905923ae1..b21eac48b4 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -65,7 +65,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->webtestFillDate('join_date', '-2 year'); // Let Start Date and End Date be auto computed - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // 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: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -259,7 +262,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->webtestFillDate('join_date', '-2 year'); // Let Start Date and End Date be auto computed - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // 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: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -288,6 +294,9 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->select('membership_type_id[1]', "label={$newMembershipType['membership_type']}"); $this->click('membership_type_id[0]'); + // 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: wait for onchange handler sleep(2); // save the renewed membership @@ -365,7 +374,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->type('check_number', '1023'); $this->select('contribution_status_id', "label=Completed"); $this->click('send_receipt'); - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // 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: make sure onchange for total_amount has a chance to fire sleep(2); // Clicking save. @@ -396,7 +408,10 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForElementPresent('num_terms'); $this->type('num_terms', ''); $this->type('num_terms', '2'); - // added sleep to make sure jscript onchange for total_amount has a chance to fire + + // 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: make sure onchange for total_amount has a chance to fire sleep(2); $this->click('total_amount'); $this->verifyValue('total_amount', "200.00"); diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php index 52fc5a2939..3a125b0eba 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php @@ -54,6 +54,9 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next_checkout"); + // 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); // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case) @@ -85,6 +88,9 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->assertElementContainsText('css=div.display-block', $text, 'Missing text: ' . $text); $this->click("_qf_Confirm_next_checkout"); + // 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); // FIXME: By this time pending records has already been created. Formatting for external page (google checkout in this case) @@ -113,7 +119,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->select("duration_unit", "label=year"); //wait for the auto-complete member_of_contact to populate - sleep(3); + $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -127,7 +133,7 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->select("duration_unit", "label=year"); //wait for the auto-complete member_of_contact to populate - sleep(3); + $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php index 528540b774..a98a05bf98 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php @@ -144,8 +144,8 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->type("duration_interval", "1"); $this->select("duration_unit", "label=year"); - //wait for the auto-complete member_of_contact to populate - sleep(2); + // wait for the auto-complete member_of_contact to populate + $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -158,12 +158,11 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->select("duration_unit", "label=year"); //wait for the auto-complete member_of_contact to populate - sleep(2); + $this->waitForValue('member_of_contact', '::'); $this->click("_qf_MembershipType_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // create contribution page with randomized title and default params $amountSection = FALSE; $payLater = TRUE; diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index f5dea7d92e..481583c92e 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -142,6 +142,9 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $i = 2; foreach($options as $index => $values){ $this->select("membership_type_id_{$index}", "value={$values['membership_type_id']}"); + // 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->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[4]/input",$values['membership_num_terms']); $this->type("xpath=//table[@id='optionField']/tbody/tr[$i]/td[5]/input",$values['label']); diff --git a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php index 967927d5b6..e3aa6d30d9 100644 --- a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php +++ b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php @@ -96,6 +96,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Batch_next'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img"); + // 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->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('_qf_Batch_next'); @@ -183,6 +186,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // if other check Profile Field check box are affected $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[2]/img"); + // 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); if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") && !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") && @@ -203,6 +209,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'copy rows for field one failed'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[3]/img"); + // 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); if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[2]") && !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[3]/input[4]") && @@ -227,6 +236,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week"); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[4]/img"); + // 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); if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) { @@ -241,6 +253,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->fillRichTextField($richTextAreaIdOne, 'This is Test Introductory Message', 'CKEditor'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img"); + // 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); if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) { @@ -258,6 +273,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // if other radio Profile Field radio buttons are affected $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[6]/img"); + // 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); if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") && !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") && @@ -278,6 +296,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'copy rows for field one failed[radio button]'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[7]/img"); + // 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); if ($this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input") && !$this->isChecked("xpath=//form[@id='Batch']/div[2]/table/tbody/tr/td[7]/input[2]") && @@ -333,6 +354,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->selectFrame('relative=top'); $this->click("xpath=//table[@class='crm-copy-fields']/thead/tr/td[5]/img"); + // 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); if ($this->getValue($richTextAreaIdOne) == $this->getValue($richTextAreaIdTwo)) { @@ -394,6 +418,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // if other check Profile Field check box are affected $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[3]/div/img"); + // 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); if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") && !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") && @@ -414,6 +441,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)'); $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[4]/div/img"); + // 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); if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[2]") && !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[4]/input[4]") && @@ -438,6 +468,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->webtestFillDateTime($dateElementIdFirstRow, "+1 week"); $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[5]/div/img"); + // 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); if ($this->getValue("{$dateElementIdFirstRow}_time") == $this->getValue("{$dateElementIdSecondRow}_time") && $this->getValue("{$dateElementIdFirstRow}_display") == $this->getValue("{$dateElementIdSecondRow}_display")) { @@ -449,6 +482,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->type("xpath=//table[@id='voterRecords']/tbody/tr/td[@class='note']/input", 'This is Test Introductory Message'); $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[8]/div/img"); + // 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); if ($this->getValue("xpath=//table[@id='voterRecords']/tbody/tr/td[@class='note']/input") == $this->getValue("xpath=//table[@id='voterRecords']/tbody/tr[2]/td[@class='note']/input")) { @@ -465,6 +501,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { // if other radio Profile Field radio buttons are affected $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[6]/div/img"); + // 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); if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") && !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") && @@ -485,6 +524,9 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { $this->assertTrue($assertCheck, 'copy rows for field one failed for inteview (campaign)[radio button]'); $this->click("xpath=//table[@id='voterRecords']/thead/tr/th[7]/div/img"); + // 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); if ($this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input") && !$this->isChecked("xpath=//table[@id='voterRecords']/tbody/tr/td[7]/input[2]") && diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index 0019439cd5..db6a4a3d5d 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -226,6 +226,9 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->verifyElementNotPresent("//div[@id='crm-profile-block']/a/span"); //Check for edit functionality + // 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("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='Edit']"); $this->waitForElementPresent("//html/body/div[5]"); @@ -238,11 +241,17 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { // Check the delete functionality $this->click("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='Delete']"); $this->waitForElementPresent("//html/body/div[5]"); + // 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->assertElementContainsText('profile-dialog', 'Are you sure you want to delete this record?'); $this->click('_qf_Edit_upload_delete'); // Check the view functionality + // 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("//div[@id='browseValues']/div/div/table/tbody/tr/td[3]/span/a[text()='View']"); $this->waitForElementPresent("//html/body/div[5]"); diff --git a/tests/phpunit/WebTest/Profile/SearchTest.php b/tests/phpunit/WebTest/Profile/SearchTest.php index 80025faa69..c3ca85181a 100644 --- a/tests/phpunit/WebTest/Profile/SearchTest.php +++ b/tests/phpunit/WebTest/Profile/SearchTest.php @@ -155,6 +155,9 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Field_next-bottom'); // sleep 5 to make sure jQuery is not hiding field after page load + // 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->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.'); $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a"); diff --git a/tests/phpunit/WebTest/Report/LoggingReportTest.php b/tests/phpunit/WebTest/Report/LoggingReportTest.php index 8195b1a3ae..5b15a6d3fd 100644 --- a/tests/phpunit/WebTest/Report/LoggingReportTest.php +++ b/tests/phpunit/WebTest/Report/LoggingReportTest.php @@ -54,6 +54,9 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { //add contact to group $this->waitForElementPresent("xpath=//li[@id='tab_group']/a"); $this->click("xpath=//li[@id='tab_group']/a"); + // 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->select("group_id", "label=Case Resources"); $this->click("_qf_GroupContact_next"); @@ -72,6 +75,9 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { //tag addition $this->waitForElementPresent("xpath=//li[@id='tab_tag']/a"); $this->click("xpath=//li[@id='tab_tag']/a"); + // 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("xpath=//div[@id='tagtree']/ul//li/label[text()='Company']/../input"); $this->waitForTextPresent("Saved"); @@ -83,6 +89,9 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { //add new note $this->waitForElementPresent("xpath=//li[@id='tab_note']/a"); $this->click("xpath=//li[@id='tab_note']/a"); + // 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("xpath=//div[@id='Notes']//div[@class='action-link']/a"); @@ -112,6 +121,9 @@ class WebTest_Report_LoggingReportTest extends CiviSeleniumTestCase { //add new relationship , disable it , delete it $this->waitForElementPresent("xpath=//li[@id='tab_rel']/a"); $this->click("xpath=//li[@id='tab_rel']/a"); + // 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("xpath=//div[@id='Relationships']//div[@class='action-link']/a"); $this->waitForElementPresent("_qf_Relationship_refresh"); -- 2.25.1