Problem/Motivation

https://git.drupalcode.org/issue/drupal-3357616/-/pipelines/917644/test_...

Drupal\Tests\ckeditor5\FunctionalJavascript\CKEditor5Test::testEmphasis
Behat\Mink\Exception\ExpectationException: The string "<p>This is a <em>test!</em></p>" was not found anywhere in the HTML response of the current page.

vendor/behat/mink/src/WebAssert.php:888
vendor/behat/mink/src/WebAssert.php:363
core/tests/Drupal/Tests/WebAssert.php:569
core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php:553

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3616094

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

longwave created an issue. See original summary.

longwave-bot made their first commit to this issue’s fork.

longwave’s picture

Status: Active » Needs review

smustgrave’s picture

There a neat gitlab trick to run x number of times?

longwave’s picture

Status: Needs review » Needs work

I tried to do 300 runs in https://git.drupalcode.org/project/drupal/-/jobs/11482920 but 1. it timed out and 2. it is running into #3616075: [random test failure] CKEditor5Test::testExistingContent in the same file. I think we should combine them.

To do the multiple runs you can start the "repeat class test" job but you have to know the variable names to configure it. So, I also opened #3616180: [ci] Improve repeat test class job configuration to make this easier. Not sure if the GitLab permissions issue affects some people trying to run this job, too.

longwave’s picture

Title: [random test failure] CKEditor5Test::testEmphasis » [random test failure] CKEditor5Test::testEmphasis and ::testExistingContent
longwave’s picture

Priority: Normal » Critical

Bumping this to critical as it's affected a number of pipelines that I've seen this week alone.

longwave’s picture

Status: Needs work » Needs review
longwave’s picture

Status: Needs review » Needs work

Better, but not good enough.

longwave’s picture

Status: Needs work » Needs review

Can't reproduce locally so far, let's just see if increasing the timeout helps at all.

100x more: https://git.drupalcode.org/issue/drupal-3616094/-/jobs/11486151

charlliequadros’s picture

I'm testing the change by adding this assertion:

$this->assertNotEmpty($assert_session->waitForText('page My test content has been created.'));

I'm trying to run the tests locally before submitting the change, using this command in the terminal:

for round in {1..10}; do
  echo "=== Run $round ==="

  if ddev exec ./vendor/bin/phpunit -c core core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php --filter testEmphasis
  then
    echo "✅ PASSED on run $round"
  else
    echo "❌ FAILED on run $round"
    break
  fi
done
charlliequadros’s picture

Hi @longwave

The tests with these assertions work because they wait for the message confirming that the content was created or updated successfully. Do you think it would be worth changing the tests to use this type of check?

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
index c35bf4d6076..9308a973d93 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
@@ -52,6 +52,7 @@ public function testExistingContent(): void {
     $page->fillField('title[0][value]', 'My test content');
     $page->fillField('body[0][value]', '<p>This is test content</p>');
     $page->pressButton('Save');
+    $this->assertNotEmpty($assert_session->waitForText('page My test content has been created.'));
     $assert_session->responseNotContains('<p>This is test content</p>');
     $assert_session->responseContains('&lt;p&gt;This is test content&lt;/p&gt;');
 
@@ -67,6 +68,7 @@ public function testExistingContent(): void {
     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
     $this->assertNotEmpty($assert_session->waitForText('This is test content'));
     $page->pressButton('Save');
+    $this->assertNotEmpty($assert_session->waitForText('page My test content has been updated.'));
 
     // Assert that the HTML is rendered correctly.
     $assert_session->responseContains('<p>This is test content</p>');
@@ -540,6 +542,7 @@ public function testEmphasis(): void {
     $page->fillField('title[0][value]', 'My test content');
     $page->fillField('body[0][value]', '<p>This is a <em>test!</em></p>');
     $page->pressButton('Save');
+    $this->assertNotEmpty($assert_session->waitForText('page My test content has been created.'));
 
     $this->addNewTextFormat();
 
@@ -551,6 +554,7 @@ public function testEmphasis(): void {
     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
     $this->assertTrue($assert_session->waitForText('This is a test!'));
     $page->pressButton('Save');
+    $this->assertNotEmpty($assert_session->waitForText('page My test content has been updated.'));
 
     $assert_session->responseContains('<p>This is a <em>test!</em></p>');
   }

longwave’s picture

Status: Needs review » Needs work

Sure, feel free to push to the MR if that has worked for you, and we can try it on CI with the "repeat class test" job.

charlliequadros’s picture

Hi @longwave.
I’ve added my changes, but I’m not sure where I should run the tests. I don’t think I have permission to run them, right?

charlliequadros’s picture

Status: Needs work » Needs review
longwave’s picture

The job is the "Repeat Class Test" job in CI, not sure who has permission to run it. You have to set the REPEAT_TEST_CLASS variable to the class that you want to test.

I am running it 100x for the class here: https://git.drupalcode.org/issue/drupal-3616094/-/jobs/11511432

longwave’s picture

Status: Needs review » Reviewed & tested by the community

@charlliequadros nice work, the 100x run passed every time, which I hadn't managed with the earlier changes.

  • catch committed 085e16d7 on 11.x
    fix: #3616094 [random test failure] CKEditor5Test::testEmphasis and ::...

  • catch committed 9d699f09 on main
    fix: #3616094 [random test failure] CKEditor5Test::testEmphasis and ::...
catch’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

This looks good. Eventually the selenium/chromium bug might get fixed, but even if it does the assertions won't do any harm.

Committed/pushed to main and 11.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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

joelpittet’s picture

Spotted this https://git.drupalcode.org/issue/drupal-3613882/-/jobs/11964276

Fail          8.943s testEmphasis                                                                    
Pass          6.997s testEmphasisArbitraryHtml                                                       
Failure              *** Process execution output ***                                                
    PHPUnit 12.5.17 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.5.10
    Configuration: /builds/core/phpunit.xml.dist
    
    F.                                                                  2 / 2 (100%)
    
    HTML output was generated.
    http://localhost/subdirectory/sites/simpletest/browser_output/Drupal_Tests_ckeditor5_FunctionalJavascript_EmphasisTest-1-76223404.html
    http://localhost/subdirectory/sites/simpletest/browser_output/Drupal_Tests_ckeditor5_FunctionalJavascript_EmphasisTest-2-76223404.html
    http://localhost/subdirectory/sites/simpletest/browser_output/Drupal_Tests_ckeditor5_FunctionalJavascript_EmphasisTest-3-55609641.html
    http://localhost/subdirectory/sites/simpletest/browser_output/Drupal_Tests_ckeditor5_FunctionalJavascript_EmphasisTest-4-55609641.html
    
    
    Time: 00:16.811, Memory: 16.00 MB
    
    Emphasis (Drupal\Tests\ckeditor5\FunctionalJavascript\Emphasis)
     ✘ Emphasis
       ┐
       ├ Behat\Mink\Exception\ExpectationException: The string "This is a test!" was not found anywhere in the HTML response of the current page.
       │
       │ /builds/vendor/behat/mink/src/WebAssert.php:888
       │ /builds/vendor/behat/mink/src/WebAssert.php:363
       │ /builds/core/tests/Drupal/Tests/WebAssert.php:569
       │ /builds/core/modules/ckeditor5/tests/src/FunctionalJavascript/EmphasisTest.php:142
       ┴
     ✔ Emphasis arbitrary html
    
    FAILURES!
    Tests: 2, Assertions: 21, Failures: 1.

Should I open a new one sonsidering it's a different test method?
testEmphasisArbitraryHtml

joelpittet’s picture