Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
- Fix all the TODO tags in the test.
User interface changes
API changes
Data model changes
=
Comment | File | Size | Author |
---|---|---|---|
#28 | 2809501-28.patch | 35.41 KB | Lendude |
#28 | interdiff-2809501-23-28.txt | 1.63 KB | Lendude |
#23 | 2809501-23.patch | 35.34 KB | Lendude |
#23 | interdiff-2809501-17-23.txt | 16.04 KB | Lendude |
#17 | 2809501-17.patch | 40.83 KB | MerryHamster |
Comments
Comment #2
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #3
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedWork in progress patch. I converted 1 of the 2 tests and can't get it to work yet. I have a lot of @TODO's for behavior I don't understand (yet) in there but wanted to share the progress.
Would love some early feedback on it as to why my first test fails.
Comment #4
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #5
LendudeAdding a drupalGet before the loading makes it pass. Makes little sense to me at the moment why that is.
The rest is just a little cleanup to make the method calls easier to trace.
Comment #6
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedThanks for looking into it. It's very weird. I expect it to work even without the form submit but somehow it doesn't. The UI actually displays everything correctly. I don't really know at the moment how to fix it. For now I'll just accept the drupalGet and make the test work and convert the other test.
Nice code cleanup btw.
Comment #7
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedI updated the test and implemented the second test. This test has the same problems though.. The tests to pass right now so it's a start. Still some weird requirements that I can't explain with my limited knowledge of fields in D8.
For now this is all I can do and I'll continue working on other tests. I've already spend several hours trying to figure this out, maybe someone with more fields knowledge has some more insights?
Comment #9
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedComment #10
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedSetting to proper status.
Comment #11
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedRerolled #7, there was a conflict on
core/modules/field_ui/src/Tests/ManageDisplayTest.php
.Comment #12
Mile23Testbot shows 25 coding standards errors: https://www.drupal.org/pift-ci-job/695080
Most are old-style array() declarations, which is unusual since we already fixed all those. That suggests the patch in #7 is out of date enough that the code being moved around doesn't reflect those array syntax fixes.
So one wonders what other changes aren't carried forward. Git log for ManageDisplayTest tells us that it's at least #2878369: Tests for local tasks in Manage Display are not correct which might be enough to fail a test or two. And maybe other changes since Nov. 2016.
That means that the code being moved into the trait here should be re-done so that we're sure we got all the changes.
Comment #16
jibranThis should be converted to WTB.
Comment #17
MerryHamster CreditAttribution: MerryHamster at Skilld commentedReroll patch from #11 and fixed coding standards errors.
Comment #18
MerryHamster CreditAttribution: MerryHamster at Skilld commentedComment #19
MerryHamster CreditAttribution: MerryHamster at Skilld commentedComment #20
MerryHamster CreditAttribution: MerryHamster at Skilld commentedComment #22
savkaviktor16@gmail.com CreditAttribution: savkaviktor16@gmail.com at Skilld commentedComment #23
LendudeWell, this take me back :)
Removed the new trait and just moved the one method to the test class. Removed all the todo's, cause if it's green it's green. Removed the weird third party assertion that was checking for something to be empty when we wouldn't actually expect it to be.
Lets see what the bot makes of this...
Comment #24
jibranPerfect! this looks ready to me. Thank you.
Haha, what makes you change your mind? :P
Pro Tip: Be careful about using the variables like this. After module uninstall we have a new container and storage is still old.
Comment #25
Lendude#25.1 Haha! I was hoping you would spot that :-) In this case the actual machine name is never used (like it was in the other test), we just need the link to show up so we can click on it.
#25.2 Yeah there are a number of assertions/tricks in this test that don't belong in a functional test. But 1-1 conversion, and moving them to a kernel test and getting the site in the right state would be a bit of bloat.
Comment #26
jibranShould have RTBCed 3 days ago sorry. :)
Comment #27
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedAwesome to see this ready!
I had a look and it seems patch has some (tiny) CS issues:
Nit: can we put these on a separate line each?
Missing docblock
Dont need this extra line.
Line over 80 chars :)
Comment #28
Lendude@Manuel Garcia thanks for taking a look. Feedback addressed, leaving it RTBC since its only cosmetic changes.
Comment #29
jibranRTBC +1
Comment #30
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedThanks @Lendude for addressing those :)
RTBC++
Comment #32
catchFixed these on commit:
Committed 0855561 and pushed to 8.7.x. Thanks!