Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
drupalPostAjaxForm()
is simulating the behaviour of ajax.js
, so using it, doesn't really provide fundamental guarantees.
#2809161: Convert Javascript/AJAX testing to use JavascriptTestBase suggests to convert them to JavascriptTestBase
Proposed resolution
- Figure out which part of the test is testing PHP code and which part ajax behaviour
- Extract the ajax behaviour into a test that extends JavascriptTestBase
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#19 | 2809521-19.patch | 3.33 KB | Lendude |
#19 | interdiff-2809521-17-19.txt | 555 bytes | Lendude |
#17 | 2809521-17.patch | 3.21 KB | martin107 |
#17 | interdiff-2809521-15-17.txt | 1.94 KB | martin107 |
#12 | 2809521-12.patch | 3.64 KB | martin107 |
Comments
Comment #3
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #6
martin107 CreditAttribution: martin107 as a volunteer commentedI have been nudged by @vaplas
in #2862510: Convert system/tests/src/Ajax to JavascriptTestBase I had created a monster patch which made changes to many test files.... it was unreviewable.
I have cut out the group test stuff from the last patch in that issue see
https://www.drupal.org/project/drupal/issues/2862510#comment-12225746
and created a new patch -- it should serve as a good starting point.
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commented🤣 I would call this a venerable entreaty) Great thanks!
Added minimal
AjaxTestBase
class for that test + made patch withdiff -M40
for more readability.AjaxTestBase
without methodassertCommand()
fromWTB::AjaxTestBase
, because it does not really check any js-behavior, and it will probably be moved to the BTB test-level in the future (or to Trait).Comment #9
martin107 CreditAttribution: martin107 as a volunteer commentedBy my way of thinking this patch is central to making progress in other phpunit initiative tests.
So by way of trade can I review any other D8 core issues in return for a review here?
This patch is now blocking these issues.
#2809529: Convert AJAX part of \Drupal\system\Tests\Ajax\ElementValidationTest::testAjaxElementValidation to JavascriptTestBase
#2809531: Convert AJAX part of \Drupal\system\Tests\Ajax\FormValuesTest::testSimpleAjaxFormValue to JavascriptTestBase
#2809535: Convert AJAX part of \Drupal\system\Tests\Ajax\MultiFormTest to JavascriptTestBase
Comment #11
LendudeThanks so much for working on this!
Hmm this looks like it has really minimal value. Do we really need this? Can't we just extend from WebDriverTestBase directly?
Comment #12
martin107 CreditAttribution: martin107 as a volunteer commentedYep, time passes and now introducing AjaxTestBase looks like a really bad idea.
Thank you.
Comment #13
martin107 CreditAttribution: martin107 as a volunteer commentedSorry bad patch... my bad
Comment #15
martin107 CreditAttribution: martin107 as a volunteer commentedWipes egg off my face and quietly removes local files.
Comment #17
martin107 CreditAttribution: martin107 as a volunteer commentedHmm that was passing locally ...on php7.23 not sure what explains that, but code related to the error report is deprecated code so....
stopped using
$this->assert()
& started using
$this->assertSession()->responseContains()
Comment #19
LendudeIt was missing the module with test path.
Comment #20
martin107 CreditAttribution: martin107 as a volunteer commentedThank you, thank you.
Lendude++
Comment #21
borisson_This looks great!
Comment #23
alexpottCommitted 7e55e67 and pushed to 8.7.x. Thanks!
Committed e4d867f and pushed to 8.6.x. Thanks!