Problem/Motivation
See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase)
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | interdiff-37-38.txt | 1.73 KB | mpdonadio |
| #38 | 2780063-38.patch | 50.67 KB | mpdonadio |
| #37 | 2780063-37.patch | 51.63 KB | mpdonadio |
| #32 | interdiff-28-32.txt | 989 bytes | mpdonadio |
| #32 | 2780063-32.patch | 51.31 KB | mpdonadio |
Comments
Comment #2
mpdonadioMay be premature since we have some major work going on with this, but want to start to identify what this needs for conversion. Being able to mock some of the classes for consistent tests will be a huge benefit for flushing out any remaining timezone problems.
Here is just the base class change. It is going to fail b/c the xpath and $this::url.
Note to anyone else working on this, the `renames = copies` bit in https://www.drupal.org/node/1542048 is important to make sure we have minimal (ha!) rebase / merge problems once other patches start landing.
Comment #4
xjmSee: #2735005-69: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase).
I would recommend postponing this, or using it to contribute BC layers upstream to BTB.
Comment #5
mpdonadioDoing some housekeeping, and postponing this on #2784537: Add legacy assertFieldByXPath()/assertNoFieldByXPath() method for browser tests. Also note that they are currently in the exclusion list in #2770921: Feb 21st: Convert chunk of WTB to BTB by just moving classes, changing use statements adding traits.
When that lands, I think we need to make the decision on how to proceed with this. I think that is the only main blocking issue (also need to replace $this->url in a few places with the one from the session).
DateTimeFieldTest and DateRangeFieldTest are monsters. I think at the very least, we need to refactor them to split out the item/field, widget, and formatter tests into separate classes, and make the decision as to whether to use UTB, KTB, or BTB. And at the same time, clean up some of the kernel-style things that are being done in UI tests (note how in #2811725: Error when render Datetime Range field: Error: Unsupported operand types how this caused something to slip through the cracks).
Comment #6
mpdonadioHere is where we stand with rename + #2784537: Add legacy assertFieldByXPath()/assertNoFieldByXPath() method for browser tests + `$this->url => $this->getSession()->getCurrentUrl()`.
Not sure why we aren't getting past the $this->drupalLogin() here.
Comment #9
mpdonadioSo, this is essentially blocked on drupalPostAjaxForm() support. We also need to figure out what to do with DateTestBase::renderTestEntity(), in particular the setRawContent() call.
Comment #10
mpdonadioKeep forgetting to tag issues.
Comment #11
jofitzRe-rolled.
Comment #13
jofitz$this->renderTestEntity() can no longer work in the same manner under BTB so this assertions after running this needed to be refactored (similar to #2763013: Convert web tests to browser tests for link module).
I'm open to suggestions of a simpler method for solving the test failures, but I sure can't think of one (and I've spent a long time thinking about it)!
Comment #14
mpdonadio#13 see https://www.drupal.org/node/2809181#comment-11954258 for an idea I had about how to rework $this->renderTestEntity().
Your idea looks better, though, at quick glance.
Comment #15
mpdonadioGreen patch! Sa-weet!
Partial review, a lot of the same comment apply to the DateRange version.
I'm worried we are losing coverage here. The XPath assertion made sure the time element was actually rendered out. This justs checked that the ISO string is there.
Is this needed?
Ditto about time.
Ditto about needed.
Hmmm. I think I am OK with this change. Not really sure why this needed Ajax in the first place.
Ditto about Ajax.
Comment out test :) Happens in a bunch of places in the DateRange test.
Overall, this looks great. Mainly worried about losing coverage on the time element.
Comment #16
jofitz$expected_markup = '<time datetime="' . $expected_iso . '" class="datetime">' . $expected . '</time>';so at least it is now looking for a rendered element.//text()avoids the error(see #11)
Comment #17
klausiwe need to update the docs for this function to have an @return tag. See also the link module conversion.
we can just use ->getUrl() here.
same here.
we need to open an issue to add assertOptionByText() to AssertLegacyTrait for better browser test compatibility. Then we don't have to change these lines.
Postponing this until we have #2862470: Add assertOptionByText() to AssertLegacyTrait for better browser test compatibility.
Comment #18
goz commented#2862470: Add assertOptionByText() to AssertLegacyTrait for better browser test compatibility has been fixed, let's work on this again
Comment #19
goz commentedComment #20
klausiyou can use $this->getUrl() here.
same here, let's use getUrl() everywhere.
Comment #21
goz commentedRight, i only replaced the one you mentioned.
Comment #22
boaloysius commentedpatch #19 had 12 matches for $this->getSession()->getCurrentUrl().
Comment #23
dawehnerI really like how this makes the test a bit more explicit.
I wonder this could be a JavascriptTestBase test instead. Maybe you could open up a new follow up for that.
Comment #24
klausiLooks good!
I think the conversions for drupalPostAjaxForm() are fine because we did not test javascript functionality anyway. We are just testing the HTML of the response, which is the same when posting the form normally and via AJAX.
Comment #25
mpdonadioI am 98% sure that this is good, but I want to give this a close study to make sure we aren't regressing anything with xpath test changes.
We also need to create a f/up plan to figure out how to make these more managble. 1000+ line test classes are not good.
Comment #26
mpdonadioOK, for my own sanity, I verified that the tests are actually being run, https://dispatcher.drupalci.org/job/drupal_patches/8878/consoleFull
Because of needing to rework what renderTestEntity does in order for a minimal conversion, this is an in-scope-change.
This could potentially be done with some Mink shenanigans to do the exact same thing, but I this this is a necessary change. The link.module conversion is also doing the same thing.
Not totally happy with this, but scoping this as a conversion with minimal refactoring, I think this is a necessary change. It make this a little more brittle, but I don't see a better alternative.
Nit that can be fixed on commit, should be alphabetical.
See #16.
I went through this pretty carefully, and think we have as close to a one-to-one conversion as we are going to get. These tests work, but are a big mess. Adding Needs Followup so we can plan out how to refactor these now that the BTB conversion is done. Will make that issue later.
This is RTBC from my perspective.
Comment #27
lendudeAre we just (re)moving base classes? Not deprecating them and making a new BrowserTestBase version? This would break any contrib testsuite building their tests on these Webtestbase base classes.
Follow up needed for the Views based test in Datetime, as far as I can see they should be converted to kernel tests so opened up #2865992: Convert Datetime module Views tests to Kerneltest and rolled that conversion.
Comment #28
mpdonadioVery, very good point.
Comment #30
mpdonadioRetriggered b/c the JSTB intermittents, https://www.drupal.org/pift-ci-job/637557
Comment #31
lendudeMissing the trigger_error under the namespace as described in the Drupal core deprecation policy.
Comment #32
mpdonadioHere we go.
Comment #33
lendude@mpdonadio looks great.
Applied the patch and everything that needs to be moved, gets moved.
Back to RTBC.
Comment #34
alexpottCommitted 5e8c04d and pushed to 8.4.x. Thanks!
The patch needs re-rolling for 8.3.x.
Comment #36
boaloysius commentedComment #37
mpdonadioThe conflict is from a test change in #2775669: Clean up redundant methods in datetime field formatters b/c changing the daterange formatters from #plain_text to #markup. DateRangeFieldTest is going to fail here, but this is to show clean change.
Comment #38
mpdonadioAnd here is that hunk removed.
Comment #40
dawehnerI always like additional test coverage.
Don't we loose some level of test coverage here?
Comment #41
mpdonadio#40, up in #24 @klausi said
I agree with this; and this is just the backport patch now. The followup that I need to make is to break up and refactor DateTimeFieldTest and DateRangeFieldTest into more manageable chunks, and see if we can refactor some of the common bits (one or two other issues will make this easier), and also split out some of these into KTB tests. When we do that, we can add some JSTB where needed.
Comment #42
lendudeYeah I think this is fine for the backport, we don't want the tests to get out of sync right?
@mpdonadio a follow up like that would be really great, date tests are hard enough without having to go through these massive files :)
Comment #43
alexpottThanks for working on the backport - and yeah out-of-sync tests are really tricky.
Committed 76a4428 and pushed to 8.3.x. Thanks!