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.
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Scope:
SearchAdvancedSearchFormTestSearchBlockTestSearchCommentTestSearchConfigSettingsFormTestSearchEmbedFormTestSearchLanguageTestSearchNodeUpdateAndDeletionTestSearchNumberMatchingTestSearchNumbersTestSearchPageCacheTagsTestSearchPageTextTestSearchPreprocessLangcodeTestSearchQueryAlterTestSearchRankingTest
Out of Scope:
- SearchBlockTest: postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and
- None
A way to port Simpletest AssertContentTrait::parse() was looked for, but this is not needed, since we can do better just using Mink for this.
SearchTestBase also needed to be updated because currently the only method on that would cause a fatal when used.
Comment | File | Size | Author |
---|---|---|---|
#35 | 2863842-35.patch | 26.47 KB | Lendude |
#35 | interdiff-2863842-32-35.txt | 1.32 KB | Lendude |
#32 | interdiff-29-32.txt | 2.63 KB | Anonymous (not verified) |
#32 | 2863842-32.patch | 26.31 KB | Anonymous (not verified) |
#29 | 2863842-29.patch | 25.03 KB | Lendude |
Comments
Comment #2
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedMany tests have been converted and are OK.
Some needs work, some other require postponed.
SearchAdvancedSearchFormTestSearchEmbedFormTestSearchLanguageTestSearchNodeUpdateAndDeletionTestSearchNumberMatchingTestSearchNumbersTestSearchPageCacheTagsTestSearchPageTextTestSearchPreprocessLangcodeTestSearchQueryAlterTestSearchRankingTestComment #3
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedcomment instead of edit summary. Oops
Comment #4
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedComment #6
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedHere is some fix, but the rest should be waiting for postponed (see summary)
Comment #8
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedFail due to clickLinkPartialName() and parse() as expected. Postponed, waiting after #2830773: Add legacy for clickLinkPartialName() method for browser tests and port of Simpletest AssertContentTrait::parse()
Comment #9
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedRemove two tests from this patch so it can be commited. 2 missing tests needs more work due to other issues. Let's deal with them in another issue.
Comment #11
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedWhat are you doing here TextFieldTest ? Please leave.
Sorry for this irrelevant test.
Comment #12
dawehnerDoes someone mind to create a followup issue so we don't forget to the convert the remaining bits?
Comment #13
dawehnerComment #14
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedI create #2870595: Convert postponed WTB to BTB for search module SearchBlockTest and SearchConfigSettingsFormTest to deal with postponed SearchBlockTest and SearchConfigSettingsFormTest so we can close this issue and working on remaining conversions in another thread.
Comment #15
dawehnerI'm wondering is this change really needed? Reading the function documentation explains that you should be able to provide a label.
Comment #16
GoZ CreditAttribution: GoZ at Barbe-Rousse, Centarro commentedI can't use label because there is a conflict with another 'Advanced search' label in form.
Comment #17
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedFollow-ups created and the feedback from @dawehner was explained. I think this is good to got!
Thanks @GoZ!
Comment #19
michielnugter CreditAttribution: michielnugter as a volunteer and at Synetic commentedUnrelated fail
Comment #20
dawehner+1 for the RTBC
Comment #21
alexpottRe #15 I think this makes the tests way less readable. However reading the docs for \Drupal\Tests\BrowserTestBase::submitForm() in BrowserTestBase I think we should just use that method instead and supply the $form_html_id param. Or maybe we should open an issue to add a param to drupalPostForm(). I think I prefer converting these calls to use \Drupal\Tests\BrowserTestBase::submitForm()
Comment #22
naveenvalechaCreated a follow-up for #21 #2887411: Add $form_html_id to drupalPostForm in BrowserTestBase and convert SearchTestBase::submitGetForm() to BrowserTestBase::drupalPostForm()
Shall we convert this particular test in follow-up and move with the tests which have minimal disruptions that way we'll have very fewer tests which are pending on postponed issues
//Naveen
Comment #23
naveenvalechaComment #24
larowlanWe can use ::findButton and then ::press instead of ::submitForm if there are conflicts
Comment #27
LendudeUnpostponed everything and converted everything.
We will not need parse() because we can do much better with the steps provided by @larowlan in #24. The existing
\Drupal\Tests\search\Functional\SearchTestBase::submitGetForm
method in HEAD is broken and will fatal when used. This means it is not used anywhere right now so I have little problem rewriting it to suit our needs, so I've done so.Also the follow up in #2887411: Add $form_html_id to drupalPostForm in BrowserTestBase and convert SearchTestBase::submitGetForm() to BrowserTestBase::drupalPostForm() won't help here to address #15 because the other label is also inside that form, so the collision will still occur even when restricting to the form. So using the #id makes sense even if it reduces readability (and having two buttons with the same label might be an accessibility issue and might be better solved by making sure we have two buttons that can be distinguished between? So might be something that should be fixed outside this test.)
Comment #29
Lendudefixed deprecation notices
Comment #30
borisson_Looks like we're losing some coverage here.
I'm not 100% sure though, but I think that we should fix that. That's the only thing I could find though. Also unassigned this issue.
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commented#15 / #21 / #27: Yep, as @Lendude said, #id does not help here:
But
findButton()
uses very widexpath
, include any html element with@role="button"
. As result a collision betweensummary
andinput
.We can introduce custom method to get submit button by preferred filter, or manually set edit fields + strict xpath, or even change label value in the
setUp()
. But while it is really a rare case, when form have few elements with button role + same text. So, +1 to just less readable'edit-submit--2'
.It is true to
WTB::drupalPostForm()
, butBTB::drupalPostForm()
usesaction
attribute ofform
. So after #2887411: Add $form_html_id to drupalPostForm in BrowserTestBase and convert SearchTestBase::submitGetForm() to BrowserTestBase::drupalPostForm() we can full replace submitGetForm on drupalPostForm with deprecated trigger.In any case, after the convert, the doc becomes obsolete. Maybe something like:
Here there can be a regression:
If we use
$form_html_id
all good ($wrapper = form). In any case $wrapper = $page, and if page contains two field with same name, thanfillField()
set value only to the first. So, better will be:#30: good catch, looks like unintentional deletion.
Comment #32
Anonymous (not verified) CreditAttribution: Anonymous commented#30: Hah, we are mistaken, @Lendude++ as always!
Node and comment used the same assert condition. So they can be combined. I just added a comment above this check to not forget about what we want to achieve here (in case someone in the future wants to optimize the check for search only nodes or comments).
#31: Done.
Comment #33
borisson_Awesome, looks great!
Comment #34
alexpott\Drupal\search\Tests\SearchTestBase
is already deprecated but we could do with a followup to trigger a silenced deprecation notice.This comment with stating with the "Not" doesn't read correctly and it looks superfluous because the test searched for says enough. let's remove it.
This means the $message is not longer used. Which is problematic because it adds context for the test.
Comment #35
Lendude#34.2 should be covered by #2886547: Add trigger_error to deprecated TestBase base classes/traits that have none, reference CR
#34.3 fixed
#34.4 true, how about using message as a fail text for the assertion.
Comment #36
alexpottThanks @Lendude - looks great.
Comment #37
alexpottCommitted ad90164 and pushed to 8.6.x. Thanks!