See #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase).
Convert all remaining WebTestBase tests to PHPUnit tests, except #2809501: Convert AJAX part of \Drupal\field_ui\Tests\ManageDisplayTest to JavascriptTestBase
Deprecate WebTestBase FieldUiTestTrait in favour of a new PHPUnit version of the same trait.
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | 2794347-37.patch | 10.14 KB | lendude |
Comments
Comment #2
jmuzz commentedThis depends on the patch from #2784537: Add legacy assertFieldByXPath()/assertNoFieldByXPath() method for browser tests but gets most of the way there. One of the test files still isn't passing. The error looks like:
I'm not sure why that field is supposed to be blank after its saved.
Comment #3
jmuzz commentedThey talk a bit about why this particular test got changed around #49 in #2136197: Move field/instance/widget/formatter settings out of annotation / plugin definition.
It has something to do with the settings for one formatter leaking into the settings of another. It looks to me like it's checking the same formatter it configures though.
Comment #4
jmuzz commentedMaybe somebody else can explain those tests better but for now I am going with they got inverted due to mistaken assumptions and I'm inverting them back in this patch.
There is also another one where it was testing for the existence of a setting button after the module providing the settings is uninstalled. I don't think the button is supposed to appear in that case.
These tests are passing for me but they still depend on #2784537: Add legacy assertFieldByXPath()/assertNoFieldByXPath() method for browser tests so I'm setting to postponed.
Comment #5
jmuzz commentedComment #7
klausiThis is ready again to be worked on.
Comment #8
jofitzRe-rolled.
Comment #10
jofitzNo longer applies.
Comment #11
jofitzRe-rolled.
I expect this to fail some tests because it seems BrowserTestBase cannot handle hidden and image input elements, e.g.
EDIT: connected comment to test error.
Comment #13
jofitzThis fixes a few failures, but the bug about BrowserTestBase failing to handle hidden and image input elements still remains.
Comment #15
nuezComment #16
nuezThere are a couple of (recurrent) issues in the tests, which my latest patch tries to resolve based on Jo Fitzgeralds' patch.
1. Simpletests asserts non-visible, javascript based, input fields
The Field UI adds a
input[type=”hidden”]field for refreshing fields that might have been changed.It also adds a hidden submit button with label ‘Refresh’, that is clicked through javascript (field_ui.js)
In several cases the clicking of the hidden ‘refresh’ button is asserted by the legacy test. When clicking the 'Refresh' button, values are passed to the hidden
refresh_fieldsfields.The test fails because Mink doesn’t allow clicking of hidden buttons: the FieldExists() method returns FALSE, because for Mink, input[type="hidden"] is not an existing field.
On the other hand, the functionality that is tested concerns a 100% JS test case. The BrowserTestBase is about testing non JS, visual user interaction, so IMO the only solution is to remove these specific assertions of the test.
About the refresh_rows and the refresh button in EntityDisplayFormBase.php:224
In overviews involving nested rows from contributed modules (i.e field_group), the 'plugin type' selects can trigger a series of changes in child rows. The #ajax behavior is therefore not attached directly to the selects, but triggered by the client-side script through a hidden #ajax 'Refresh' button.
2. The ::assertFieldByID method fails asserting ‘buttons’.
There is a patch for that. I’ve included the patch in this path to make the tests work.
https://www.drupal.org/node/2862947
3. FieldDefinitionInterFace::getDefaultLiteral() returns an array().
ManageFieldTests::testDefaultValue() asserts that the getDefaultsLiteral() should return NULL (no default configuration). According to the interface it always returns an array. If there is no default value, the array is empty.
4. testLockedField() assumes that xpath() returns an array, but it returns an array of NodeElement when using Mink.
Therefore the the assertion has to be changed to use the NodeElement that the xpath() method returns and check it for the presence of the ‘Locked’ string.
Comment #17
nuezMy patch included some comments, and differences in 8.4.x that I hadn't pulled.
These ones are clean:
- One including patch of https://www.drupal.org/node/2862947 - which should pass.
- One excluding patch of https://www.drupal.org/node/2862947 - which will not pass.
Comment #18
jofitz@nuez it is really helpful if you also add interdiffs with your patches - it makes them much easier to review.
Comment #21
nuezThanks for the tip @Jo Fitzgerald. Interdiff added.
There was still a failing test.
In testFormatterUI() there is an ajax interaction involving clicking the hidden 'refresh' button that I just simply removed. I'll try and revise this tomorrow, because I don't think it's the right solution.
For now I think the test passes when applying with the 2862947-8.patch.
Comment #22
jofitz@nuez++ for the interdiff :D
Keep an eye out for using the short array syntax: [] instead of array().
Assuming this passes the tests then it's probably worth postponing it until #2862947: Incorrect field assertions in AssertLegacyTrait has been accepted into core (it's not the only ticket waiting on that).
Comment #24
klausiinstead of reset() you could use $main_content[0].
instead of assertTrue() you should use assertContains() for checking strings.
the (string) cast can now be removed.
why do we need to change this? shouldn't this just work? Something missing in assertFieldByName()
remove (string) cast.
getRawContent() exists now, so this change should be removed.
assertContains()
should be \Behat\Mink\Element\NodeElement[] as type
remove (string)
same here, remove (string). Also elsewhere.
use short array syntax
@var docs should be fully qualified namespaces.
use assertSame() instead.
looks like you forgot to move the file?
Postponing on #2862947: Incorrect field assertions in AssertLegacyTrait
Comment #25
boaloysius commentedSolved 1,2,4,5,6,8,9,10,12
Comment #26
nuez3. assertFieldByName() calles FieldExists() on a input[type="image"] button (the wee cog), which is not recognised by Mink. That's why I converted it to an xpath assertion. Should we change assertFieldByName() instead?
7. I've changed the argument docs from
arrayto\Behat\Mink\Element\NodeElement[]. PHP doesn't support strongly typed arrays of objects as arguments so that will have to remain array.11. Done.
13. The FieldUiTestTrait trait is used by many other modules so I've left and deprecated the old trait. Field UI already uses the new trait, but other modules continue using the old trait.
Comment #27
boaloysius commentedComment #28
michielnugter commentedPostponed on: #2809501: Convert AJAX part of \Drupal\field_ui\Tests\ManageDisplayTest to JavascriptTestBase.
Comment #29
michielnugter commentedComment #33
mile23There are currently only a few tests left, and only
ManageDisplayTestneeds the functional javascript treatment.So I'd un-postpone here so we could convert the other ones and, more importantly, move
FieldUiTestTraitto field_ui/tests/src/Traits/. However:ManageFieldsTestusesDrupal\field\Tests\EntityReference\EntityReferenceTestTraitwhich we should move out of simpletest-land.So it's fair to say we're now postponed on #2996789: Deprecate Drupal\field\Tests\EntityReference\EntityReferenceTestTrait
Comment #34
lendudeblocker has landed.
Comment #35
lendudeThis does it for the remaining tests, except ManageDisplayTest for which we have a follow up #2809501: Convert AJAX part of \Drupal\field_ui\Tests\ManageDisplayTest to JavascriptTestBase
Deprecated the old trait and added a CR for that and removed usage in PHPUnit test using it, left it in tests still using WebTestBase.
No interdiff because too much has changed since the last patch. I've tried to reuse as much as possible for earlier patch but a lot has changed, so much I just redid.
Comment #37
lendudeMissed one.
edit: interdiff is a bit weird, showing stuff that isn't true
Comment #38
jibranWhat about these asserts?
Comment #39
lendude@jibran, well spotted, I knew I should have put that in a comment here :-)
With the rewrite we now check the full HTML of that xpath (they all use the same xpath query), so if this is true the others must be false.
negative assertions--
So, I think, they serve no purpose, so they can just go.
Comment #40
jibranThanks, for explaining it.
Comment #41
alexpott@jibran thanks for asking that - I was wondering the same.
Committed 982c174 and pushed to 8.7.x. Thanks!
Committed 58746b5 and pushed to 8.6.x. Thanks! Backported without the deprecation of FieldUiTestTrait to keep the tests in-sync between the branches.
After recent discussions only doing deprecations in the next minor for the time being.
Comment #45
quietone commentedpublish the change record