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
In #3167880: [meta] Convert assertions involving use of xpath to WebAssert, where possible we identified that use of $this->xpath()
can be dangerous as we aren't always testing what we expect to test. In WebAssert we have more appropriate methods to find and assert HTML elements, so we should use them where possible.
This issue is scoped to find XPath selectors for <select>
and <option>
and convert those where possible.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#30 | 3187309-30.patch | 58.6 KB | kleiton_rodrigues |
#23 | 3187309-23.patch | 58.43 KB | adityasingh |
Comments
Comment #2
longwaveOnly two I couldn't figure out how to convert in FilterAdminTest:
Unsure if or how we can find the order that two elements appear in without using XPath like this.
Comment #3
longwaveA subtle bug fix here - the XPath selector has a typo, it was looking for a select element with ID
edit-predefined-langcode/option
- which doesn't exist, so $option_elements was empty, and the rest of the code went on to successfully compare two empty arrays.Comment #4
longwaveComment #5
longwaveSome improvements, some more cases that I missed.
Comment #6
mondrakeGreat work! Readibility so much improved. I have put down the nits below walking through - more food for thought than anything, please do not take them as strict.
In general:
Walkthrough:
We're missing the uniqueness check here. Some of the $message info could be inlined as comment.
Message->comment
Message->comment
Message->comment, uniqueness?
Message->comment, uniqueness?
again
very nice
Comment #7
longwaveDo you think it is worth adding a helper to extract option values/text from a select? We have the same loop repeated in a number of places.
Also, a helper to assert that an element exists only once might be useful too?
Comment #8
mondrake#7.1 - yeah but not so many of them, and something like this
seems already quite readable to me. But as you prefer.
#7.2 - well we could use
$this->assertSession()->elementsCount()
with $count = 1, do we really need a separate method?Comment #9
longwaveRerolled and addressed review points.
For #6.3 and #6.4 I think the comment above the block of assertions already explains what we are doing so the message isn't needed. Everywhere else I added back the messages either as assertion message or comment.
I didn't change #7.1 and I also forgot about elementsCount() so we don't need anything new, added that here where needed.
Comment #10
mondrakeCode style not passing.
Comment #11
SpokjeCreated an issue for failing the Custom Commands script not setting the issue status back to
Needs Work
automagically.(#3189649: Failing Custom Commands script doesn't change issue status from Needs Review to Needs Work)
Attached patch addresses Code Style failures in #9
Comment #13
SpokjeTrying to keep up The Good Fight Against TestBot Failures with attached patch
Comment #14
mondrakeLooks all good! RTBC
Comment #16
SpokjeRandom test fluke, back to RTBC per #14
Comment #17
SpokjeComment #18
mondrakeComment #19
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedComment #20
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedRerolled patch #12. Please review.
Comment #21
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedFixed the issue.
Comment #22
longwaveNeeds another reroll :(
Comment #23
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedReroll the patch.
Comment #24
mondrakeComment #26
catchThis is really nice clean-up, as evidenced by the diffstat:
Committed/pushed to 9.2.x.
We should backport to 9.1.x to make other backports easier, but that patch doesn't apply so needs a re-roll.
Comment #27
paulocsComment #28
paulocsComment #29
kleiton_rodrigues CreditAttribution: kleiton_rodrigues at CI&T commentedI m working
Comment #30
kleiton_rodrigues CreditAttribution: kleiton_rodrigues at CI&T commentedNew rollout performed for version 9.1.x
Comment #31
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedVerified patch#30. RTBC +1.
Comment #32
longwaveCompared the patches and they look good, the reason this doesn't go back cleanly is #3132919: Replace assert*() involving equality comparison operators with assert(Not)(Equals|Same) was committed to 9.2.x but not backported to 9.1.x.
Comment #34
catchCommitted/pushed to 9.1.x, thanks!