Skip to content

Commit

Permalink
Add state token to email testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jitendrapurohit committed Feb 11, 2024
1 parent 95b7581 commit 92152b1
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions tests/src/FunctionalJavascript/ExistingContactElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ public function testTokensInEmail() {
$this->assertSession()->checkboxChecked("civicrm_1_contact_1_email_email");
$this->getSession()->getPage()->selectFieldOption('civicrm_1_contact_1_email_location_type_id', 'Main');

// Enable Address fields.
$this->getSession()->getPage()->selectFieldOption('contact_1_number_of_address', 1);
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->checkField('Country');
$this->assertSession()->checkboxChecked('Country');

$this->getSession()->getPage()->clickLink('Activities');
$this->getSession()->getPage()->selectFieldOption('activity_number_of_activity', 2);
$this->assertSession()->assertWaitOnAjaxRequest();
Expand All @@ -326,7 +332,7 @@ public function testTokensInEmail() {

$email = [
'to_mail' => '[webform_submission:values:civicrm_1_contact_1_email_email:raw]',
'body' => 'Submitted Values Are - [webform_submission:values] Existing Contact - [webform_submission:values:civicrm_1_contact_1_contact_existing]. Activity 1 ID - [webform_submission:activity-id:1]. Activity 2 ID - [webform_submission:activity-id:2]. Webform CiviCRM Contacts IDs - [webform_submission:contact-id:1]. Webform CiviCRM Contacts Links - [webform_submission:contact-link:1].',
'body' => 'Submitted Values Are - [webform_submission:values] Existing Contact - [webform_submission:values:civicrm_1_contact_1_contact_existing]. Activity 1 ID - [webform_submission:activity-id:1]. Activity 2 ID - [webform_submission:activity-id:2]. Webform CiviCRM Contacts IDs - [webform_submission:contact-id:1]. Webform CiviCRM Contacts Links - [webform_submission:contact-link:1] Country - [webform_submission:values:civicrm_1_contact_1_address_country_id]. State/Province - [webform_submission:values:civicrm_1_contact_1_address_state_province_id]',
];
$this->addEmailHandler($email);
$this->drupalGet($this->webform->toUrl('handlers'));
Expand All @@ -342,6 +348,24 @@ public function testTokensInEmail() {
$this->getSession()->getPage()->fillField('Last Name', 'Pabst');
$this->getSession()->getPage()->fillField('Email', '[email protected]');

$countryID = $this->utils->wf_civicrm_api4('Country', 'get', [
'where' => [
['name', '=', 'United States'],
],
], 0)['id'];
$stateProvinceID = $this->utils->wf_civicrm_api4('StateProvince', 'get', [
'where' => [
['abbreviation', '=', 'NJ'],
['country_id', '=', $countryID],
],
], 0)['id'];
$this->getSession()->getPage()->fillField('Street Address', '123 Milwaukee Ave');
$this->getSession()->getPage()->fillField('City', 'Milwaukee');
$this->getSession()->getPage()->fillField('Postal Code', '53177');
$this->getSession()->getPage()->selectFieldOption('Country', $countryID);
$this->getSession()->wait(1000);
$this->getSession()->getPage()->selectFieldOption('State/Province', $stateProvinceID);

$this->getSession()->getPage()->pressButton('Submit');
$this->assertPageNoErrorMessages();
$this->assertSession()->pageTextContains('New submission added to CiviCRM Webform Test.');
Expand Down Expand Up @@ -370,7 +394,8 @@ public function testTokensInEmail() {
[email protected] [1]
Existing Contact - Frederick Pabst. Activity 1 ID - {$actID1}. Activity 2 ID - {$actID2}.
Webform CiviCRM Contacts IDs - {$this->rootUserCid}. Webform CiviCRM Contacts Links -
{$cidURL}.
{$cidURL} Country - United
States. State/Province - New Jersey.
[1] mailto:[email protected]
", $sent_email[0]['body']);
Expand Down

0 comments on commit 92152b1

Please sign in to comment.