Webtest fixes and cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Event / AddParticipationTest.php
index 71227d0c1ace083119a6b1202d1573433d9b7d17..017ae01758b5ab33da960deef8248c2ed89bc754 100644 (file)
@@ -36,14 +36,11 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
   }
 
   function testEventParticipationAdd() {
-    // Log in using webtestLogin() method
     $this->webtestLogin();
 
     // Adding contact with randomized first name (so we can then select that contact when creating event registration)
-    // We're using Quick Add block on the main page for this.
     $firstName = substr(sha1(rand()), 0, 7);
     $this->webtestAddContact($firstName, 'Anderson', TRUE);
-    $contactName = "Anderson, $firstName";
     $displayName = "$firstName Anderson";
 
     $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
@@ -61,7 +58,6 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     // Using helper webtestFillDate function.
     $this->webtestFillDate('register_date', 'now');
     $today = date('F jS, Y', strtotime('now'));
-    // May 5th, 2010
 
     // Select participant status
     $this->select('status_id', 'value=1');
@@ -92,16 +88,14 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked by default but is not checked.');
     
     // Clicking save.
-    $this->click('_qf_Participant_upload-bottom');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->clickLink('_qf_Participant_upload-bottom');
 
     // Is status message correct?
-    $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
+    $this->checkCRMAlert("Event registration for $displayName has been added");
 
     $this->waitForElementPresent("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
     //click through to the participant view screen
-    $this->click("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
-    $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
+    $this->clickAjaxLink("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ParticipantView_cancel-bottom');
 
     $this->webtestVerifyTabularData(
       array(
@@ -114,8 +108,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     );
     // check contribution record as well
     //click through to the contribution view screen
-    $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
-    $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
+    $this->clickAjaxLink("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom');
 
     $this->webtestVerifyTabularData(
       array(
@@ -133,18 +126,15 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->webtestLogin();
 
     // Adding contact with randomized first name (so we can then select that contact when creating event registration)
-    // We're using Quick Add block on the main page for this.
     $firstName = substr(sha1(rand()), 0, 7);
     $this->webtestAddContact($firstName, 'Anderson', TRUE);
-    $contactName = "Anderson, $firstName";
     $displayName = "$firstName Anderson";
 
     // add custom data for participant role
     $this->openCiviPage("admin/custom/group", "reset=1");
 
     //add new custom data
-    $this->click("//a[@id='newCustomDataGroup']/span");
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->clickLink("//a[@id='newCustomDataGroup']/span");
 
     //fill custom group title
     $customGroupTitle = 'custom_' . substr(sha1(rand()), 0, 7);
@@ -159,12 +149,13 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->select('extends[1][]', 'value=2');
 
     $this->click("//option[@value='Contact']");
-    $this->clickLink('_qf_Group_next', 'label');
+    $this->clickLink('_qf_Group_next');
 
     //Is custom group created?
-    $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
+    $this->checkCRMAlert("Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
 
     //add custom field - alphanumeric checkbox
+    $this->waitForAjaxContent();
     $checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
     $this->click('label');
     $this->type('label', $checkboxFieldLabel);
@@ -195,13 +186,14 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->click('is_searchable');
 
     //clicking save
-    $this->clickLink('_qf_Field_done-bottom', 'newCustomField', FALSE);
+    $this->click('_qf_Field_done-bottom');
 
     //Is custom field created?
-    $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved.");
+    $this->checkCRMAlert("Custom field '$checkboxFieldLabel' has been saved.");
+    $this->waitForAjaxContent();
 
     //create another custom field - Integer Radio
-    $this->clickLink('newCustomField', '_qf_Field_cancel', FALSE);
+    $this->clickAjaxLink('newCustomField', '_qf_Field_cancel');
     $this->click('data_type[0]');
     $this->select('data_type[0]', 'value=1');
     $this->click("//option[@value='1']");
@@ -235,7 +227,10 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->click('is_searchable');
 
     //clicking save
-    $this->click('_qf_Field_done-bottom');
+    $this->clickAjaxLink('_qf_Field_done-bottom', NULL);
+
+    // Visit home page for a sec to give caches time to be cleared
+    $this->openCiviPage('');
 
     $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
 
@@ -282,16 +277,14 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
     $this->type('check_number', '1044');
 
     // Clicking save.
-    $this->click('_qf_Participant_upload-bottom');
-    $this->waitForPageToLoad($this->getTimeoutMsec());
+    $this->clickLink('_qf_Participant_upload-bottom');
 
     // Is status message correct?
-    $this->waitForText('crm-notification-container', "Event registration for $displayName has been added");
+    $this->checkCRMAlert("Event registration for $displayName has been added");
 
     $this->waitForElementPresent("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
     //click through to the participant view screen
-    $this->click("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']");
-    $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom');
+    $this->clickAjaxLink("xpath=//*[@id='Search']//table/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ParticipantView_cancel-bottom');
 
     $this->webtestVerifyTabularData(
       array(
@@ -309,8 +302,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
 
     // check contribution record as well
     //click through to the contribution view screen
-    $this->click("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
-    $this->waitForElementPresent('_qf_ContributionView_cancel-bottom');
+    $this->clickAjaxLink("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']", '_qf_ContributionView_cancel-bottom');
 
     $this->webtestVerifyTabularData(
       array(
@@ -369,7 +361,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase {
       array('entity' => 'ParticipantRole', 'subEntity' => 'Attendee','triggerElement' => array('name' => 'role_id', 'type' => "select"))
     );
     $pageUrl = array('url' => "participant/add", 'args' => "reset=1&action=add&context=standalone");
-    $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl);
+    $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, TRUE);
   }
 
   /*