which uses the entity info as its selection value
* @param array $pageUrl the url which on which the ajax custom group load takes place
- * @param $beforeTriggering code to execute before actual element triggering
+ * @param callable|boolean $beforeTriggering fn to execute before actual element triggering
* @return void
*/
function customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl, $beforeTriggering = NULL) {
//add the custom set
$return = $this->addCustomGroupField($customSets);
+ // Hack to ensure caches are properly cleared
+ // FIXME: This shouldn't be necessary, try to find root of the problem with WebTest_Event_AddParticipationTest::testAjaxCustomGroupLoad
+ if ($beforeTriggering === TRUE) {
+ $this->webtestLogout();
+ $this->webtestLogin();
+ }
+
$this->openCiviPage($pageUrl['url'], $pageUrl['args']);
foreach($return as $values) {
foreach ($values as $entityType => $customData) {
list($entity, $entityData) = explode('_', $entityType);
$elementType = CRM_Utils_Array::value('type', $customData['triggerElement'], 'select');
$elementName = CRM_Utils_Array::value('name', $customData['triggerElement']);
- if ($beforeTriggering) {
+ if (is_callable($beforeTriggering)) {
call_user_func($beforeTriggering);
}
if ($elementType == 'select') {
}
}
//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}");
+ $this->waitForElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]");
$this->assertElementPresent("xpath=//div[contains(@class, 'custom-group-{$customData['cgtitle']}')]/div[contains(@class, 'crm-accordion-body')]/table/tbody/tr/td[2]/input",
"The on the fly custom group field is not present for entity : {$entity} => {$entityData}");
}
$this->select("status_id", "value=2");
// click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickLink("_qf_Campaign_upload-bottom");
- $this->waitForText('crm-notification-container', "Campaign $title");
+ $this->checkCRMAlert("Campaign $title");
- $this->waitForElementPresent("xpath=//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[text()='$campaignTitle']");
- $url = explode('id=', $this->getAttribute("xpath=//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[text()='$campaignTitle']/../td[13]/span/a[text()='Edit']@href"));
- $campaignId = $url[1];
+ $this->waitForElementPresent("//td[text()='$campaignTitle']");
+ $campaignId = $this->urlArg('id', $this->getAttribute("//td[text()='$campaignTitle']/../td[13]/span/a[text()='Edit']@href"));
$this->offlineContributionTest($campaignTitle, $campaignId);
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);
+ $this->waitForElementPresent("css=#campaign_id option[value=$id]");
}
- $this->click("campaign_id");
$this->select("campaign_id", "value=$id");
// total amount
$this->click("_qf_Contribution_upload-bottom");
// Is status message correct?
- $this->waitForText('crm-notification-container', "The contribution record has been saved.");
+ $this->checkCRMAlert("The contribution record has been saved.");
$this->waitForElementPresent("xpath=//*[@id='Search']//div[2]//table[2]/tbody/tr/td[8]/span/a[text()='View']");
$this->addSelection("enableComponents-t", "label=CiviCampaign");
$this->click("//option[@value='CiviCampaign']");
$this->click("remove");
- $this->click("_qf_Component_next-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $this->assertTrue($this->isTextPresent("Changes Saved."));
+ $this->clickLink("_qf_Component_next-bottom");
+
+ $this->checkCRMAlert("Changes Saved.");
$this->openCiviPage('contribute/search', 'reset=1', '_qf_Search_refresh');
$this->multiselect2("includeGroups", array("$groupName", "Advisory Board"));
// fill the start date for campaign
- $this->webtestFillDate("start_date", "1 January 2011");
+ $this->webtestFillDate("start_date", "1 January " . (date('Y') - 1));
// fill the end date for campaign
- $this->webtestFillDate("end_date", "31 January 2011");
+ $this->webtestFillDate("end_date", "31 January " . (date('Y') - 1));
// select campaign status
$this->select("status_id", "value=3");
// click save
- $this->click("_qf_Campaign_upload-bottom");
- $this->waitForElementPresent("//*[@id='crm-notification-container']");
- $this->waitForText('crm-notification-container', "Campaign $pastCampaignTitle has been saved.");
+ $this->clickLink("_qf_Campaign_upload-bottom");
+ $this->checkCRMAlert("Campaign $pastCampaignTitle has been saved.");
$this->waitForElementPresent("link=Add Campaign");
$this->waitForElementPresent("link=Campaigns");
$this->click("search_form_campaign");
$this->type("campaign_title", $pastCampaignTitle);
- $this->click("xpath=//div[@class='crm-accordion-body']/table/tbody/tr[4]/td/a[text()='Search']");
-
- $this->waitForElementPresent("xpath=//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[text()='$pastCampaignTitle']");
- $url = explode('id=', $this->getAttribute("xpath=//div[@id='campaignList']/div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[text()='$pastCampaignTitle']/../td[13]/span/a[text()='Edit']@href"));
- $campaignId = $url[1];
+ $this->clickAjaxLink("//a[text()='Search']", "//td[text()='$pastCampaignTitle']");
+ $campaignId = $this->urlArg('id', $this->getAttribute("//td[text()='$pastCampaignTitle']/../td[13]/span/a[text()='Edit']@href"));
$this->offlineContributionTest($pastCampaignTitle, $campaignId, TRUE);
}
$this->click("campaign_id");
$this->select("campaign_id", "value=$id");
$this->waitForElementPresent('_qf_EventInfo_upload_done-bottom');
- $this->click("_qf_EventInfo_upload_done-bottom");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->clickLink("_qf_EventInfo_upload_done-bottom");
// 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.
$this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
// Type contact last name in contact auto-complete, wait for dropdown and click first result
- $this->webtestFillAutocomplete($firstName, 'contact_id');
+ $this->webtestFillAutocomplete($firstName);
// Select event. Based on label for now.
$this->select2("event_id", $eventName);
}
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");
// 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');
$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(
);
// 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(
$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);
$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);
$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']");
$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");
$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(
// 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(
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);
}
/*
$this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
- // Type contact last name in contact auto-complete, wait for dropdown and click first result
$this->webtestFillAutocomplete($firstName);
// Select event. Based on label for now.
// 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');
$this->type('check_number', '1044');
// give some time for js to process
- sleep(1);
+ $this->waitForAjaxContent();
$this->verifySelectedLabel("status_id", 'Partially paid');
// later on change the status
$this->select('status_id', 'label=Partially paid');
// 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->click('_qf_ContributionView_cancel-top');
+ $this->clickAjaxLink('_qf_ContributionView_cancel-top');
$this->waitForElementPresent("xpath=id('ParticipantView')/div[2]/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
// make additional payment
// 1 - check for links presence on participant view and edit page
$this->assertElementPresent("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span[2]/ul/li[2]/a[text()='Record Payment']");
$this->click("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
$this->waitForElementPresent("xpath=id('ParticipantView')");
- $this->assertElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]");
+ $this->waitForElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]");
$this->click("xpath=id('ParticipantView')//div[@class='action-link']/div/a/span[contains(text(), 'Edit')]");
$this->waitForElementPresent("xpath=id('Participant')");
- $this->assertElementPresent("xpath=id('Participant')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]");
- $location = $this->getAttribute("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]/../@href");
-
- $this->open($location);
- $this->waitForElementPresent("xpath=id('AdditionalPayment')");
+ $this->waitForElementPresent("xpath=id('Participant')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]");
+ $this->clickLinkSuppressPopup("xpath=id('Participant')//td[@id='payment-info']/a/span[contains(text(), 'Record Payment')]/../", 'AdditionalPayment');
// verify balance
$text = $this->getText("xpath=id('AdditionalPayment')/div[2]//table/tbody/tr[3]/td[2]");
$this->waitForText("xpath=//span[@id='totalAmount']/span", 'Payment amount cannot be greater than owed amount');
$this->type('total_amount', $balance);
$this->click('_qf_AdditionalPayment_upload-bottom');
- $this->waitForText('crm-notification-container', 'The payment record has been processed.');
+ $this->checkCRMAlert('The payment record has been processed.');
$this->waitForElementPresent("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
$this->click("xpath=id('Search')/table[@class='selector row-highlight']/tbody/tr[1]/td[8]/span/a[text()='View']");
// check the fee amount and contribution amount
$this->_checkPaymentInfoTable(800.00, 800.00);
- // check for not apprence of record payment button
+ // check for absence of record payment button
$this->assertFalse($this->isElementPresent("xpath=id('ParticipantView')//td[@id='payment-info']//a/span[contains(text(), 'Record Payment')]"));
- $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']");
$this->webtestVerifyTabularData(
array(
// view transaction popup info check
$this->waitForElementPresent("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
- $this->click("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
+ $this->clickAjaxLink("xpath=//td[@id='payment-info']/table[@id='info']/tbody/tr[2]/td[2]/a");
$this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[contains(text(), 'Amount')]/../../tr[2]/td[contains(text(), '$ 400.00')]/../../tr[3]/td[contains(text(), '$ 400.00')]");
$this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[3][contains(text(), 'Paid By')]/../../tr[2]/td[3][contains(text(), 'Check')]/../../tr[3]/td[3][contains(text(), 'Cash')]");
$this->waitForElementPresent("xpath=//table[@id='info']/tbody/tr/th[6][contains(text(), 'Status')]/../../tr[2]/td[6][contains(text(), 'Completed')]/../../tr[3]/td[6][contains(text(), 'Completed')]");