X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FWebTest%2FImport%2FImportCiviSeleniumTestCase.php;h=0e2c0e3354506b91f5bf1f7215cf0175cc54f322;hb=b78a8038cd5f8631030ae902e194f5958f3b34f2;hp=7b299df126b62d000cdf96c269ad84d1d30fc513;hpb=071a6d2e0aa7b375dbf6fecb4333a47a8ee35856;p=civicrm-core.git diff --git a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php index 7b299df126..0e2c0e3354 100644 --- a/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php +++ b/tests/phpunit/WebTest/Import/ImportCiviSeleniumTestCase.php @@ -1,9 +1,9 @@ click('_qf_UploadFile_upload'); + $this->click('_qf_DataSource_upload'); $this->waitForPageToLoad($this->getTimeoutMsec()); // Select matching field for cvs data. @@ -142,12 +142,7 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { $this->_checkImportMapperData($headers, $rows, $existingMapping, isset($other['checkMapperHeaders']) ? $other['checkMapperHeaders'] : array()); // Submit form. - $this->click('_qf_Preview_next-bottom'); - - sleep(10); - - // Visit summary page. - $this->waitForElementPresent("_qf_Summary_next"); + $this->clickLink('_qf_Preview_next-bottom', "_qf_Summary_next"); // Check success message. $this->assertTrue($this->isTextPresent("Import has completed successfully. The information below summarizes the results.")); @@ -173,7 +168,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * @params string $mode import mode * @params array $fieldMapper select mapper fields while import * @params array $other other parameters - * contactSubtype : import for selected Contact Subtype + * contactSubtype : import for selected Contact Subtype + * useMappingName : to reuse mapping * dateFormat : date format of data * checkMapperHeaders : to override default check mapper headers @@ -188,7 +184,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * callbackImportSummary : function to override default import summary assertions * * @params string $type import type (csv/sql) - * @todo:currently only supports csv, need to work on sql import + * @todo:currently only supports csv, need to work on sql import + */ function importContacts($headers, $rows, $contactType = 'Individual', $mode = 'Skip', $fieldMapper = array( ), $other = array(), $type = 'csv') { @@ -233,7 +230,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 +358,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"); @@ -432,7 +431,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * * @params string $component component name * - * @return string import url + * @return string import url + */ function _getImportComponentUrl($component) { @@ -451,7 +451,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * * @params string $component component name * - * @return string import url + * @return string import url + */ function _getImportComponentContactType($component, $contactType) { $importComponentMode = array( @@ -519,7 +520,8 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { * Helper function to get imported contact ids. * * @params array $rows fields rows - * @params string $contactType contact type + * @params string $contactType contact type + * * @return array $contactIds imported contact ids */ @@ -548,16 +550,14 @@ class ImportCiviSeleniumTestCase extends CiviSeleniumTestCase { $this->typeKeys("css=input#sort_name_navigation", $searchName); // Wait for result list. - $this->waitForElementPresent("css=div.ac_results-inner li"); + $this->waitForElementPresent("css=ul.ui-autocomplete li"); // Visit contact summary page. - $this->click("css=div.ac_results-inner li"); + $this->click("css=ul.ui-autocomplete li"); $this->waitForPageToLoad($this->getTimeoutMsec()); // Get contact id from url. - $matches = array(); - preg_match('/cid=([0-9]+)/', $this->getLocation(), $matches); - $contactIds[] = $matches[1]; + $contactIds[] = $this->urlArg('cid'); } return $contactIds;