Problem/Motivation

Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest

fail: [Other] Line 0 of sites/default/files/simpletest/phpunit-107.xml:
PHPUnit Test failed to complete; Error: PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

Testing Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest
F.S.                                                                4 / 4 (100%)

Time: 00:32.271, Memory: 4.00 MB

There was 1 failure:

1) Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections
Error: cannot call methods on dialog prior to initialization; attempted to call method 'widget'
    at Function.error (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/assets/vendor/jquery/jquery.min.js?v=3.6.3:2:2616)
    at HTMLDivElement. (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/assets/vendor/jquery.ui/ui/widget-min.js?v=10.1.0-dev:9:2224)
    at Function.each (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/assets/vendor/jquery/jquery.min.js?v=3.6.3:2:3003)
    at E.fn.init.each (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/assets/vendor/jquery/jquery.min.js?v=3.6.3:2:1481)
    at t.fn. [as dialog] (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/assets/vendor/jquery.ui/ui/widget-min.js?v=10.1.0-dev:9:1962)
    at Object.getContainer (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/misc/dialog/off-canvas/js/off-canvas.js?v=10.1.0-dev:302:23)
    at resetSize (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/misc/dialog/off-canvas/js/off-canvas.js?v=10.1.0-dev:207:42)
    at later (http://php-apache-jenkins-drupal8-core-regression-tests-79911/subdirectory/core/misc/debounce.js?v=10.1.0-dev:37:23)

/var/www/html/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php:133
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

https://www.drupal.org/pift-ci-job/2629306
https://www.drupal.org/pift-ci-job/2628845

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

quietone created an issue. See original summary.

nod_’s picture

Status: Active » Needs review
StatusFileSize
new12.55 KB
new504 bytes

Not sure yet why exactly but it seems to be a timing issue, attached patch should fix it.

spokje’s picture

Status: Needs review » Reviewed & tested by the community

The patch showing that LayoutBuilderUiTest has random fails is here: #2856047-65: Avoid random failures in JavascriptTestBase when testing functionality in a dialog.

No idea how this works, but core-3350972-2.patch shows that it _does_ work.

RTBC for me, core-3350972-2-full-suite.patch is the patch to commit.

  • lauriii committed 8ea9e1c3 on 10.1.x
    Issue #3350972 by nod_: [random test failure]...

  • lauriii committed 8d5f3cac on 10.0.x
    Issue #3350972 by nod_: [random test failure]...
lauriii’s picture

Title: [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections » [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections
Version: 10.1.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Fixed

I got some helpful context from @nod_ on Slack:

executing at the start of the debounce prevents the use of settimeout (for the first call anyway) so a line like $(window).on('myevent', debounce(func, 100, true)).trigger('myevent') will be added to the execution stack and executed in the order it's called. When the callback is executed in the settimeout that messes with the order of execution and I think that's what is causing issues in testing

I don't think it's only in testing, I don't use offcanvas often so I didn't run into it yet but it makes sense that it would happen from time to time for

It sound like this a bug that at least @larowlan had hit. @nod_ explained that this is expected behavior for Drupal.debounce, and that the problem is about the usage of it.

Committed 8ea9e1c and pushed to 10.1.x. Also backported to 10.0.x. Thanks!

nod_’s picture

  • xjm committed b32909a6 on 9.5.x authored by lauriii
    Issue #3350972 by nod_: [random test failure]...

  • xjm committed 6214a7f3 on 9.4.x authored by lauriii
    Issue #3350972 by nod_: [random test failure]...
xjm’s picture

I also backported this to 9.5.x and 9.4.x since it interferes with the security advisory development process.

xjm’s picture

Version: 10.0.x-dev » 9.4.x-dev

  • xjm committed aa4021c7 on 9.4.x
    Revert "Issue #3350972 by nod_: [random test failure]...

  • xjm committed f09c8346 on 9.5.x
    Revert "Issue #3350972 by nod_: [random test failure]...
xjm’s picture

Title: [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections » [Needs backport to 9.5.x and 9.4.x] [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections
Status: Fixed » Needs work

Whoopsidaisy, JS needs to be rebuilt for the D9 backports. Fail was: https://www.drupal.org/pift-ci-job/2639435

xjm’s picture

Title: [Needs backport to 9.5.x and 9.4.x] [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections » [Needs backport to 9.5.x and 9.4.x] [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections()
spokje’s picture

Status: Needs work » Needs review
StatusFileSize
new1.28 KB
xjm’s picture

Title: [Needs backport to 9.5.x and 9.4.x] [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections() » [random test failure] Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderUiTest::testReloadWithNoSections()
Priority: Normal » Critical

This is actually critical; updating metadata.

  • xjm committed e2d11b5f on 9.5.x
    Issue #3350972 by nod_, Spokje, xjm, quietone, lauriii: [random test...

  • xjm committed ff2d458e on 9.4.x
    Issue #3350972 by nod_, Spokje, xjm, quietone, lauriii: [random test...
xjm’s picture

Status: Needs review » Fixed

Also given the above criticality, I committed the backport straight from NR. Thanks @Spokje!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bwaindwain’s picture

I think this may have caused a bug with browser resizing. See https://www.drupal.org/project/drupal/issues/3359465