With #2544020: CKEditor plugin not written with CKEditor >=4.4 in mind; rewrite it based on core's `drupalimage` plugin, #2282957: Caption should work like the drupalimage plugin (editable in WYSIWYG, not in dialog) and #2511404: Image entities/fields embedded using Entity Embed cannot be linked in CKEditor landing, we're stabilizing the CKEditor Widget. We already have some test coverage for it thanks to #2466013: Write test for CKEditor integration, but while stabilizing it, I discovered additional edge cases that warrant test coverage but did not warrant blocking an RC release since they're solid improvements already.
Furthermore, by taking a high-level overview of the different testing needs (edge case scenarios), I think we can test this more effectively.
This issue is for adding that test coverage.
Known edge cases to test:
- 👍 Triggering "Source" button does not trigger a
blurevent on thecaptioneditable, which results in the source being inaccurate. Theblurevent should be triggered. - 👍 Bold, italics etc work in the
captioneditable *and* are properly HTML-encoded. - 👍 Inserting a link in the
captioneditable fails in thedrupallinkplugin on this line:var range = selection.getRanges(1)[0]; - 👍 Bold, italics etc work in the caption editable *and* are properly HTML-encoded *and* are displayed properly in the
EntityEmbedDialog*but* upon saving that dialog they're escaped. - 👍 Not specifying a caption in
EntityEmbedDialogcauses nodata-captionvalue to be sent to the client; the client should not fail, and automatically update the preview to be captionless. <drupal-entity>tags without adata-embed-buttonattribute should be upcast but not be editable, and same for those with that same attribute whose value is not one of the currently enabled text editor buttons (or perhaps even a nonsensical one). Only the remaining ones should trigger theEntityEmbedDialog.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3060396-14.patch | 22.76 KB | wim leers |
| #14 | interdiff.txt | 1.53 KB | wim leers |
| #13 | 3060396-13.patch | 23.32 KB | wim leers |
| #13 | interdiff.txt | 15.5 KB | wim leers |
| #12 | entity-embed-3060396-12.patch | 22.09 KB | oknate |
Comments
Comment #2
oknateHere's a start for the test for the caption being editable in the wysiwyg. It validates the basic functionality, but not the edge cases in this issue yet.
Comment #3
wim leersBased on #2544020-38: CKEditor plugin not written with CKEditor >=4.4 in mind; rewrite it based on core's `drupalimage` plugin: #2544018: Manual embed should not get an option to Edit Entity does something somewhat unexpected, and merits explicit test coverage.
Comment #4
wim leers#2: DUDE THAT WAS SO FAST WHAT THE HELL!? 😀
Comment #5
oknateLol, I started working on it when I saw the original issue (#2282957) was ready for tests when I got up this morning. I can work on it more this evening, or if you want to move it along, that's cool too.
Comment #6
wim leersNo, I'll be traveling to https://cluj2019.drupaldays.org tomorrow to sprint on Media (which includes integrating Entity Embed with Media Library and generating core patches), I'll be spending tonight with my wife, she'll have to miss me all week (including this long weekend — Monday is a national holiday in Belgium). So if you'd like to continue, that'd be superb 🥳
Comment #7
oknateAdding coverage for edge cases in the issue summary, except for this:
I'm not sure what the issue is there, nor how to test it. And I don't really see a problem. The source seems accurate. I need some clarification on what the issue to test is there.
Comment #9
oknateI can't recreate the error on testbot in #7. I don't see that error locally. I changed that part of the code slightly to see if I can circumvent the issue.
Also adding some coding standard fixes.
Comment #11
oknateStill the same failure in #9 as #7. I suspect the double click is not working properly on headless chrome. Testing version without double clicks. Although after I posted this, I figured out how to run it locally headless and tested #7, and I didn't get the error.
Comment #12
oknateI realized that one bit of js wasn't executing as I failed to actually execute it. When I updated it to run, I was getting an ajax error. Here's the code in question:
I had left off the execution line.
I've tried various ways of testing whether the widget is editable. There's a function added in the anonymous function isEditableEntityWidget(), so I could possibly check that in the test if it’s exposed outside the anonymous function. But I think it's better to actually run the code rather than just test the attributes.
I propose that the editdrupalentity command above should run without error, whether there is a drupal-embed-button attribute or not.
This also would fix an edge case where the command is run instead of prevented to run.
To get this to work, I added some code to the editdrupalentity command borrowed from isEditableEntityWidget():
I tried to actually have it run isEditableEntityWidget() there, but I couldn't get it to work I was getting the following error:
But it worked with the above condition. This allows the code to tests if, when the data-embed-button attribute is missing, it doesn't try to launch a dialog.
I also added another helper function for readability.
Comment #13
wim leersThat was fixed prior to commit, hence you can't reproduce it anymore :) It was a bug in an earlier iteration. So don't worry — that actually makes sense!
#12:
Making it a no-op can work. But why do we even need it? Why are we even triggering those embeds without that attribute? I think this is just an artifact of us not being able to double-click the widget due to test infrastructure (webdriver) limitations. We shouldn't be modifying our code just to work around test infra limitations.
Because that function is not exposed in the global scope. :)
My primary concern is that this is one super long test method testing all the things. I think it'd be better to split it up into different areas that we're exercising expectations against:
the widget's caption's editability
linkability of the overall widget
the upcasting of the widget working always, even if no appropriate button is specified
That's going to make this test much more valuable, because a failing test will now tell us in which area there is a problem.
Comment #14
wim leersOne more thing that doesn't belong here, because that's why we have #3060439: Caption fails to render when adding back to captionless embed when edited via EntityEmbedDialog.
Comment #15
wim leersComment #17
wim leers🚢
Comment #18
oknateThat was fast, too! Thanks.
IRT:
Exactly. Double clicking was working locally and it was much nicer. I think my solution doesn't hurt anything, and it works. If you can come up with a more elegant way to simulate either double clicking or triggering the context menu, I'm all ears (or eyes, to improve upon the cliché).
It would be especially cool to see the context menu open in the tests and verify the custom text per button displays.
Comment #19
oknateNice job breaking it up. Thanks! I was thinking you might recommend that.
Comment #20
wim leers😀
Comment #21
wim leersComment #22
rosinegrean commented