Problem/Motivation
Spinning off from #3227033: Remove Quick Edit from core. There are a handful of places where we're currently leaning on quickedit data attributes as selectors for various test assertions in places that have nothing to do with testing quick edit functionality.
The main culprit are tests of stable / stable9, where there are no classes to target something specific. For example:
core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.php
It's trying to do this in assertNodeHtml()
:
$assert->elementTextContains('css', $created_selector, \Drupal::service('date.formatter')->format($node->getCreatedTime()));
So we need a selector to find exactly where the timestamp is appearing. But without quickedit enabled, the markup for this node in stable and stable9 looks something like this:
<article role="article" about="/drupal-9_1/node/1">
<footer>
<article typeof="schema:Person" about="/drupal-9_1/user/2">
<div class="js-form-item form-item js-form-type-item form-item- js-form-item- form-no-label">
<h4 class="label">Member for</h4> 24 seconds
</div>
</article>
<div>
Submitted by <span><a title="View user profile." href="/drupal-9_1/user/2" lang="" about="/drupal-9_1/user/2" typeof="schema:Person" property="schema:name" datatype="">eMHCSGYOuJAkD2</a></span>
on <span>Fri, 08/06/2021 - 11:09</span>
</div>
</footer>
<div>
<div><p>vJUMtKdL7e4hG5MdElsfGh0ucpCuPhDY</p>
</div>
</div>
</article>
I'm not sure how we're supposed to find this needle: <span>Fri, 08/06/2021 - 11:09</span>
in that haystack, without any classes or anything to distinguish it from every other <span>
.
Proposed resolution
Make test assertions less specific when testing themes without field classes.
The following tests need help:
core/modules/node/tests/src/Functional/NodeDisplayConfigurableTest.phpWorks for all core themes that provide field classes.Needs a solution for stable + stable9
- core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
- core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
Remaining tasks
- Come up with a solution.
- Implement it.
- Confirm tests are all still passing.
- Reviews / refinements.
- RTBC.
- Commit.
- Unblock parent and friends.
User interface changes
n/a
API changes
n/a
Data model changes
n/a
Release notes snippet
n/a
Comment | File | Size | Author |
---|---|---|---|
#3 | 3227161-2.data-quickedit-todo.txt | 1.93 KB | dww |
Issue fork drupal-3227161
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
dwwCherry picked the proof-of-concept commit about NodeDisplayConfigurableTest from the parent issue into this issue's fork. Still @todo to get that test working again for stable + stable9.
Also grabbed the commit about MediaEmbedFilterDisabledIntegrationsTest. Still @todo: that test is now a Kernel test with a data provider that only provides a single case. Refactor?
Grep says these are the only places we reference 'data-quickedit' in any tests that are neither provided by quickedit module itself, nor explicit tests for quickedit integration (e.g. core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderQuickEditTest.php):
grep output attached for reference.
This is actually a smaller set of tests to deal with than I first feared. ;)
Comment #4
BerdirMediaEmbedFilterDisabledIntegrationsTest I think is actually an integration test with quickedit. But it is testing code in quickedit_entity_view_alter(), so maybe we can just move that test into the quickedit module to make it easier to move into contrib.
Comment #5
xjmPosted #3228634: Move tests for integrations between QuickEdit and other modules into QuickEdit so that it can more easily be moved into contrib to better address @Berdir's feedback.
Comment #6
xjmComment #7
xjmAlso updated the IS to remove the Media test from the scope.
Comment #8
xjmSorry for the noise; cherry-picked something from a related issue to the wrong branch.
Comment #9
paulocsI did not find any solution for it as well. What is a possible solution?
Comment #10
xjmComment #11
dwwHere's a solution that at least gets the tests passing locally:
Not sure that's going to fly, but it's the best I could come up with that maintains as much test coverage as possible.
If @xjm is cool with that, we can turn our attention elsewhere.
I did a quick skim of core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTray*. Those look more like actual tests of Quick edit, and are maybe more appropriately moved over to the scope of #3228634: Move tests for integrations between QuickEdit and other modules into QuickEdit so that it can more easily be moved into contrib instead of trying to deal with them here?
Comment #12
xjmThis needs merge conflicts resolved -- auto-rebasing through the UI failed.
Comment #14
longwaveRebased and force pushed; deleted the commits that were later reverted.
Comment #15
Wim LeersReview posted. It makes sense that the two fields whose values cannot be precisely asserted anymore are the
name
andcreated
base fields — back in 2012 when I was working on Quick Edit that were precisely the two I was unable to reliably target across themes as well, precisely because they were rendered in non-standard ways. 9 years later, that's still the case 🤓+1
… But … #3228634: Move tests for integrations between QuickEdit and other modules into QuickEdit so that it can more easily be moved into contrib has since then been committed and did not do that. That's wrong, because:
\Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testEditModeEnableDisable()
even has it in its method name: its literally testing Quick Edit's "edit mode".\Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testBlocks()
cals::doTestBlocks()
which does:\Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest::testValidationMessages()
does$this->enableEditMode();
Comment #16
Berdir> that were precisely the two I was unable to reliably target across themes as well, precisely because they were rendered in non-standard ways. 9 years later, that's still the case
FWIW, this is actually a "new" problem, as we aggressively removed all classes from most markup in the minimalist themes in Drupal 8. So that's kind of by design and a feature(?).
This is off topic of course, but I'm wondering if that's really still a thing that enough people care about? I feel like a a lot of people that want that level of control moved to decoupled and other approaches, and there could still be a contrib theme like that. As mentioned, the whole thing always felt very strange to me, someone who doesn't want default classes will also not want double-divs on single-value fields with no class, imho that's even less desired than divs with default classes, but maybe that's just me. Anyway, might be worth to revisit that topic?
Comment #18
Wim LeersVery interesting question! 🤔
I think it's to empower the Site Builder persona?
@lauriii & @dww: thanks, that addressed all of my concerns! :)
I'd RTBC, but the last 3 bullets of #15 are not yet addressed. I'm fine with moving that to a follow-up too.
Comment #19
lauriii#15 seems scope creep given that this issue was opened specifically to handle Quick Edit data attributes used in arbitrary tests. Maybe we need a follow-up for #3228634: Move tests for integrations between QuickEdit and other modules into QuickEdit so that it can more easily be moved into contrib?
Comment #20
Wim Leers+1
Comment #21
Wim Leers(RTBC as soon as the follow-up exists.)
Comment #22
paulocsHere is a follow-up issue: #3238626: [Follow-up] Move tests for integrations between QuickEdit and other modules into QuickEdit
Comment #23
paulocsMoving to RTBC per #21
Comment #25
catchCommitted f93d9a3 and pushed to 9.3.x. Thanks!