protected function WebformCivicrmTestBase::editContactElement in Webform CiviCRM Integration 8.5
Edit contact element on the build form.
Parameters
array $params: Example Usage - $params = [ 'selector' => 'edit-webform-ui-elements-civicrm-4-contact-1-contact-existing-operations', 'widget' => 'Static', 'default' => 'relationship', 'filter' => [ 'group' => group_id, ], 'default_relationship' => [ 'default_relationship_to' => 'Contact 3', 'default_relationship' => 'Child of Contact 3', ], ];
6 calls to WebformCivicrmTestBase::editContactElement()
- CaseSubmissionTest::testCaseSubmission in tests/
src/ FunctionalJavascript/ CaseSubmissionTest.php - Test Case Submission.
- ContactSubmissionTest::testSelectContactElement in tests/
src/ FunctionalJavascript/ ContactSubmissionTest.php - Test select contact widget for existingcontact element.
- ContactSubmissionTest::testStaticCurrentUser in tests/
src/ FunctionalJavascript/ ContactSubmissionTest.php - Test Existing Contact Element configured as Current (logged-in) User
- ExistingContactElementTest::testRenderingOfExistingContactElement in tests/
src/ FunctionalJavascript/ ExistingContactElementTest.php - Verify if existing contact element is loaded as expected.
- MultiCustomFieldsSubmissionTest::testContactRefSubmission in tests/
src/ FunctionalJavascript/ MultiCustomFieldsSubmissionTest.php - Submit webform with 3 contact reference fields.
File
- tests/
src/ FunctionalJavascript/ WebformCivicrmTestBase.php, line 312
Class
Namespace
Drupal\Tests\webform_civicrm\FunctionalJavascriptCode
protected function editContactElement($params, $openWidget = TRUE) {
$this
->assertSession()
->waitForElementVisible('css', "[data-drupal-selector=\"{$params['selector']}\"] a.webform-ajax-link");
$contactElementEdit = $this
->assertSession()
->elementExists('css', "[data-drupal-selector=\"{$params['selector']}\"] a.webform-ajax-link");
$contactElementEdit
->click();
$this
->htmlOutput();
if ($openWidget) {
$this
->assertSession()
->waitForElementVisible('css', '[data-drupal-selector="edit-form"]');
$this
->assertSession()
->elementExists('css', '[data-drupal-selector="edit-form"]')
->click();
$this
->assertSession()
->elementExists('css', '[data-drupal-selector="edit-field-handling"]')
->click();
}
if (!empty($params['title'])) {
$this
->getSession()
->getPage()
->fillField('title', $params['title']);
}
if (!empty($params['description'])) {
$this
->fillCKEditor('properties[description][value]', $params['description']);
}
if (!empty($params['hide_fields'])) {
$this
->getSession()
->getPage()
->selectFieldOption('properties[hide_fields][]', $params['hide_fields']);
}
$this
->assertSession()
->waitForElementVisible('xpath', '//select[@name="properties[widget]"]');
if ($params['widget'] == 'Static') {
$this
->getSession()
->getPage()
->selectFieldOption('properties[show_hidden_contact]', 1);
}
else {
$this
->getSession()
->getPage()
->selectFieldOption('Form Widget', $params['widget']);
$this
->assertSession()
->assertWaitOnAjaxRequest();
if ($params['widget'] == 'Autocomplete') {
$this
->assertSession()
->waitForElementVisible('css', '[data-drupal-selector="edit-properties-search-prompt"]');
$this
->getSession()
->getPage()
->fillField('Search Prompt', '- Select Contact -');
}
}
$this
->htmlOutput();
if (!empty($params['default'])) {
$this
->assertSession()
->elementExists('css', '[data-drupal-selector="edit-contact-defaults"]')
->click();
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->getPage()
->selectFieldOption('Set default contact from', $params['default']);
if ($params['default'] == 'relationship') {
$this
->getSession()
->getPage()
->selectFieldOption('properties[default_relationship_to]', $params['default_relationship']['default_relationship_to']);
$this
->assertSession()
->assertWaitOnAjaxRequest();
$this
->getSession()
->getPage()
->selectFieldOption('properties[default_relationship][]', $params['default_relationship']['default_relationship']);
}
}
// Apply contact filter.
if (!empty($params['filter'])) {
if (!empty($params['filter']['group'])) {
$this
->assertSession()
->elementExists('css', '[data-drupal-selector="edit-filters"]')
->click();
$this
->getSession()
->getPage()
->selectFieldOption('Groups', $params['filter']['group']);
}
}
if (!empty($params['remove_default_url'])) {
$this
->getSession()
->getPage()
->uncheckField('properties[allow_url_autofill]');
}
$this
->getSession()
->getPage()
->pressButton('Save');
$this
->assertSession()
->assertWaitOnAjaxRequest();
}