Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D11 - WIP #973

Open
wants to merge 28 commits into
base: 6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
dcfaf7a
test
demeritcowboy May 30, 2024
4cc6b73
put this off for the moment
demeritcowboy May 30, 2024
947f688
flail wildly
demeritcowboy May 30, 2024
6213e40
more 11
demeritcowboy May 30, 2024
b622762
deprecation / cli syntax
demeritcowboy May 30, 2024
6636f31
more 11
demeritcowboy May 30, 2024
0e62d62
not sure what the problem is
demeritcowboy Jun 1, 2024
ebef343
speed up trial and error
demeritcowboy Jun 1, 2024
743ec14
undo speed up trial and error
demeritcowboy Jun 1, 2024
ef33ff3
Fix deprecation for D11 while still supporting D9, icon class https:/…
jackrabbithanna May 30, 2024
d0e6cf3
are these needed
demeritcowboy Jun 2, 2024
ae8ca55
show skipped
demeritcowboy Jun 2, 2024
4c75220
apply 3rd party patch for tababble
demeritcowboy Jun 4, 2024
720de16
phpunit 10 renames getName
demeritcowboy Jun 5, 2024
e5dc3e7
are these needed - it doesn't like them
demeritcowboy Jun 5, 2024
f99e325
are these needed
demeritcowboy Jun 7, 2024
cb4e80a
don't try to capture output while stuff is moving
demeritcowboy Jun 7, 2024
17db432
are these needed
demeritcowboy Jun 7, 2024
9056ee9
thought already did this
demeritcowboy Jun 7, 2024
de80402
are these needed
demeritcowboy Jun 10, 2024
df4af6a
rebase/reapply matrix
demeritcowboy Jun 25, 2024
0c658e1
make parent webform to use newer select2
demeritcowboy Jul 10, 2024
5db8bfc
adjust find/replace to match change in parent webform
demeritcowboy Jul 10, 2024
b78b993
passes locally, so try to see what's happening
demeritcowboy Jul 12, 2024
ff7624f
see if upstream MR 499 has anything
demeritcowboy Aug 12, 2024
a0dabf3
Try drupal/webform:6.3.x-dev@dev
KarinG Nov 20, 2024
93cdb81
verbose option removed in phpunit 10
demeritcowboy Nov 20, 2024
0aed128
put back these patches for tabbable and jquery since they aren't in p…
demeritcowboy Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,10 @@ jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
include:
- drupal: '10.2.*'
civicrm: '5.78.*'
php: '8.2'
- drupal: '10.2.*'
civicrm: '5.79.*'
php: '8.2'
- drupal: '10.2.*'
civicrm: '5.80.x-dev'
php: '8.2'
- drupal: '10.3.*'
- drupal: '11.x-dev'
civicrm: 'dev-master'
php: '8.3'
name: Drupal ${{ matrix.drupal }} | CiviCRM ${{ matrix.civicrm }}
Expand Down Expand Up @@ -96,25 +87,36 @@ jobs:
composer config repositories.1 path $GITHUB_WORKSPACE
composer install --no-interaction
COMPOSER_MEMORY_LIMIT=-1 composer require drupal/core-dev-pinned:${{ matrix.drupal }}
- name: Suppress links to screenshots
# This is done differently in 11. We'll come back to it...
# - name: Suppress links to screenshots
# There's so many! They can be useful locally if running one test, but they aren't useful here and cause massive scrolling.
run: |
cd ~/drupal
curl -L -O https://raw.githubusercontent.com/colemanw/webform_civicrm/def72b3dce1ea4bc7dd2cdd28a72844885727789/DrupalHtmlOutputTrait.diff
git apply DrupalHtmlOutputTrait.diff
# run: |
# cd ~/drupal
# curl -L -O https://raw.githubusercontent.com/colemanw/webform_civicrm/def72b3dce1ea4bc7dd2cdd28a72844885727789/DrupalHtmlOutputTrait.diff
# git apply DrupalHtmlOutputTrait.diff
- name: Install CiviCRM ${{ matrix.civicrm }}
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require civicrm/civicrm-asset-plugin:'~1.1' civicrm/civicrm-{core,packages,drupal-8}:${{ matrix.civicrm }} -W
- name: Download Webform
run: |
cd ~/drupal
COMPOSER_MEMORY_LIMIT=-1 composer require 'drupal/webform:^6.2'
COMPOSER_MEMORY_LIMIT=-1 composer require 'drupal/webform:6.3.x-dev@dev'
cd web/modules/contrib/webform
# somebody has submitted a patch for "tabbable"
curl -L -O https://git.drupalcode.org/project/webform/-/merge_requests/452.diff
git apply 452.diff
# use newer version of select2 that doesn't call jQuery.isArray
sed -i -e 's/4\.0\.13/4.1.0-rc.0/' webform.libraries.yml
- name: Install webform_civicrm
run: |
cd ~/drupal
# We used the github action `checkout` plugin at the start to check out the PR branch, and then set up a composer virtual `path` repo earlier when setting up composer config. So this should pull from that repo not the real one.
COMPOSER_MEMORY_LIMIT=-1 composer require drupal/webform_civicrm:@dev
#COMPOSER_MEMORY_LIMIT=-1 composer require drupal/webform_civicrm:@dev
cd web/modules/contrib
mkdir webform_civicrm
cd webform_civicrm
cp -a $GITHUB_WORKSPACE/* .
- name: Install token
run: |
cd ~/drupal
Expand Down Expand Up @@ -187,7 +189,7 @@ jobs:
run: |
mkdir -p $BROWSERTEST_OUTPUT_DIRECTORY
cd ~/drupal/web
../vendor/bin/phpunit --verbose -c core modules/contrib/webform_civicrm
../vendor/bin/phpunit --display-skipped -c core modules/contrib/webform_civicrm
env:
SYMFONY_DEPRECATIONS_HELPER: 999999
SIMPLETEST_DB: mysql://root:@127.0.0.1:${{ job.services.mysql.ports[3306] }}/db
Expand Down
8 changes: 7 additions & 1 deletion src/WebformCivicrmBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,17 @@ function getFileInfo($fieldName, $val, $entity, $n) {
}
$file = $this->utils->wf_crm_apivalues('Attachment', 'get', $val);
if (!empty($file[$val])) {
if (function_exists('file_icon_class')) {
$icon_class = file_icon_class($file[$val]['mime_type']);
}
else {
$icon_class = \Drupal\file\IconMimeTypes::getIconClass($file[$val]['mime_type']);
}
return [
'data_type' => 'File',
'name' => $file[$val]['name'],
'file_url'=> $file[$val]['url'],
'icon' => file_icon_class($file[$val]['mime_type']),
'icon' => $icon_class,
];
}
return NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ name: 'Webform CiviCRM test'
type: module
description: 'Support module for webform civicrm testing.'
package: 'Webform CiviCRM Testing'
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11
dependencies:
- 'webform_civicrm:webform_civicrm'
2 changes: 1 addition & 1 deletion tests/src/FunctionalJavascript/ActivitySubmissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ private function addActivityFields($num = 1, $select_activity = FALSE) {
if ($num > 1) {
$multiple = TRUE;
$this->getSession()->getPage()->find('xpath', '//div[contains(@class, "form-item-civicrm-1-activity-1-activity-assignee-contact-id")]/a[contains(@class, "select-multiple")]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
}
$this->assertSession()->assertWaitOnAjaxRequest();
for ($i = 1; $i <= $num; $i++) {
$this->getSession()->getPage()->selectFieldOption('civicrm_1_activity_1_activity_assignee_contact_id[]', "Contact {$i}", $multiple);
}
Expand Down
3 changes: 0 additions & 3 deletions tests/src/FunctionalJavascript/ContactRelationshipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,8 @@ public function testSubmitWebform() {
$contactElementEdit->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->elementExists('css', '[data-drupal-selector="edit-contact-defaults"]')->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->selectFieldOption('Set default contact from', 'Relationship to...');
$this->assertSession()->assertWaitOnAjaxRequest();
$loadedRelationshipTypes = $this->getOptions('Specify Relationship(s)');
$type = array_search('School is Contact 1', $loadedRelationshipTypes);
$this->getSession()->getPage()->selectFieldOption('Specify Relationship(s)', $type);
Expand Down
5 changes: 1 addition & 4 deletions tests/src/FunctionalJavascript/ContactSubmissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,10 @@ public function testStaticAndAutocompleteOnContactElement() {
$contactElementEdit->click();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->elementExists('css', '[data-drupal-selector="edit-form"]')->click();

$this->assertSession()->waitForField('properties[widget]');
$this->getSession()->getPage()->selectFieldOption('Form Widget', 'Autocomplete');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->waitForElementVisible('css', '[data-drupal-selector="edit-properties-search-prompt"]');
$this->addFieldValue('Search Prompt', '- Select Contact -');

Expand All @@ -255,7 +253,6 @@ public function testStaticAndAutocompleteOnContactElement() {
$this->assertSession()->elementExists('css', '.token-input-delete-token')->click();

$this->fillContactAutocomplete('token-input-edit-civicrm-1-contact-1-contact-existing', $contact_result['values'][0]['first_name']);
$this->assertSession()->assertWaitOnAjaxRequest();

$this->assertFieldValue('edit-civicrm-1-contact-1-contact-first-name', $contact_result['values'][0]['first_name']);
$this->assertFieldValue('edit-civicrm-1-contact-1-contact-last-name', $contact_result['values'][0]['last_name']);
Expand Down Expand Up @@ -616,7 +613,7 @@ public function testSubmitWebform($contact_type, array $contact_values) {
* @return \Generator
* The test data.
*/
public function dataContactValues() {
public static function dataContactValues() {
yield [
'Individual',
[
Expand Down
4 changes: 0 additions & 4 deletions tests/src/FunctionalJavascript/ContributionDummyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,10 @@ public function testAssignContributionSecondContactSelectByUser() {
$this->getSession()->getPage()->selectFieldOption('civicrm_1_contribution_1_contribution_enable_contribution', 1);
// Assign the contribution to contact "- User Select -"
$this->getSession()->getPage()->selectFieldOption('civicrm_1_contribution_1_contribution_contact_id', 'create_civicrm_webform_element');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->getSession()->getPage()->selectFieldOption('Currency', 'USD');

$this->enableBillingSection();
$this->assertSession()->assertWaitOnAjaxRequest();

$this->htmlOutput();
$this->saveCiviCRMSettings();
Expand Down Expand Up @@ -654,12 +652,10 @@ public function testAssignContributionSecondContactSelectByUserPaymentProcessor(
$this->getSession()->getPage()->selectFieldOption('civicrm_1_contribution_1_contribution_enable_contribution', 1);
// Assign the contribution to contact "- User Select -"
$this->getSession()->getPage()->selectFieldOption('civicrm_1_contribution_1_contribution_contact_id', 'create_civicrm_webform_element');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->getSession()->getPage()->selectFieldOption('Currency', 'USD');

$this->enableBillingSection();
$this->assertSession()->assertWaitOnAjaxRequest();

$this->htmlOutput();
$this->saveCiviCRMSettings();
Expand Down
3 changes: 0 additions & 3 deletions tests/src/FunctionalJavascript/ExistingContactElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ function testRenderingOfExistingContactElement() {

// Enter contact 3.
$this->fillContactAutocomplete('token-input-edit-civicrm-3-contact-1-contact-existing', 'Maarten');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertFieldValue('edit-civicrm-3-contact-1-contact-job-title', 'Accountant');

// Check if related contact is loaded on c4.
Expand Down Expand Up @@ -204,14 +203,12 @@ public function testDisplayFields() {
// Search on first name and verify if the contact is selected.
$this->drupalGet($this->webform->toUrl('canonical'));
$this->fillContactAutocomplete('token-input-edit-civicrm-1-contact-1-contact-existing', 'James');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertFieldValue('edit-civicrm-1-contact-1-contact-first-name', 'James');
$this->assertFieldValue('edit-civicrm-1-contact-1-contact-last-name', 'Doe');

// Search on source value and verify if the contact is selected.
$this->drupalGet($this->webform->toUrl('canonical'));
$this->fillContactAutocomplete('token-input-edit-civicrm-1-contact-1-contact-existing', 'Webform Testing');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertFieldValue('edit-civicrm-1-contact-1-contact-first-name', 'James');
$this->assertFieldValue('edit-civicrm-1-contact-1-contact-last-name', 'Doe');
}
Expand Down
1 change: 0 additions & 1 deletion tests/src/FunctionalJavascript/GrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ function testSubmitGrant() {
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->getSession()->getPage()->selectFieldOption('Grant Type', $this->grant_type_id);
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->assertSession()->checkboxChecked("Amount Requested");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ public function testSubmitMembershipQueryParams() {
$this->htmlOutput();

$this->getSession()->getPage()->clickLink('Advanced');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$fieldset = $this->assertSession()->elementExists('css', '[data-drupal-selector="edit-default"]');
$fieldset->click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ public function testContactRefSubmission() {
$this->htmlOutput();
foreach ([2, 3, 4, 5] as $c) {
$this->getSession()->getPage()->clickLink("Contact {$c}");
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->selectFieldOption("{$c}_contact_type", 'Household');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->checkField("civicrm_{$c}_contact_1_contact_existing");
$this->assertSession()->checkboxChecked("civicrm_{$c}_contact_1_contact_existing");
}
Expand Down Expand Up @@ -283,13 +281,11 @@ public function testSubmitWebform() {
$this->htmlOutput();

$this->getSession()->getPage()->clickLink('Contact 2');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->checkField('civicrm_2_contact_1_contact_existing');
$this->assertSession()->checkboxChecked('civicrm_2_contact_1_contact_existing');
$this->enableCustomFields(2);

$this->getSession()->getPage()->clickLink('Contact 3');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->checkField('civicrm_3_contact_1_contact_existing');
$this->assertSession()->checkboxChecked('civicrm_3_contact_1_contact_existing');
$this->enableCustomFields(3);
Expand Down
16 changes: 9 additions & 7 deletions tests/src/FunctionalJavascript/WebformCivicrmTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ abstract class WebformCivicrmTestBase extends CiviCrmTestBase {
*/
protected static $configSchemaCheckerExclusions = [
'webform.webform.civicrm_webform_test',
// In drupal 11 the reserved and startIndex fields are saying they have
// no schema for them in ckeditor5, but it does, so not sure what the
// problem is.
'editor.editor.webform_default',
];

/**
Expand Down Expand Up @@ -118,7 +122,9 @@ protected function tearDown(): void {
// store the civi log in the downloadable artifacts
$logfile = \Civi::$statics['CRM_Core_Error']['logger_file'] ?? NULL;
if ($logfile && file_exists($logfile)) {
copy($logfile, '/home/runner/drupal/web/sites/simpletest/browser_output/' . \CRM_Utils_File::makeFilenameWithUnicode($this->getName()) . '.log');
// phpunit10 renames getName
$testName = method_exists($this, 'getName') ? $this->getName() : $this->name();
copy($logfile, '/home/runner/drupal/web/sites/simpletest/browser_output/' . \CRM_Utils_File::makeFilenameWithUnicode($testName) . '.log');
}
parent::tearDown();
}
Expand Down Expand Up @@ -242,7 +248,6 @@ protected function configureContributionTab($params = []) {
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()->pageTextContains('You must enable an email field for Contact 1 in order to process transactions.');
$this->getSession()->getPage()->pressButton('Enable It');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->getSession()->getPage()->selectFieldOption('Currency', 'USD');
$this->getSession()->getPage()->selectFieldOption('Financial Type', $params['financial_type_id'] ?? 1);
$this->assertSession()->assertWaitOnAjaxRequest();
Expand All @@ -264,7 +269,6 @@ protected function configureContributionTab($params = []) {
}
else {
$this->getSession()->getPage()->selectFieldOption('Enable Receipt?', 'No');
$this->assertSession()->assertWaitOnAjaxRequest();
}
}

Expand Down Expand Up @@ -508,10 +512,11 @@ protected function editContactElement($params) {
$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");
$this->createScreenshot($this->htmlOutputDirectory . '/pic' . hrtime(true) . '.png');
$contactElementEdit->click();
$this->htmlOutput();

$this->assertSession()->waitForElementVisible('css', "button.webform-details-toggle-state");
$this->htmlOutput();
$expandLink = $this->cssSelect('button.webform-details-toggle-state')[0];
if ($expandLink->getText() == 'Expand all') {
$expandLink->click();
Expand Down Expand Up @@ -561,7 +566,6 @@ protected function editContactElement($params) {

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'] == 'Specified Contact') {
Expand All @@ -570,7 +574,6 @@ protected function editContactElement($params) {

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']);
}
}
Expand Down Expand Up @@ -691,7 +694,6 @@ protected function enableComponent($componentName) {
*/
protected function enableBillingSection() {
$this->getSession()->getPage()->selectFieldOption('Enable Billing Address?', 'Yes');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->htmlOutput();
$this->assertSession()->checkboxChecked("Billing First Name");
$this->assertSession()->checkboxNotChecked("Billing Middle Name");
Expand Down
2 changes: 1 addition & 1 deletion webform_civicrm.info.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: 'Webform CiviCRM'
type: module
description: 'Webform CiviCRM Integration'
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^9.4 || ^10 || ^11
package: 'CiviCRM'
dependencies:
- drupal:webform
Loading