Problem/Motivation
The media library integration should have test coverage
Proposed resolution
Port existing tests.
Remaining tasks
- Port test coverage from
\Drupal\Tests\media_library\FunctionalJavascript\CKEditorIntegrationTest. #3232409: Media Embed button is broken already added a subset of this:\Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLibraryTestcopied a portion of it. But not all. We should expand it here:- #3232409 already ported
::testButton(). But incompletely. We should expand it in this issue. ::testAllowedMediaTypes()depends on more than just the filter settings: PHP code for CKEditor 5 must invoke the media library dialog correctly, using the filter settings (see\Drupal\ckeditor5\Plugin\CKEditor5Plugin\MediaLibrary::getDynamicPluginConfig()). This still should be ported in its entirety.::testConfigurationValidation()does not need to be ported.
- #3232409 already ported
- Port
\Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest
Issue fork ckeditor5-3206522
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 #2
zrpnrTagging for Contribution event
Comment #3
gábor hojtsyComment #4
wim leers→
\Drupal\Tests\media_library\FunctionalJavascript\CKEditorIntegrationTestComment #5
wim leersComment #6
effulgentsia commentedThere's also a
CKEditorIntegrationTestclass in the\Drupal\Tests\medianamespace and the\Drupal\Tests\ckeditornamesapce. Might want to copy/extend those as well unless you already have the equivalent test coverage handled some other way.Comment #7
wim leers#6++
Comment #8
wim leersUpdated remaining tasks. Fixed copy/paste error in issue summary.
#6:
\Drupal\Tests\ckeditor\FunctionalJavascript\CKEditorIntegrationTestcontains:::testOffCanvasStyles()→ CKE5 equivalent already exists at\Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5OffCanvasTest::testDrupalImageDialog()+::testDrupalImageCaptionDialog()→ irrelevant, since CKE5 is not usingEditorImageDialog::testFragmentLink()→ tested, verified this is not yet working. Opened new issue for this: #3238257: Fragment link pointing to <textarea> should be redirected to CKEditor 5 instance when CKEditor 5 replaced that textarea.Comment #10
wim leersThis test's
\Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::testPreviewUsesDefaultThemeAndIsClientCacheable()(and others) will fail, becauseSA-CORE-2021-006 by azinck, seanB, effulgentsia, marcoscano, larowlan, phenaproxima, xjm, mcdruid, drumm, briantschufrom September 15 introduced a new CSRF check that the CKEditor 5 module is not yet using.That makes this test coverage even more important!
Comment #12
wim leers🥳 Tests are running!
Comment #13
wim leersNot yet passing tests though, but getting there 👍
Comment #14
wim leersThe tests are currently failing because of what I wrote in #10 :) So all that still needs to happen here, is porting those same changes that were made to the CKEditor 4 media integration into our CKEditor 5 plugin. I provided @yash.rode with very specific pointers just now, I'm sure he'll be pushing new commits that make this MR green soon 🤓
Comment #15
wim leersComment #16
wim leersLooking good — if I
diffthis against\Drupal\Tests\media_library\FunctionalJavascript\CKEditorIntegrationTest, I can find virtually no differences; and all the ones that I do find are essential 👍Marking needs work again for the remaining work.
Comment #17
wim leersTo clarify: the remaining work here is to port the
\Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTesttest — so far it only covers\Drupal\Tests\media_library\FunctionalJavascript\CKEditorIntegrationTest.Comment #18
wim leersThis blocks #3231337: [drupalMedia] Remove manual dataDowncast from DrupalMediaEditing.
Comment #19
yash.rode commentedComment #20
wim leersYay, green! Reviewing 🥳
Comment #21
wim leersAFAICT the following test methods actually should be ported too:
\Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testErrorMessages()\Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testAlt()Both of those are implemented by the current
DrupalMediaCKE5 plugin. On it…Comment #22
wim leersFinished porting
::testErrorMessages(). A single assertion is blocked on another issue: #3194084-17: Support functionality equivalent to ckeditor_stylesheets.Comment #23
wim leersThe majority of
\Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testAlt()has now been ported. Found one significant behavioral difference, opened an issue for that: #3246365: [drupalMedia] Show the Image Media's default alt text that is being overridden.Two tiny changes to the JS logic were required: the user-entered
altshould always be trimmed, and when no value is provided, the attribute should be removed from the model. Trivial changes 😊Comment #24
wim leersSpent 45 minutes trying to fix #3246380: [drupalMedia] Media previews do not update after alt text was modified, but couldn't figure it out, hence created that issue. Now
::testAlt()is complete.Comment #25
wim leers#3245720: [drupalMedia] Support choosing a view mode for <drupal-media> was too simplistic. Therefore, opened #3246385: [drupalMedia] Support captions on <drupal-media>, which should bring a better UX for 99% of scenarios.
Comment #26
wim leersComment #28
wim leers