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.
Problem/Motivation
#3066447-53: [random test failure] Random failures building media library form after uploading image (WidgetUploadTest) points out that there's a random fail on \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::testEditorFileReferenceIntegration
with PostgreSQL. However, that test is failing on my local environment with PostgreSQL consistently.
Proposed resolution
Fix it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#7 | 3250587-7.patch | 1.1 KB | lauriii |
#7 | 3250587-7-30x.patch | 2.83 KB | lauriii |
#3 | 3250587-2-fix-only.patch | 981 bytes | lauriii |
#2 | 3250587-2-30x.patch | 2.69 KB | lauriii |
Comments
Comment #2
lauriiiComment #3
lauriiiHere's patch from #2 without the
drupalci.yml
changes.Comment #4
Wim LeersFascinating!
So your theory is … that the file upload did not properly finish? 🤔
Comment #5
lauriii#4 that's right.
We should probably remove this since the image upload is not a Drupal Ajax request meaning that this doesn't do what we expect it to do.
Comment #6
mondrakeBumping to critical, this is rather consistently failing on 9.4.x HEAD for Postgres
Comment #7
lauriiiThis implements the change I proposed in #5.
Comment #8
bnjmnmThis is a pretty unambiguous improvement. The test had been calling
$assert_session->assertWaitOnAjaxRequest();
to wait for the completion of the image upload/render before advancing. However, that process is not handled by an AJAX request.assertWaitOnAjaxRequest()
introduces a brief wait, long enough to be sufficient for tests to sometimes pass, particularly in faster environments. It's not surprising that this use of$assert_session->assertWaitOnAjaxRequest();
is causing intermittent failures.By changing this to
$this->assertNotEmpty($assert_session->waitForElement('css', '.ck-content img[data-entity-uuid]'));
, the test is actually waiting for the upload/render to complete before advancing. Waiting for an element to appear/disappear is preferable toassertWaitOnAjaxRequest();
even in situations where Ajax requests are being used, so this is a welcome change, and one I'm glad @lauriii spotted.Comment #9
Wim Leers+1000!
Wow.
What a find.
Image uploads in CKEditor 5 are handled slightly differently than in CKEditor 4; they're uploaded by the CKEditor 5 plugin itself, not via a clunky Drupal-owned, AJAX-powered
EditorImageDialog
. That's whyassertWaitOnAjaxRequest()
is not sufficient in this case. It went unnoticed all this time just because only PostgreSQL tests happen to be slower… 🤯Epic find, @lauriii!
Agreed with RTBC.
Comment #12
catchCommitted/pushed to 9.4.x and cherry-picked to 9.3.x, thanks!
Comment #14
Grevil CreditAttribution: Grevil at DROWL.de commentedHey guys, I know this issue is closed, but I just stumbled upon it and was wondering how it is possible to run "waitForElement()" on $assert_session?
$assert_session is initialized with,
$assert_session = $this->assertSession();
and "$this->assertSession()" will return a "\Drupal\Tests\WebAssert" Object.But in https://api.drupal.org/api/drupal/core%21tests%21Drupal%21Tests%21WebAss..., there is not a single note about "waitForElement()". Am I missing something? Or is it just not documented yet?