Problem/Motivation

When assertWaitOnAjaxRequest() fails, it uses \RuntimeException which immediately halts the test and bypasses things like tearDown().

Discovered at #3218985-20: CKEditor 5 admin UI's AJAX logic and form alterations are too complex and brittle and #3218985-21: CKEditor 5 admin UI's AJAX logic and form alterations are too complex and brittle:

What's weird is that \Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5TestBase::tearDown() which was added in #3228355: PHP warning when saving text format with CKE5: $form_state->getTriggeringElement() unexpectedly returning NULL should be causing this to be visible, but it's … just not. It seems that the tearDown() is perhaps not being called in the case of Functional JS tests failing early? Yet ::tearDown() is supposed to be called always I could decorate $assert_session->assertWaitOnAjaxRequest(); in CKE5 tests just so we get better error response checking… using the same technique as I added in \Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::getLastPreviewRequestTransferSize().

+

Actually … I think I figured out why:

00:06:37.487 FATAL Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test: test runner returned a non-zero error code (2).

This is because \Drupal\FunctionalJavascriptTests\JSWebAssert::assertWaitOnAjaxRequest() triggers a \RuntimeException that the test runner won't handle. So it instantly aborts the test, without running ::tearDown()!

While the plan is to remove assertWaitOnAjaxRequest, in the meantime this fix will stop preventing issues like #3228956: PHP notices are not detected for headless browser-triggered requests in FunctionalJavascript tests from progressing.

Steps to reproduce

TBD

Proposed resolution

Replace \RuntimeException with Behat\Mink\Exception\ExpectationException

Remaining tasks

Write tests

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

Issue fork drupal-3230726

Command icon 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

tim.plunkett created an issue. See original summary.

larowlan’s picture

Status: Active » Reviewed & tested by the community

Makes sense

longwave’s picture

Status: Reviewed & tested by the community » Needs work

NW for MR feedback.

tim.plunkett’s picture

Issue tags: +Needs tests

I mentioned needing tests in the IS, forgot to tag.
Addressed MR feedback.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.44 KB

Attaching a failing patch to go along with the MR which should pass.

Status: Needs review » Needs work

The last submitted patch, 6: 3230726-assertWaitOnAjaxRequest-6-FAIL.patch, failed testing. View results

tim.plunkett’s picture

Status: Needs work » Needs review

Patch failed as expected, branch is passing.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, test coverage makes sense.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

NW for small fixes above.

wim leers’s picture

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.