[random test failure] MediaTest::testLinkManualDecorator()

Created on 10 January 2023, about 2 years ago
Updated 13 June 2023, over 1 year ago

Problem/Motivation

Random, inconsistent errors in the ckeditor5 FunctionalJavascript tests.

Testing Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest
..............E........                                           23 / 23 (100%)

Time: 07:06.351, Memory: 6.00 MB

There was 1 error:

1) Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::testLinkManualDecorator with data set "unrestricted" (true)
Behat\Mink\Exception\ElementNotFoundException: Element matching css ".ck-balloon-panel_visible .ck-balloon-rotator__content > .ck.ck-link-actions" not found.

in https://www.drupal.org/pift-ci-job/2564452

10 Jan 2023 https://www.drupal.org/pift-ci-job/2564081
27 Mar 2023 https://www.drupal.org/pift-ci-job/2626370

Steps to reproduce

In a patch in another issue I took screenshots just before the "balloon assertion" at line 1073.
Here's what a screenshot from a passing test looks like:

In another patch I took screenshots at the same spot for failing tests.
That looks like this:

Upon close inspection we see the differences:
The failing one has a different "balloon" (which is why the test fails) and an URL in the textfield below the actual media.
That textfield is actually the caption edit field, and seems to be default on in this test.

The test selects the media to be able to edit it by doing a

    $this->assertNotEmpty($drupalmedia = $assert_session->waitForElementVisible('css', '.ck-content .ck-widget.drupal-media'));
    $drupalmedia->click();

and seeing that '.ck-content .ck-widget.drupal-media' is the whole area surrounded by the blue border in the first image , there's a chance we click on the caption edit area.
When we do that the behaviour of the link-adding changes and doesn't follow the assertions in the test any more.

Proposed resolution

Toggle the Caption edit capability off, so we're sure we never add a link in there, instead of the wanted link on the media.

Remaining tasks

There are still 2 random test failures left that seem to stem from the inner bowels of CKEditor 5. To me they look like an upstream issue, but since I can't really pinpoint the root cause of those and seeing the fact that this patch drops the failure rate from about 10 in 1500 down to 6 in 45.000, I take that as a win.

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

9.5

Component
CKEditor 5 

Last updated 1 day ago

Created by

🇺🇸United States jastraat

Live updates comments and jobs are added and updated live.
  • JavaScript

    Affects the content, performance, or handling of Javascript.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024