[random test failure] Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews random fail

Created on 25 October 2022, over 1 year ago
Updated 19 June 2023, about 1 year ago

Problem/Motivation

Testing Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest
F                                                                   1 / 1 (100%)

Time: 01:57.676, Memory: 4.00 MB

There was 1 failure:

1) Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews
"Loading grid view." not found
Failed asserting that a boolean is not empty.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:121
/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php:55
/var/www/html/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php:65
/var/www/html/core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php:409
/var/www/html/core/modules/media_library/tests/src/FunctionalJavascript/WidgetViewsTest.php:118
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:726

https://www.drupal.org/pift-ci-job/2507467

1) Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews
WebDriver\Exception\CurlExec: Curl error thrown for http POST to http://chromedriver-jenkins-drupal-patches-187886:9515/session/73f6b5d5a73c8b7035b4362195d8782f/element/0.27412969624553574-76/click

Retries: 10 and last result:
{"sessionId":"73f6b5d5a73c8b7035b4362195d8782f","status":10,"value":{"message":"stale element reference: element is not attached to the page document\n  (Session info: headless chrome=106.0.5249.103)\n  (Driver info: chromedriver=106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}),platform=Linux 4.9.0-0.bpo.6-amd64 x86_64)"}}

/var/www/html/vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:198
/var/www/html/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php:146
/var/www/html/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:125
/var/www/html/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:234
/var/www/html/vendor/instaclick/php-webdriver/lib/WebDriver/Container.php:241
/var/www/html/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:805
/var/www/html/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:729
/var/www/html/vendor/behat/mink/src/Element/NodeElement.php:185
/var/www/html/vendor/behat/mink/src/Element/TraversableElement.php:210
/var/www/html/core/modules/media_library/tests/src/FunctionalJavascript/WidgetViewsTest.php:123
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

Steps to reproduce

In another issue, far, far away, I reproduced the first error and took screenshots when the assertion fails. That looks like this:

So the assertion is done whilst the AJAX request hasn't finished yet.

The second failure can only happen for two reasons:
1. The element under test is removed from the DOM.
2. The page changed whilst after getting the element under test.

In this patch 📌 [Ignore] In space (and/or this issue), no one can hear patches scream VI Closed: outdated I took screenshots if there's a CurlExec is thrown. Those look like this:

The select for Dog is still present, which leaves us with only option 2.

Upon closer inspection, the page actually does get (AJAX-)reloaded with the $page->pressButton('Apply filters'); just above our random failure point.

Proposed resolution

Add a $this->assertSession()->assertWaitOnAjaxRequest(); before both problematic code lines to make sure we're testing the page we're expecting to test.

For the second failure, we can now also change the waitFor(No)Text with pageText(Not)Contains, since the waiting is now, more reliable done with the assertWaitOnAjaxRequest()

Since both random failures are related in their cause and #5 🐛 [random test failure] Drupal\Tests\media_library\FunctionalJavascript\WidgetViewsTest::testWidgetViews random fail Fixed proves they are both occuring with our (gazillion) test runs, I believe we can fix and test their "fixed-ness" in one go.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.1

Component
Media 

Last updated about 15 hours ago

Created by

🇧🇪Belgium Wim Leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
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.69.0 2024