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.
Child to #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Problem/Motivation
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#74 | 2757007-74.patch | 4.9 KB | tameeshb |
#63 | 2757007-63.patch | 4.92 KB | tameeshb |
#63 | interdiff-56-63.txt | 546 bytes | tameeshb |
#60 | interdiff-2757007-57-60.txt | 2.61 KB | himanshu-dixit |
#60 | 2757007-60.patch | 75.65 KB | himanshu-dixit |
Comments
Comment #2
jibranComment #4
claudiu.cristeaI fixed all tests except one that is caused by #2767655: Allow WebAssert to inspect also hidden fields.
We should postpone this on that.
Comment #6
jibran@claudiu.cristea++ thanks mate for picking this up.
Comment #7
claudiu.cristea@jibran thanks. We have a green patch in #2767655: Allow WebAssert to inspect also hidden fields that could unblock this.
Comment #8
claudiu.cristeaBypassed #2767655: Allow WebAssert to inspect also hidden fields by moving
BookTest::testBookOrdering()
into a newBookJavascriptTest
(JavascriptTestBase) test.Comment #9
claudiu.cristeaHere we go. This is ready for review.
Comment #10
jibranThis looks perfect to me now. I think #8 is the correct way of handling it. That test was indeed related to JS and a JS specific test makes sense here.
Do we want to investigate this here?
Comment #11
claudiu.cristea@jibran, I would not block the conversion of test on this. I will open a new issue for that and try to reproduce the error in a dedicated test.
Comment #12
klausimessages should not be removed with this patch, we can do that when we replace the deprecated assertPattern() method calls with WebAssert invocations.
Comment #13
claudiu.cristeaOK for assertPattern() but the others have lost the message parameter in method signature. It's clear enough for review, now.
Comment #14
klausiWhoa, a javascript test! Yippee!
The second parameter for wait() is missing. Don't simply wait here; pass a javascript snippet condition until something is visible or whatever. See https://knpuniversity.com/screencast/behat/javascript-waiting for an example. And the max wait time should be longer, for example 5000 (5 seconds).
Never call t() in tests. Directly assert what should be there, we are not testing the Drupal translation system here. Also elsewhere.
use assertGreaterThan() instead.
assertGreaterThan()
I still think all the changes which just remove the messages should not be done because they are out of scope for this issue, but I don't care too much :)
Comment #15
jibranThank you @klausi for the review.
-1 to that. Let's not run ourselves to the ground. This is a test code we can keep on changing it all day long and it won't be done. This change is not impacting the testing scenario so let's leave it as is. I agree we shouldn't convert it but reverting it will be just like wasting time. It was my fault that I spent time on removing that additional param. Let's not waste any further time. Thank you.
Comment #16
claudiu.cristeaI added a new issue and a test for the drag'n'drop issue mentioned in the @todo: #2769825: Cannot swap tabledrag rows by dragging the lower over the upper row in tests.
Comment #17
claudiu.cristea@klausi, thank you for review. I reverted also the messages.
#14.1, 3, 4: Fixed. #14.2: I disagree. Even this is not a translation test we use t() when checking for translated elements on page. I agree it will give the same result. See https://www.drupal.org/simpletest-tutorial-drupal7 section "When to use t() in simpletests" (it's for simpletest but it's the same).
Comment #19
claudiu.cristeaThe CI says "ERROR: Step ?Publish JUnit test result report? failed: no workspace for default #181961"
Comment #21
dawehnerAre we actually still allowed to move along with this issues. @claudiu.cristea do you know something about it?
Comment #22
klausiNo, this issue is more or less postponed until we can shake out the random fails in #2776269: High random fail rate in BTB forum tests on Postgres (especially, but not only, with PHP7). In the meantime we should not commit more browser test conversions, because there is a high risk to reintroduce the random fails and give core committers headaches.
Comment #23
claudiu.cristea@dawehner, no, I'm totally confused about the test conversion policy. I didn't followed the discussion. But this is a case that cannot be converted with the bulk conversion issue because has a test that need to be converted into JavascriptTestBase.
Comment #24
dawehnerIMHO it would be still valuable to continue ...
Comment #25
claudiu.cristea@dawehner it needs review & RTBC. Is done IMO
Comment #27
klausiLooks almost ready, just some minor point that should be fixed:
this can be just be {@inheritdoc}
$session is not used for anything later, so this can be one line.
should be assertGreaterThan()
shouldn't the second parameter be "2nd page"?
Comment does not make sense, 2 times "1st page"?
https://www.drupal.org/node/2783189#t has now a section to never use t(), I'm also going to update the Drupal 7 variant to never use t(). We should not add unnecessary t() calls to new test code that we write.
Comment #28
claudiu.cristea@klausi,
#27.1:
No, unfortunately it cannot be yet. We need #2801883: Add an empty $modules property in BrowserTestBase first (Please review also that one).
#27.2-6: Fixed.
I also made
assertFirstPrecedesSecond()
more generic in the idea that at some point we can move it in BTB. At least I had in some projects cases where I need to make such assertions, with 2 or more than 2 elements.Comment #29
claudiu.cristeaComment #30
claudiu.cristeaNo, using
FormattableMarkup
is wrong with$this->assertSession()->pageTextContains()
as it turned out in #2773733: Fix AssertLegacyTrait::assert(No)Text to handle html encoded strings (part 3).Comment #31
claudiu.cristeaOK, now that #2801883: Add an empty $modules property in BrowserTestBase, I've fixed also the docs for
$modules
. This is ready, IMO.Comment #32
dawehnerTo be honest, all those tests needs some adaption, so I guess its kinda fine to have them. We will not be able to fix those my moving code around.
This is just super nice, that it works
Comment #33
Sam152 CreditAttribution: Sam152 commentedassertOrderInPage seems like a really handy helper method. We should add it to WebAssert so everyone can use it.
Comment #34
claudiu.cristeaNo sorry. That should be a followup because it needs also tests and it should be separate. I think a followup is more acceptable than hiding it here.
Comment #35
Sam152 CreditAttribution: Sam152 commentedAs you like. Back to RTBC for #31 then.
Comment #36
Sam152 CreditAttribution: Sam152 commentedIs there any precedent for testing our test methods like this? I can't seem to find any. If it's acceptable for a book test, I'm not sure why it wouldn't be acceptable to be used elsewhere.
Comment #38
claudiu.cristeaComment #39
claudiu.cristea@Sam152, I agree with you that the assertion could be useful in other places. But this is not in the scope of this issue. I'm not very sure that needs testing, though there are assertion methods that we are testing. @dawehner and @klausi are leading the PHPUnit initiative, maybe you should suggest them and if everybody agrees let's create a separate issue and fix there.
Comment #40
claudiu.cristeaReposting the patch from #31.
Comment #41
Sam152 CreditAttribution: Sam152 commentedSure, sounds fine to me. Opened #2817657: Add methods to assert that a sequence of strings appears on the page in a given order as a follow up.
Comment #42
Sam152 CreditAttribution: Sam152 commented#31 was already RTBC.
Comment #44
claudiu.cristeaComment #45
claudiu.cristeaIt was a random bot failure. Back to RTBC as per #31.
Comment #46
klausiLooks good, can we get the new javascript test as a separate child issue of #2809161: Convert Javascript/AJAX testing to use JavascriptTestBase? We can do that change immediately, the rest of book module will probably have to wait until we do the big conversion patch. See #2807237: PHPUnit initiative.
Comment #47
claudiu.cristea@klausi, opened #2820079: Convert \Drupal\book\Tests\BookTest::testBookOrdering() to a JavascriptTestBase test. It's ready for RTBC. Comparing to this I only added a @todo in BookJavascriptTest::assertOrderInPage()
Comment #48
dawehnerI'm wondering whether with #2809181: Provide forward compatibility layer for BrowserTestBase::xpath we could make this issue be redundant.
Comment #50
klausiNeeds a reroll.
Comment #51
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-roll.
Comment #52
klausiLooks like you forgot to move the files. The core/modules/book/src/Tests directory should be empty after this patch.
Comment #53
jofitz CreditAttribution: jofitz at ComputerMinds commentedOoops, let's try that re-roll again...
Comment #55
klausithe (string) cast is not needed anymore because getText() will already return a string.
Looks like your forgot to convert core/modules/book/src/Tests/BookInstallTest.php?
Then there is Views/BookRelationshipTest.php but that is again blocked on #2747167: Convert first part of web tests of views_ui and can be skipped for now.
Comment #56
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedComment #57
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedSorry, uploaded wrong patch by mistake.
Comment #58
claudiu.cristeaPerfect!
Note: I can RTBC this because the code I worked on has been moved to #2820079: Convert \Drupal\book\Tests\BookTest::testBookOrdering() to a JavascriptTestBase test.
Comment #59
alexpott#55 Looks like your forgot to convert core/modules/book/src/Tests/BookInstallTest.php?
Has not been addressed.
Comment #60
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commentedHere is the patch converting BookInstallTest.php. I don't understand why my patch is this big :(
Comment #62
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedConverted "convert core/modules/book/src/Tests/BookInstallTest.php"
Comment #63
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedRedone after staging and commiting...
Comment #64
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedComment #65
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer commented@tameeshb I don't understand what extra you apart from #60.
UPDATE: OK, i got it. But you could have made an interdiff against #60. It would have been easy.
Comment #66
tameeshb CreditAttribution: tameeshb at Google Summer of Code commented@himanshu-dixit interdiff against #60 wouldnt have made sense.
You are asking me to interdiff 75.65 KB Vs 4.92 KB!
Comment #67
alexpott@himanshu-dixit - you need to configure git to detect moves. See https://www.drupal.org/documentation/git/configure - specifically the bit about Ooptimising diffs for renamed and copied files.
Comment #68
claudiu.cristea@himanshu-dixit, you'll need to use the
-C
option when creating the patch with diff:or you can configure Git to do this automatically. In ~/.gitconfig add:
Comment #69
claudiu.cristeaBookInstallTest is converted too, now.
Comment #71
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedComment #72
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedThere's something wrong with the testbot, I saw the same problem in another issue.
Update: I came across the new coding standard about using only [] for array declarations and depreciating array().
Uploaded reroll.
Comment #73
Eric_A CreditAttribution: Eric_A commentedNeeds reroll now that #2776975: March 3, 2017: Convert core to array syntax coding standards for Drupal 8.3.x RC phase is in.
Comment #74
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedComment #75
jofitz CreditAttribution: jofitz at ComputerMinds commentedRemoved "Needs reroll" tag.
Comment #76
klausiLooks good, thanks!
Comment #77
alexpottCommitted and pushed 2c0c8c1 to 8.4.x and 610ea72 to 8.3.x. Thanks!
Comment #81
himanshu-dixit CreditAttribution: himanshu-dixit as a volunteer and at Google Summer of Code commented