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.
Write tests to ensure that embed buttons are properly added to the CKEditor configuration toolbar and that it can be enabled/disabled by the user.
- Ensure that the correct tag/attributes are added to the allowed HTML configuration when someone adds the button (covers #2554687: <drupal-entity> tag not being automatically added when an Entity Embed button is added to active editor toolbar)
- Ensure that the CKEditor plugin can be used to insert and edit entity embeds, as well as correctly previewing the embedded entity.
Comment | File | Size | Author |
---|---|---|---|
#33 | 2466013-33.patch | 9.26 KB | Wim Leers |
| |||
#33 | interdiff.txt | 2.83 KB | Wim Leers |
#32 | 2466013-32.patch | 8.58 KB | Wim Leers |
| |||
#32 | interdiff.txt | 2.61 KB | Wim Leers |
#31 | entity-embed-integration-test-2466013-31.patch | 7.93 KB | oknate |
|
Comments
Comment #1
slashrsm CreditAttribution: slashrsm commentedComment #2
slashrsm CreditAttribution: slashrsm commentedComment #3
Dave ReidComment #4
Dave ReidComment #5
Wim LeersSimilar to #2560787-3: Add tests for entity access.
Comment #6
Wim Leers#2328659: Convert all existing entity_embed tests from WebTestBase to BrowserTestBase landed, unblocking this!
Comment #7
oknateHere's an initial test.
Comment #8
oknateRemoving test code "createScreenshot".
Comment #9
oknateNote: I had to add some extra code because of a bug in #2752253: Document correct filter_html_image_secure + filter_align + filter_caption + entity_embed filters order, write tests, and ensure correct by default. Once that issue is resolved, I can update the test.
Comment #10
oknateCoding standard fix (makes comment multiline).
Comment #11
oknateComment #12
oknate- Needs to cover "Ensure that the correct tag/attributes are added to the allowed HTML configuration when someone adds the button"
Comment #13
oknateAdding check that allowed formats are automatically updated in the filter format.
Comment #14
oknateComment #15
oknateIn testing ImageFieldFormatter, I noticed that it requires "alt" and "title" attributes on the drupal-entity in order to function properly.
See: #3022768: Validate that `alt` and `title` are required attributes for `<drupal-entity>`, and ensure they're added by default.
I added a fix and a test class that adds functional test coverage. I would say that it's more test coverage for CKEditor integration, so it would be good to add that too.
I also noticed that there's some javascript testing that I missed in #13. When the user drags and drops the button into the toolbar it automatically updates the allowed_html via javascript. I didn't add test coverage for that, but rather after the form was saved. It would be easy to add.
So I'll mark this back as Needs Work.
Comment #16
oknateComment #17
oknate- adds assertion before drop and drag that allowed_html doesn't have drupal-entity, and after drop and drag it does.
Comment #18
oknateHmm, not sure why that failed. It passed on my local drupalci_testbot. Here's a slightly reorganized version.
Comment #19
oknateThe order the attributes just needed to be reconfigured.
Comment #20
oknateComment #21
oknateChanging $button to $this->button, which allows referencing it later. This will be useful because I plan to copy this test to test other usages.
Comment #22
Wim LeersO M G
EPIC progress here, thanks so much @oknate! 🥳🥳🙏
Comment #23
Wim Leers#9 has been fixed in that other issue, so this patch can become slightly simpler again :)
Comment #24
Wim LeersFix nits.
Comment #25
Wim LeersThis is testing that a "Entity Embed" button in the text editor can insert an embedded entity into the text editor. (And that it is rendered when viewed.)
What this is not yet testing is that it's possible to edit an already existing
<drupal-entity>
in the content.So adding something like
would finish this.
Would you like to take his on? :)
Comment #26
Wim Leers#25 is just to to have complete functional testing, but don't get me wrong: I'm super grateful for how far you've already pushed this! 🙏🙏🙏 Excellent work, extremely valuable contributions! 🤩
Comment #27
oknateSure I can work on this. Thanks for the review!
Comment #28
Wim LeersLOVELY! Are you going to any Drupal events in the coming months? I totally owe you Belgian beer and chocolates for this :D
Comment #29
oknateI don't have immediately plans. I'll let you know. Belgian beer and chocolates sounds great! If you're ever in New York, you can come visit me in the World Trade Center. It's a nice view.
Comment #30
Wim LeersOh wow! My wife and I may be coming to visit NYC this summer, then we'll bring Belgian beer & chocolates and take you up on your offer! :D
Comment #31
oknateThat would be lovely, DM me when you know your plans.
Here's an updated patch that replaces the embed, per #25.
Comment #32
Wim LeersGREAT work, thanks so much @oknate!
😆
Nit: this format does not exist. Fixed.
There's no need for switching back if we didn't switch to something else first.
This isn't quite testing what it seems to be testing; this was just waiting for the max timeout.
That's because this is not switching to the CKEditor iframe, and it's only in that iframe that this text is supposed to appear.
Fixed.
Comment #33
Wim LeersThis addresses #32.3, adds a few additional comments to clarify what's being tested and adds matching before/after assertions to make the existing assertions more trustworthy and hence more valuable.
Comment #34
Wim LeersStill green — YAY — let's do this! This will certainly help ensure that #2544020: CKEditor plugin not written with CKEditor >=4.4 in mind; rewrite it based on core's `drupalimage` plugin does not introduce regressions! 🥳
Comment #35
Wim LeersUpdating IS, assigning appropriate attribution.
Comment #36
Wim LeersComment #38
Wim LeersUGH I just noticed that this was attributed to me instead of @oknate because I uploaded the last patch. d.o's default attribution algorithm often trips me up that way :( Very sorry, @oknate :/ Because you definitely are the primary author of this patch!
To compensate, I'll attribute you instead of myself on the next thing I actually am the primary author of.
Comment #39
oknateNo problem, thanks for getting it in! I would like to add test coverage for media to this test, since that's what we're looking to move into core. I'll look into that. Maybe a separate issue: Add test coverage for media embed.
Comment #40
Wim LeersIf you're willing to do that, that'd be lovely! 🙏😃
That would also help #2998005: [PP-1] Support Drupal core's Media Library go faster 💪