From fa2f8a6c0b96c761f99f4981811f0e0d54eb971d Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 13:54:06 +1000
Subject: [PATCH 01/52] chrome 134

---
 .gitlab-ci/pipeline.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml
index ee6f1e0e1769..338ba6778f9f 100644
--- a/.gitlab-ci/pipeline.yml
+++ b/.gitlab-ci/pipeline.yml
@@ -87,7 +87,7 @@ variables:
     - "--allowed-origins=*"
 
 .with-selenium-chrome: &with-selenium-chrome
-  name: selenium/standalone-chrome:127.0
+  name: selenium/standalone-chrome:134.0
   alias: selenium
   variables:
     JAVA_OPTS: "-Dwebdriver.chrome.logfile=/builds/chromedriver.log"
-- 
GitLab


From fcf26cca4c8b809479c3444d1628b4b3a8a1269e Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 15:43:47 +1000
Subject: [PATCH 02/52] waitForDocumentReady

---
 .../src/FunctionalJavascript/ManageFieldsTest.php      |  2 ++
 .../Drupal/FunctionalJavascriptTests/JSWebAssert.php   | 10 ++++++++++
 2 files changed, 12 insertions(+)

diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
index ed59877c5577..a50f08a92ded 100644
--- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
+++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
@@ -309,6 +309,7 @@ public function testFieldTypeOrder(): void {
       $group_field_card = $page->find('css', "[name='new_storage_type'][value='$field_type_category']")->getParent();
       $group_field_card->click();
       $page->pressButton('Continue');
+      $this->assertSession()->waitForDocumentReady();
       $field_types = $page->findAll('css', '.subfield-option .option');
       $field_type_labels = [];
       foreach ($field_types as $field_type) {
@@ -328,6 +329,7 @@ public function testFieldTypeOrder(): void {
       $this->assertSame($expected_field_types, $field_type_labels);
       // Return to the first step of the form.
       $page->pressButton('Back');
+      $this->assertSession()->waitForDocumentReady();
     }
   }
 
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
index 49c0ea9e8e4c..83197ade1f3d 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
@@ -747,4 +747,14 @@ public function statusMessageNotContains(string $message, ?string $type = NULL):
     parent::statusMessageNotContains($message, $type);
   }
 
+  /**
+   * Wait until the document is ready.
+   */
+  public function waitForDocumentReady(): bool {
+    // Wait for a very short time to allow page state to update after clicking.
+    usleep(5000);
+    return $this->waitForHelper(10000, fn () =>
+      $this->session->evaluateScript('document.readyState === "complete"'));
+  }
+
 }
-- 
GitLab


From 9507332857d8ab807b24542d2b1f85de90e74905 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 14:56:37 +1000
Subject: [PATCH 03/52] LayoutBuilderTest

---
 .../tests/src/FunctionalJavascript/LayoutBuilderTest.php        | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
index fb237f03a226..3e5becf7622a 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
@@ -385,6 +385,7 @@ public function testLayoutNoDialog(): void {
     $page->fillField('settings[label_display]', TRUE);
     $page->pressButton('Add block');
 
+    $assert_session->waitForDocumentReady();
     $assert_session->addressEquals($layout_url);
     $assert_session->pageTextContains('Powered by Drupal');
     $assert_session->pageTextContains('The block label');
@@ -396,6 +397,7 @@ public function testLayoutNoDialog(): void {
       'delta' => 0,
     ]));
     $page->pressButton('Remove');
+    $assert_session->waitForDocumentReady();
     $assert_session->addressEquals($layout_url);
     $assert_session->pageTextNotContains('Powered by Drupal');
     $assert_session->pageTextNotContains('The block label');
-- 
GitLab


From 0c9ee17da1979a73de7d91fbf955873da6ae69fd Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 15:45:54 +1000
Subject: [PATCH 04/52] LayoutBuilderToolbarTest

---
 .../src/FunctionalJavascript/LayoutBuilderToolbarTest.php      | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php
index 5e0155ae06d7..5b4f01a946d2 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php
@@ -79,6 +79,7 @@ public function testBackToSiteLink(): void {
     $this->clickLink('Manage layout');
     // Save the defaults.
     $page->pressButton('Save layout');
+    $assert_session->waitForDocumentReady();
     $assert_session->addressEquals("$field_ui_prefix/display/default");
 
     // As the Layout Builder UI is typically displayed using the frontend theme,
@@ -92,11 +93,13 @@ public function testBackToSiteLink(): void {
 
     $this->drupalGet("$field_ui_prefix/display/default/layout/discard-changes");
     $page->pressButton('Confirm');
+    $assert_session->waitForDocumentReady();
     $this->clickLink('Back to site');
     $assert_session->addressEquals("/user/2");
 
     $this->drupalGet("$field_ui_prefix/display/default/layout/disable");
     $page->pressButton('Confirm');
+    $assert_session->waitForDocumentReady();
     $this->clickLink('Back to site');
     $assert_session->addressEquals("/user/2");
   }
-- 
GitLab


From 72429569743ef02145b681aad1b36ff3e760b52b Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 15:54:19 +1000
Subject: [PATCH 05/52] EnableLayoutBuilderTrait

---
 .../FunctionalJavascript/LayoutBuilderOptInTest.php    |  1 +
 .../tests/src/Traits/EnableLayoutBuilderTrait.php      | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
index f5e106cfc9ac..d4b0f418da1d 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderOptInTest.php
@@ -73,6 +73,7 @@ public function testCheckboxLogic(): void {
     // Check and submit allow_custom.
     $page->checkField('layout[allow_custom]');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $assert_session->checkboxChecked('layout[enabled]');
     $assert_session->checkboxChecked('layout[allow_custom]');
 
diff --git a/core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php b/core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php
index 201b1f9aff29..eb239b00ded4 100644
--- a/core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php
+++ b/core/modules/layout_builder/tests/src/Traits/EnableLayoutBuilderTrait.php
@@ -4,6 +4,7 @@
 
 namespace Drupal\Tests\layout_builder\Traits;
 
+use Drupal\FunctionalJavascriptTests\WebDriverWebAssert;
 use Drupal\layout_builder\Entity\LayoutEntityDisplayInterface;
 
 /**
@@ -55,12 +56,21 @@ protected function enableLayoutBuilderFromUi(string $bundle, string $viewMode, b
    *   The view mode that Layout Builder is being disabled on.
    */
   protected function disableLayoutBuilderFromUi(string $bundle, string $viewMode): void {
+    $assert_session = $this->assertSession();
+    $wait = $assert_session instanceof WebDriverWebAssert;
     $path = sprintf('admin/structure/types/manage/%s/display/%s', $bundle, $viewMode);
     $page = $this->getSession()->getPage();
     $this->drupalGet($path);
     $page->uncheckField('layout[enabled]');
     $page->pressButton('Save');
+    if ($wait) {
+      $assert_session->waitForDocumentReady();
+    }
+
     $page->pressButton('Confirm');
+    if ($wait) {
+      $assert_session->waitForDocumentReady();
+    }
   }
 
 }
-- 
GitLab


From 587506c64f5041fa4f6c2e984396d49108e6d53b Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 15:58:31 +1000
Subject: [PATCH 06/52] LayoutBuilderNestedFormUiTest

---
 .../FunctionalJavascript/LayoutBuilderNestedFormUiTest.php    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php
index 6cb5b136b876..7b32884d5605 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderNestedFormUiTest.php
@@ -155,13 +155,13 @@ protected function addFormBlock($label, $path, $expected_save_message): void {
 
     // Save the defaults.
     $page->pressButton('Save layout');
-    $assert_session->pageTextContains($expected_save_message);
+    $this->assertTrue($assert_session->waitForText($expected_save_message));
     $assert_session->addressEquals($path);
 
     // Go back to edit layout and try to re-save.
     $this->drupalGet($path . '/layout');
     $page->pressButton('Save layout');
-    $assert_session->pageTextContains($expected_save_message);
+    $this->assertTrue($assert_session->waitForText($expected_save_message));
     $assert_session->addressEquals($path);
   }
 
-- 
GitLab


From 41de668fce1ff58bfc1c6c0672f29a1c2d2a7a86 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Mon, 24 Mar 2025 16:21:41 +1000
Subject: [PATCH 07/52] OptionsFieldUIAllowedValuesTest

---
 .../field_ui/tests/src/Traits/FieldUiJSTestTrait.php      | 8 ++++++++
 .../OptionsFieldUIAllowedValuesTest.php                   | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
index c611e00adede..6754d55049e3 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
@@ -51,7 +51,9 @@ public function fieldUIAddNewFieldJS(?string $bundle_path, string $field_name, ?
       $field_card = $this->getFieldFromGroupJS($field_type);
     }
     $field_card?->click();
+    $assert_session->waitForDocumentReady();
     $page->findButton('Continue')->click();
+    $assert_session->waitForDocumentReady();
     $field_label = $page->findField('edit-label');
     $this->assertTrue($field_label->isVisible());
     $field_label = $page->find('css', 'input[data-drupal-selector="edit-label"]');
@@ -59,16 +61,19 @@ public function fieldUIAddNewFieldJS(?string $bundle_path, string $field_name, ?
     $machine_name = $assert_session->waitForElementVisible('css', '[data-drupal-selector="edit-label"] + * .machine-name-value');
     $this->assertNotEmpty($machine_name);
     $page->findButton('Edit')->press();
+    $assert_session->waitForDocumentReady();
 
     $field_field_name = $page->findField('field_name');
     $this->assertTrue($field_field_name->isVisible());
     $field_field_name->setValue($field_name);
 
     $page->findButton('Continue')->click();
+    $assert_session->waitForDocumentReady();
     $assert_session->waitForText("These settings apply to the $label field everywhere it is used.");
     if ($save_settings) {
       // Second step: Save field settings.
       $page->findButton('Save settings')->click();
+      $assert_session->waitForDocumentReady();
       $assert_session->pageTextContains("Saved $label configuration.");
 
       // Check that the field appears in the overview form.
@@ -141,12 +146,15 @@ public function getFieldFromGroupJS($field_type) {
     foreach ($groups as $group) {
       $group_field_card = $this->getSession()->getPage()->find('css', "[name='new_storage_type'][value='$group']")->getParent();
       $group_field_card->click();
+      $this->assertSession()->waitForDocumentReady();
       $this->getSession()->getPage()->pressButton('Continue');
+      $this->assertSession()->waitForDocumentReady();
       $field_card = $this->getSession()->getPage()->find('css', "[name='group_field_options_wrapper'][value='$field_type']");
       if ($field_card) {
         break;
       }
       $this->getSession()->getPage()->pressButton('Back');
+      $this->assertSession()->waitForDocumentReady();
     }
     return $field_card->getParent();
   }
diff --git a/core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php b/core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php
index 5266f1c950aa..adff1dd97483 100644
--- a/core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php
+++ b/core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUIAllowedValuesTest.php
@@ -119,6 +119,7 @@ public function testOptionsAllowedValues($option_type, $options, $is_string_opti
       switch ($add_row_method) {
         case 'Press button':
           $page->pressButton('Add another item');
+          $assert->waitForDocumentReady();
           break;
 
         case 'Enter button':
@@ -171,6 +172,7 @@ public function testOptionsAllowedValues($option_type, $options, $is_string_opti
       $this->assertAllowValuesRowCount($expected_rows);
     }
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
 
     $option_labels = array_values($options);
     $this->assertCount(3, $option_labels);
@@ -189,6 +191,7 @@ public function testOptionsAllowedValues($option_type, $options, $is_string_opti
     $drag_handle->dragTo($target);
     $this->assertOrder([$option_labels[1], $option_labels[2], $option_labels[0], ''], $is_string_option);
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
 
     $this->drupalGet($this->nodeFormPath);
     $this->assertNodeFormOrder(['- None -', $option_labels[1], $option_labels[2], $option_labels[0]]);
@@ -203,6 +206,7 @@ public function testOptionsAllowedValues($option_type, $options, $is_string_opti
     $this->assertSession()->assertWaitOnAjaxRequest();
     $this->assertOrder([$option_labels[1], $option_labels[0], ''], $is_string_option);
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
 
     $this->drupalGet($this->nodeFormPath);
     $this->assertNodeFormOrder(['- None -', $option_labels[1], $option_labels[0]]);
-- 
GitLab


From bb745d985b70dc74df44dc3d90d0138f7e422ff8 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 12:25:59 +1000
Subject: [PATCH 08/52] LayoutBuilderUiTest

---
 .../tests/src/FunctionalJavascript/LayoutBuilderUiTest.php     | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
index 46f15a177c2c..ddc34c60d2e1 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
@@ -105,13 +105,16 @@ public function testUnsavedChangesMessage(): void {
 
     // Discard then confirm.
     $page->pressButton('Discard changes');
+    $this->assertSession()->waitForDocumentReady();
     $page->pressButton('Confirm');
+    $this->assertSession()->waitForDocumentReady();
     $assert_session->addressEquals(static::FIELD_UI_PREFIX . '/display/default');
     $assert_session->pageTextNotContains('You have unsaved changes.');
 
     // Make and then save changes.
     $this->assertModifiedLayout(static::FIELD_UI_PREFIX . '/display/default/layout');
     $page->pressButton('Save layout');
+    $this->assertSession()->waitForDocumentReady();
     $assert_session->pageTextNotContains('You have unsaved changes.');
   }
 
-- 
GitLab


From 647c64ceb5290634014082574314567300d017a4 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 12:26:08 +1000
Subject: [PATCH 09/52] CKEditor5Test

---
 .../ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
index 10a32513fb2a..38e3acb59821 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
@@ -213,6 +213,7 @@ public function languageOfPartsPluginInitialConfigurationHelper($page, $assert_s
     // Confirm there are no longer any warnings.
     $assert_session->waitForElementRemoved('css', '[data-drupal-messages] [role="alert"]');
     $page->pressButton('Save configuration');
+    $this->assertSession()->waitForDocumentReady();
     $assert_session->responseContains('Added text format <em class="placeholder">ckeditor5</em>.');
   }
 
@@ -232,6 +233,7 @@ public function languageOfPartsPluginConfigureLanguageListHelper($page, $assert_
       $assert_session->assertWaitOnAjaxRequest();
     }
     $page->pressButton('Save configuration');
+    $this->assertSession()->waitForDocumentReady();
     $assert_session->responseContains('The text format <em class="placeholder">ckeditor5</em> has been updated.');
   }
 
-- 
GitLab


From 159db97ad91423a3fa882f602825381ee66da396 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 12:26:14 +1000
Subject: [PATCH 10/52] CKEditor5MarkupTest

---
 .../tests/src/FunctionalJavascript/CKEditor5MarkupTest.php    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5MarkupTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5MarkupTest.php
index 3557f2df2448..d3023628ef86 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5MarkupTest.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5MarkupTest.php
@@ -160,6 +160,7 @@ public function testComments(): void {
     $page->fillField('title[0][value]', 'My test content');
     $page->fillField('body[0][value]', '<!-- Hamsters, alpacas, llamas, and kittens are cute! --><p>This is a <em>test!</em></p>');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     FilterFormat::create([
       'format' => 'ckeditor5',
@@ -187,9 +188,11 @@ function (ConstraintViolationInterface $v) {
     $page->selectFieldOption('body[0][format]', 'ckeditor5');
     $this->assertNotEmpty($assert_session->waitForText('Change text format?'));
     $page->pressButton('Continue');
+    $assert_session->waitForDocumentReady();
 
     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $assert_session->responseContains('<!-- Hamsters, alpacas, llamas, and kittens are cute! --><p>This is a <em>test!</em></p>');
   }
@@ -339,6 +342,7 @@ function (ConstraintViolationInterface $v) {
       $editor->setValue($markup);
       $page->pressButton('Save');
 
+      $this->assertSession()->waitForDocumentReady();
       $assert_session->responseContains($expected_content);
     }
   }
-- 
GitLab


From 6a4f0ea4335c03e997f20abef08ddb64a165b9e3 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 13:53:31 +1000
Subject: [PATCH 11/52] CKEditor5AllowedTagsTest

---
 .../src/FunctionalJavascript/CKEditor5AllowedTagsTest.php    | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
index ca9cb17ca62b..e8a00b25b3c1 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
@@ -433,6 +433,7 @@ public function testFullHtml(): void {
     $page->fillField('title[0][value]', 'My test content');
     $page->fillField('body[0][value]', '<foo bar="baz">⬅️✌️➡️</foo><p><a style="color:#ff0000;" foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     // Configure Full HTML text format to use CKEditor 5.
     $this->drupalGet('admin/config/content/formats/manage/full_html');
@@ -454,10 +455,12 @@ public function testFullHtml(): void {
     $page->selectFieldOption('body[0][format]', 'full_html');
     $this->assertNotEmpty($assert_session->waitForText('Change text format?'));
     $page->pressButton('Continue');
+    $assert_session->waitForDocumentReady();
 
     // Ensure the editor is loaded and ensure that arbitrary markup is retained.
     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     // But note that the `style` attribute was stripped by
     // \Drupal\editor\EditorXssFilter\Standard.
@@ -469,9 +472,11 @@ public function testFullHtml(): void {
     $this->triggerKeyUp('.ckeditor5-toolbar-item-link', 'ArrowDown');
     $assert_session->assertWaitOnAjaxRequest();
     $page->pressButton('Save configuration');
+    $assert_session->waitForDocumentReady();
 
     $this->drupalGet('node/1/edit');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $assert_session->responseContains('<p><a foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
 
-- 
GitLab


From 36aebe32e44a8303597f9c6ee79d1e33d97d525f Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 13:56:45 +1000
Subject: [PATCH 12/52] MediaDisplayTest

---
 .../media/tests/src/FunctionalJavascript/MediaDisplayTest.php  | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
index b1fc5baaf7d1..96fe10a08f17 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
@@ -76,6 +76,7 @@ public function testMediaDisplay(): void {
     $page->selectFieldOption('fields[name][region]', 'content');
     $assert_session->waitForElementVisible('css', '#edit-fields-name-settings-edit');
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
     $this->drupalGet('media/' . $media->id());
     // Verify the name is present, and its text matches what is expected. Now
     // there should be markup in the h1.
@@ -91,6 +92,7 @@ public function testMediaDisplay(): void {
     $this->assertNotEmpty($result);
     $page->fillField('field_media_image[0][alt]', 'Image Alt Text 1');
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
     $image_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
@@ -129,6 +131,7 @@ public function testMediaDisplay(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
 
     // Go to the media entity view.
     $this->drupalGet($this->assertLinkToCreatedMedia());
-- 
GitLab


From 217184d38dd921acfa9b1c1c32b60b8a2877cd64 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:11:56 +1000
Subject: [PATCH 13/52] MediaStandardProfileTest

---
 .../FunctionalJavascript/MediaStandardProfileTest.php    | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php
index 72fa18190b75..5131300a4dc3 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaStandardProfileTest.php
@@ -127,6 +127,7 @@ protected function audioTest(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $audio_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
@@ -175,6 +176,7 @@ protected function audioTest(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $this->drupalGet('/node/' . $node->id());
 
@@ -215,6 +217,7 @@ protected function imageTest(): void {
     $this->assertNotEmpty($result);
     $page->fillField("{$source_field_id}[0][alt]", 'Image Alt Text 1');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $image_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
@@ -269,6 +272,7 @@ protected function imageTest(): void {
     $this->assertNotEmpty($result);
     $page->fillField("{$source_field_id}[0][alt]", 'Image Alt Text 2');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $this->drupalGet('/node/' . $node->id());
 
@@ -318,6 +322,7 @@ protected function documentTest(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $file_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
@@ -363,6 +368,7 @@ protected function documentTest(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $this->drupalGet('/node/' . $node->id());
 
@@ -406,6 +412,7 @@ protected function remoteVideoTest(): void {
     // Create a media item.
     $page->fillField("{$source_field_id}[0][value]", $video_url);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $remote_video_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
@@ -452,6 +459,7 @@ protected function remoteVideoTest(): void {
     $this->drupalGet('media/' . $remote_video_media_id . '/edit');
     $page->fillField("{$source_field_id}[0][value]", $video_url_updated);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $this->drupalGet('/node/' . $node->id());
 
@@ -503,6 +511,7 @@ protected function videoTest(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $video_media_id = $this->container
       ->get('entity_type.manager')
       ->getStorage('media')
-- 
GitLab


From 8ba0b986b303b5315ef2092cfde24508e725443f Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:16:02 +1000
Subject: [PATCH 14/52] InlineBlockTest

---
 .../tests/src/FunctionalJavascript/InlineBlockTestBase.php       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php
index 6931a733d96d..23be9f510cb5 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTestBase.php
@@ -87,6 +87,7 @@ protected function assertSaveLayout() {
     // Reload the page to prevent random failures.
     $this->drupalGet($this->getUrl());
     $page->pressButton('Save layout');
+    $assert_session->waitForDocumentReady();
     $this->assertNotEmpty($assert_session->waitForElement('css', '.messages--status'));
 
     if (stristr($this->getUrl(), 'admin/structure') === FALSE) {
-- 
GitLab


From 4fc4946952822c05f60f7275d183edd6ccf5a97e Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:18:20 +1000
Subject: [PATCH 15/52] ManageFieldsTest

---
 .../tests/src/FunctionalJavascript/ManageFieldsTest.php     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
index a50f08a92ded..b932afb57ea3 100644
--- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
+++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageFieldsTest.php
@@ -363,13 +363,15 @@ public function testLabelFieldFormValidation(): void {
     $page = $this->getSession()->getPage();
 
     $page->findButton('Continue')->click();
-    $this->assertSession()->pageTextContains('You need to select a field type.');
+    $this->assertTrue($this->assertSession()->waitForText('You need to select a field type.'));
 
     $this->assertNotEmpty($boolean_field = $page->find('xpath', '//*[text() = "Boolean (overridden by alter)"]')->getParent());
     $boolean_field->click();
+    $this->assertSession()->waitForDocumentReady();
     $page->findButton('Continue')->click();
+    $this->assertSession()->waitForDocumentReady();
     $page->findButton('Continue')->click();
-    $this->assertSession()->pageTextContains('Add new field: you need to provide a label.');
+    $this->assertTrue($this->assertSession()->waitForText('Add new field: you need to provide a label.'));
   }
 
 }
-- 
GitLab


From 282f9e3fecaa075453bde9a5d9178164b0650957 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:19:04 +1000
Subject: [PATCH 16/52] AjaxFileManagedMultipleTest

---
 .../src/FunctionalJavascript/AjaxFileManagedMultipleTest.php    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php b/core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php
index e7fb4e3e7016..df74de39bca4 100644
--- a/core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php
+++ b/core/modules/file/tests/src/FunctionalJavascript/AjaxFileManagedMultipleTest.php
@@ -49,7 +49,7 @@ public function testMultipleFilesUpload(): void {
     // Save entire form.
     $page->pressButton('Save');
 
-    $this->assertSession()->pageTextContains('The file ids are 1,2.');
+    $this->assertTrue($this->assertSession()->waitForText('The file ids are 1,2.'));
     $this->assertCount(2, $file_storage->loadByProperties(['filename' => $paths]));
   }
 
-- 
GitLab


From e7955825007dfcac49139477ddaaee6ed2e45076 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:22:12 +1000
Subject: [PATCH 17/52] NodeDeleteConfirmTest

---
 .../tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
index 5eb912c577cd..6cf5bdec2164 100644
--- a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
+++ b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
@@ -120,7 +120,7 @@ public function testNodeTypeDelete(): void {
     $this->clickLink('Delete');
     $this->assertEquals('Are you sure you want to delete the content type Article?', $this->assertSession()->waitForElement('css', '.ui-dialog-title')->getText());
     $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');
-    $this->assertSession()->pageTextContains('The content type Article has been deleted.');
+    $this->assertTrue($this->assertSession()->waitForText('The content type Article has been deleted.'));
 
     $this->drupalCreateContentType([
       'name' => 'Article',
@@ -132,7 +132,7 @@ public function testNodeTypeDelete(): void {
     $this->clickLink('Delete');
     $this->assertEquals('Are you sure you want to delete the content type Article?', $this->assertSession()->waitForElement('css', '.ui-dialog-title')->getText());
     $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');
-    $this->assertSession()->pageTextContains('The content type Article has been deleted.');
+    $this->assertTrue($this->assertSession()->waitForText('The content type Article has been deleted.'));
   }
 
 }
-- 
GitLab


From 4e7c064b77a392af0b8147b4d576ef7a2f8135e2 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:43:34 +1000
Subject: [PATCH 18/52] MediaTypeCreationTest

---
 .../tests/src/FunctionalJavascript/MediaTypeCreationTest.php    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
index 699d97e9a181..f43b4a6018c7 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
@@ -163,6 +163,7 @@ public function testMediaTypeCreationReuseSourceField(): void {
     $page->fillField('label', 'Pastafazoul');
     $session->wait(5000, "jQuery('.machine-name-value').text() === 'pastafazoul'");
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $label = 'Type reusing Default Field';
     $mediaTypeMachineName = str_replace(' ', '_', strtolower($label));
@@ -187,6 +188,7 @@ public function testMediaTypeCreationReuseSourceField(): void {
     $session->wait(5000, "jQuery('.machine-name-value').text() === '{$mediaTypeMachineName}'");
 
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     // Check that no new fields were created.
     $this->drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}/fields");
-- 
GitLab


From 14b03d53cc3a78c55a32cf8447bc73522e4c9fa3 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:46:50 +1000
Subject: [PATCH 19/52] NodeDeleteConfirmTest

---
 .../src/FunctionalJavascript/NodeDeleteConfirmTest.php     | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
index 6cf5bdec2164..c2bb6d5b084c 100644
--- a/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
+++ b/core/modules/node/tests/src/FunctionalJavascript/NodeDeleteConfirmTest.php
@@ -65,8 +65,7 @@ public function testNodeDelete(): void {
     // Asserts a dialog opens with the expected text.
     $this->assertEquals('Are you sure you want to delete the content item Delete article from content list?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText());
     $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');
-
-    $assert_session->pageTextContains('The Article Delete article from content list has been deleted.');
+    $this->assertTrue($assert_session->waitForText('The Article Delete article from content list has been deleted.'));
     // Assert that the node is deleted in above operation.
     $this->drupalGet('admin/content');
     $assert_session->pageTextContains('There are no content items yet.');
@@ -83,7 +82,7 @@ public function testNodeDelete(): void {
     $this->assertEquals('Are you sure you want to delete the content item Delete article from entity form?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText());
 
     $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');
-    $assert_session->pageTextContains('The Article Delete article from entity form has been deleted.');
+    $this->assertTrue($assert_session->waitForText('The Article Delete article from entity form has been deleted.'));
 
     $node = $this->createNode([
       'type' => 'article',
@@ -103,7 +102,7 @@ public function testNodeDelete(): void {
     $this->assertEquals('Are you sure you want to delete the content item Delete article from views entity operations?', $assert_session->waitForElement('css', '.ui-dialog-title')->getText());
     $page->find('css', '.ui-dialog-buttonset')->pressButton('Delete');
 
-    $assert_session->pageTextContains('The Article Delete article from views entity operations has been deleted.');
+    $this->assertTrue($assert_session->waitForText('The Article Delete article from views entity operations has been deleted.'));
     $assert_session->pageTextContains('No content available.');
   }
 
-- 
GitLab


From 9f650eafe56f5088cb350444f50ca174b9d96b9f Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:49:20 +1000
Subject: [PATCH 20/52] MediaUiJavascriptTest

---
 .../tests/src/FunctionalJavascript/MediaUiJavascriptTest.php     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
index 757242234234..a4f85f86a933 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
@@ -193,6 +193,7 @@ public function testMediaTypes(): void {
     $this->assertNotEmpty($assert_session->waitForElementVisible('css', '#drupal-modal'));
     $assert_session->addressEquals('admin/structure/media/manage/' . $this->testMediaType->id());
     $this->click('.ui-dialog button:contains("Delete")');
+    $assert_session->waitForDocumentReady();
     $assert_session->addressEquals('admin/structure/media');
     $assert_session->pageTextContains('The media type ' . $new_name . ' has been deleted.');
 
-- 
GitLab


From d0112b780b2ae723f43c000da88d3cb4469e9635 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:52:11 +1000
Subject: [PATCH 21/52] DevelopmentSettingsFormTest

---
 .../FunctionalJavascript/Form/DevelopmentSettingsFormTest.php    | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php b/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php
index 30f50b7bd0af..de476f8a350f 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/Form/DevelopmentSettingsFormTest.php
@@ -65,6 +65,7 @@ public function testTwigDevelopmentMode(bool $twig_development_mode, ?bool $twig
       $this->getSession()->getPage()->uncheckField('Disable Twig cache');
     }
     $this->getSession()->getPage()->pressButton('Save settings');
+    $this->assertSession()->waitForDocumentReady();
 
     $this->drupalGet(Url::fromRoute('system.status'));
     if (!$twig_development_mode) {
-- 
GitLab


From 0acf858b52147871bcf68ebe068c320292fb3321 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 14:57:41 +1000
Subject: [PATCH 22/52] FieldUiIntegrationTest

---
 .../tests/src/FunctionalJavascript/FieldUiIntegrationTest.php    | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/media_library/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php b/core/modules/media_library/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php
index f30393116782..a22ee5075124 100644
--- a/core/modules/media_library/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php
+++ b/core/modules/media_library/tests/src/FunctionalJavascript/FieldUiIntegrationTest.php
@@ -110,6 +110,7 @@ public function testFieldUiIntegration(): void {
     $this->waitForFieldExists('Type One')->check();
     $this->assertElementExistsAfterWait('css', '[name="settings[handler_settings][target_bundles][type_one]"][checked="checked"]');
     $page->pressButton('Save settings');
+    $assert_session->waitForDocumentReady();
     $this->drupalGet('/admin/structure/types/manage/page/form-display');
     $assert_session->fieldValueEquals('fields[field_shatner][type]', 'media_library_widget');
   }
-- 
GitLab


From 2be6c4ff5942e8aaf0f9b9fa30f430efd7029669 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:00:06 +1000
Subject: [PATCH 23/52] TriggeringElementTest

---
 .../src/FunctionalJavascript/Form/TriggeringElementTest.php      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/system/tests/src/FunctionalJavascript/Form/TriggeringElementTest.php b/core/modules/system/tests/src/FunctionalJavascript/Form/TriggeringElementTest.php
index d07aea57549d..515a5fdb3841 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/Form/TriggeringElementTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/Form/TriggeringElementTest.php
@@ -107,6 +107,7 @@ public function testAttemptAccessControlBypass(): void {
     $input->setValue('name', 'button1');
     $input->setValue('value', 'button1');
     $this->xpath('//form[@id="' . $form_html_id . '"]//input[@type="submit"]')[0]->click();
+    $this->assertSession()->waitForDocumentReady();
 
     // Ensure that the triggering element was not set to the restricted button.
     // Do this with both a negative and positive assertion, because negative
-- 
GitLab


From 0f49797fdaa1096f62ff144c0b67cdeb7ae6eae7 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:04:59 +1000
Subject: [PATCH 24/52] MediaEmbedFilterConfigurationUiAddTest

---
 .../MediaEmbedFilterConfigurationUiAddTest.php                   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiAddTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiAddTest.php
index 554fc35e37c5..f264ec75ec27 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiAddTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiAddTest.php
@@ -48,6 +48,7 @@ public function testValidationWhenAdding($filter_html_status, $filter_align_stat
       $page->fillField('filters[filter_html][settings][allowed_html]', $allowed_html);
     }
     $page->pressButton('Save configuration');
+    $this->assertSession()->waitForDocumentReady();
 
     if ($expected_error_message) {
       $this->assertSession()->pageTextNotContains('Added text format Another test format.');
-- 
GitLab


From 6febd2bd5d44f7084de72df74b02b558b14fc985 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:07:58 +1000
Subject: [PATCH 25/52] CKEditor5AllowedTagsTest

---
 .../FunctionalJavascript/CKEditor5AllowedTagsTest.php  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
index e8a00b25b3c1..7f0921556fde 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5AllowedTagsTest.php
@@ -156,7 +156,7 @@ public function testSwitchToVersion5(): void {
 
     $page->pressButton('Save configuration');
 
-    $assert_session->pageTextContains('The text format unicorn has been updated');
+    $this->assertTrue($assert_session->waitForText('The text format unicorn has been updated'));
   }
 
   /**
@@ -267,7 +267,7 @@ public function testAllowedTags(): void {
     $this->assertHtmlEsqueFieldValueEquals('filters[filter_html][settings][allowed_html]', $allowed_with_blockquote);
 
     $page->pressButton('Save configuration');
-    $assert_session->pageTextContains('The text format ckeditor5 has been updated.');
+    $this->assertTrue($assert_session->waitForText('The text format ckeditor5 has been updated.'));
 
     // Flush caches so the updated config can be checked.
     drupal_flush_all_caches();
@@ -312,8 +312,8 @@ public function testAllowedTags(): void {
     // The same validation error appears when saving the form regardless of the
     // immediate AJAX validation error above.
     $page->pressButton('Save configuration');
-    $assert_session->pageTextContains('The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold (<strong>)');
-    $this->assertTrue($page->find('css', '[href^="#edit-editor-settings-plugins-ckeditor5-sourceediting"]')->getParent()->hasClass('is-selected'));
+    $this->assertTrue($assert_session->waitForText('The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold (<strong>)'));
+    $this->assertTrue($assert_session->waitForElement('css', '[href^="#edit-editor-settings-plugins-ckeditor5-sourceediting"]')->getParent()->hasClass('is-selected'));
     $this->assertSame('true', $page->findField('editor[settings][plugins][ckeditor5_sourceEditing][allowed_tags]')->getAttribute('aria-invalid'));
     $assert_session->pageTextNotContains('The text format ckeditor5 has been updated');
 
@@ -326,7 +326,7 @@ public function testAllowedTags(): void {
     $source_edit_tags_field->setValue('<aside>');
     $assert_session->assertWaitOnAjaxRequest();
     $page->pressButton('Save configuration');
-    $assert_session->pageTextContains('The text format ckeditor5 has been updated');
+    $this->assertTrue($assert_session->waitForText('The text format ckeditor5 has been updated'));
     $assert_session->pageTextNotContains('The following tag(s) are already supported by enabled plugins and should not be added to the Source Editing "Manually editable HTML tags" field: Bold (<strong>)');
 
     // Ensure that CKEditor can be initialized with Source Editing.
-- 
GitLab


From 646526eec18a588f2b0efa954cfe58662280b984 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:18:14 +1000
Subject: [PATCH 26/52] FieldUiJSTestTrait

---
 .../field_ui/tests/src/Traits/FieldUiJSTestTrait.php        | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
index 6754d55049e3..f793e181fe23 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
@@ -68,13 +68,11 @@ public function fieldUIAddNewFieldJS(?string $bundle_path, string $field_name, ?
     $field_field_name->setValue($field_name);
 
     $page->findButton('Continue')->click();
-    $assert_session->waitForDocumentReady();
-    $assert_session->waitForText("These settings apply to the $label field everywhere it is used.");
+    $this->assertTrue($assert_session->waitForText("These settings apply to the $label field everywhere it is used."));
     if ($save_settings) {
       // Second step: Save field settings.
       $page->findButton('Save settings')->click();
-      $assert_session->waitForDocumentReady();
-      $assert_session->pageTextContains("Saved $label configuration.");
+      $this->assertTrue($assert_session->waitForText("Saved $label configuration."));
 
       // Check that the field appears in the overview form.
       $row = $page->find('css', '#field-' . $field_name);
-- 
GitLab


From 5fe5f7c89dd8afab4f553d4d37e579196ff41f4f Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:18:21 +1000
Subject: [PATCH 27/52] ManageDisplayTest

---
 .../tests/src/FunctionalJavascript/ManageDisplayTest.php         | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
index e076b57ceba9..f8ff9c55e634 100644
--- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
+++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
@@ -376,6 +376,7 @@ public function testWidgetUI(): void {
     $assert_session->assertWaitOnAjaxRequest();
 
     $button_save->click();
+    $assert_session->waitForDocumentReady();
     $this->drupalGet($manage_display);
 
     // Assert the third party settings.
-- 
GitLab


From c866bb1c8edf7d8cbb64681c5f0651ffee4a1b5a Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:20:05 +1000
Subject: [PATCH 28/52] LayoutBuilderTest

---
 .../tests/src/FunctionalJavascript/LayoutBuilderTest.php         | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
index 3e5becf7622a..6441e02c943b 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
@@ -189,6 +189,7 @@ public function testLayoutBuilderUi(): void {
 
     // Ensure the dragged block is still in the correct position after save.
     $page->pressButton('Save layout');
+    $assert_session->waitForDocumentReady();
     $assert_session->elementExists('css', '.layout__region--second .block-system-powered-by-block');
     $assert_session->elementTextContains('css', '.layout__region--second', 'Powered by Drupal');
 
-- 
GitLab


From 1e186867398c20cc8c4e925ec30c282f17181f36 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:25:26 +1000
Subject: [PATCH 29/52] ContextualLinkClickTrait

---
 .../tests/src/FunctionalJavascript/ContextualLinkClickTrait.php  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php
index b6b62dbddd2c..55eba1c55e25 100644
--- a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php
+++ b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinkClickTrait.php
@@ -32,6 +32,7 @@ protected function clickContextualLink($selector, $link_locator, $force_visible
     $element = $this->getSession()->getPage()->find('css', $selector);
     $element->find('css', '.contextual button')->press();
     $element->findLink($link_locator)->click();
+    $this->assertSession()->waitForDocumentReady();
 
     if ($force_visible) {
       $this->toggleContextualTriggerVisibility($selector);
-- 
GitLab


From d34d7331b5b3963ab87c5276fb75950a67f087d7 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:25:32 +1000
Subject: [PATCH 30/52] LayoutBuilderDisableInteractionsTest

---
 .../LayoutBuilderDisableInteractionsTest.php                     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
index 4067edd2616a..54e5b3fcde6d 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -129,6 +129,7 @@ public function testFormsLinksDisabled(): void {
     $this->assertLinksFormIframeNotInteractive();
 
     $page->pressButton('Save layout');
+    $assert_session->waitForDocumentReady();
     $this->clickLink('Manage layout');
 
     // Ensure the links and forms are disabled using the defaults.
-- 
GitLab


From 19370be1d7fbe13aad7f0781698bb06398e9b87a Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:37:41 +1000
Subject: [PATCH 31/52] MediaReferenceFieldHelpTest

---
 .../src/FunctionalJavascript/MediaReferenceFieldHelpTest.php  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php
index be1e173d6d28..e17e45817705 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaReferenceFieldHelpTest.php
@@ -50,8 +50,10 @@ public function testFieldCreationHelpText(): void {
     $assert_session->elementExists('css', "[name='new_storage_type'][value='boolean']");
     $page->find('css', "[name='new_storage_type'][value='boolean']")->getParent()->click();
     $page->pressButton('Continue');
+    $assert_session->waitForDocumentReady();
     $assert_session->pageTextNotContains($help_text);
     $page->pressButton('Back');
+    $assert_session->waitForDocumentReady();
 
     // Select each of the Reference, File upload field groups and verify their
     // descriptions are now visible and match the expected text.
@@ -60,8 +62,10 @@ public function testFieldCreationHelpText(): void {
       $page->find('css', "[name='new_storage_type'][value='$field_group']")->getParent()->click();
 
       $page->pressButton('Continue');
+      $assert_session->waitForDocumentReady();
       $assert_session->pageTextContains($help_text);
       $page->pressButton('Back');
+      $assert_session->waitForDocumentReady();
     }
   }
 
-- 
GitLab


From 31f06ab5bc018115034b743cb3ad46ea8cc27f1f Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:37:47 +1000
Subject: [PATCH 32/52] MediaTypeCreationTest

---
 .../tests/src/FunctionalJavascript/MediaTypeCreationTest.php     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
index f43b4a6018c7..dddb52aa5503 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaTypeCreationTest.php
@@ -52,6 +52,7 @@ public function testSourceChangeOnMediaTypeCreationForm(): void {
     );
 
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     // Check that source can not be changed anymore.
     $this->drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}");
-- 
GitLab


From f235b3c58ffe464b1d2f551ace34b886cffbf42d Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:45:44 +1000
Subject: [PATCH 33/52] CKEditor5Test

---
 .../ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php  | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
index 38e3acb59821..930e67e429cf 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
@@ -537,6 +537,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');
+    $assert_session->waitForDocumentReady();
 
     $this->addNewTextFormat();
 
@@ -548,6 +549,7 @@ public function testEmphasis(): void {
     $this->assertNotEmpty($assert_session->waitForElement('css', '.ck-editor'));
     $page->pressButton('Save');
 
+    $assert_session->waitForDocumentReady();
     $assert_session->responseContains('<p>This is a <em>test!</em></p>');
   }
 
-- 
GitLab


From 5ae2452432eb581f93f6445247aec230a2123818 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 15:58:15 +1000
Subject: [PATCH 34/52] toolbarTest.js

---
 .../tests/src/Nightwatch/Tests/toolbarTest.js     | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
index cbba417abe3a..d3db004220a2 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
@@ -109,10 +109,9 @@ module.exports = {
       'open',
     );
     browser.click('#toolbar-item-administration-tray li:nth-child(2) button');
-    browser.assert.hasClass(
-      '#toolbar-item-administration-tray li:nth-child(2)',
-      'open',
-    );
+    browser.waitForElementPresent(
+      '#toolbar-item-administration-tray li:nth-child(2).open'
+    )
     browser.assert.hasClass(
       '#toolbar-item-administration-tray li:nth-child(2) button',
       'open',
@@ -138,10 +137,9 @@ module.exports = {
     browser.click(
       '#toolbar-item-administration-tray li.menu-item.level-2 button',
     );
-    browser.assert.hasClass(
-      '#toolbar-item-administration-tray li.menu-item.level-2',
-      'open',
-    );
+    browser.waitForElementPresent(
+      '#toolbar-item-administration-tray li.menu-item.level-2.open'
+    )
     browser.assert.hasClass(
       '#toolbar-item-administration-tray li.menu-item.level-2 button',
       'open',
@@ -189,6 +187,7 @@ module.exports = {
     browser.drupalRelativeURL('/admin');
     // Don't check the visibility as stark doesn't add the .path-admin class
     // to the <body> required to display the button.
+    browser.waitForElementPresent(escapeSelector);
     browser.assert.attributeContains(escapeSelector, 'href', '/user/2');
   },
   'Aural view test: tray orientation': (browser) => {
-- 
GitLab


From 6760aca4545604d52f892fcc1e55e8061f179b7c Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 16:01:25 +1000
Subject: [PATCH 35/52] MediaSourceTestBase

---
 .../tests/src/FunctionalJavascript/MediaSourceTestBase.php      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceTestBase.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceTestBase.php
index ba73eb8fe13f..e754eade1696 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceTestBase.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceTestBase.php
@@ -147,7 +147,7 @@ public function doTestCreateMediaType($media_type_id, $source_id, array $provide
 
     // Save the form to create the type.
     $page->pressButton('Save');
-    $assert_session->pageTextContains('The media type ' . $media_type_id . ' has been added.');
+    $this->assertTrue($assert_session->waitForText('The media type ' . $media_type_id . ' has been added.'));
     $this->drupalGet('admin/structure/media');
     $assert_session->pageTextContains($media_type_id);
 
-- 
GitLab


From 3c55be3b226d1cb12d08ed56de71c037ac2025d6 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 16:02:23 +1000
Subject: [PATCH 36/52] BulkOperationsTest

---
 .../tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/views/tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php b/core/modules/views/tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php
index fb6bcab6de73..5ae8a4ee35d8 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/Plugin/BulkOperationsTest.php
@@ -76,6 +76,7 @@ public function testBulkOperations(): void {
     $this->assertSession()->pageTextContains($node_1->getTitle());
     $this->assertSession()->pageTextNotContains($node_2->getTitle());
     $this->getSession()->getPage()->pressButton('Delete');
+    $this->assertSession()->waitForDocumentReady();
 
     // Confirm that the first node was deleted.
     $this->assertSession()->pageTextNotContains($node_1->getTitle());
-- 
GitLab


From f6e7ee12567ba918cd228e80bc45fc8658715f76 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 16:03:04 +1000
Subject: [PATCH 37/52] ResponsiveImageFieldUiTest

---
 .../src/FunctionalJavascript/ResponsiveImageFieldUiTest.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/modules/responsive_image/tests/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php b/core/modules/responsive_image/tests/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php
index 8093b37bd4a2..bd45ec84b7b9 100644
--- a/core/modules/responsive_image/tests/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php
+++ b/core/modules/responsive_image/tests/src/FunctionalJavascript/ResponsiveImageFieldUiTest.php
@@ -91,7 +91,7 @@ public function testResponsiveImageFormatterUi(): void {
     $this->assertEquals('Select a responsive image style. Loading attribute: lazy', $summary_text->getText());
 
     $page->pressButton('Save');
-    $assert_session->responseContains("Select a responsive image style.");
+    $this->assertTrue($assert_session->waitForText("Select a responsive image style."));
 
     // Create responsive image styles.
     $responsive_image_style = ResponsiveImageStyle::create([
@@ -141,7 +141,7 @@ public function testResponsiveImageFormatterUi(): void {
     // Save the form to save the settings.
     $page->pressButton('Save');
 
-    $assert_session->responseContains('Responsive image style: Style One');
+    $this->assertTrue($assert_session->waitForText('Responsive image style: Style One'));
     $assert_session->responseContains('Linked to content');
 
     $page->find('css', '#edit-fields-field-image-settings-edit')->click();
@@ -151,7 +151,7 @@ public function testResponsiveImageFormatterUi(): void {
     // Save the form to save the settings.
     $page->pressButton('Save');
 
-    $assert_session->responseContains('Responsive image style: Style One');
+    $this->assertTrue($assert_session->waitForText('Responsive image style: Style One'));
     $assert_session->responseContains('Linked to file');
   }
 
-- 
GitLab


From fdbd31bd2a30b2ef0027a3d5a0fcd3728e3515b7 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 16:03:31 +1000
Subject: [PATCH 38/52] ManageDisplayTest

---
 .../tests/src/FunctionalJavascript/ManageDisplayTest.php        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
index f8ff9c55e634..fe990235a956 100644
--- a/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
+++ b/core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php
@@ -174,7 +174,7 @@ public function testFormatterUI(): void {
     // Submit the form and assert that
     // hook_field_formatter_settings_summary_alter() is called.
     $button_save->click();
-    $assert_session->responseContains('field_test_field_formatter_settings_summary_alter');
+    $this->assertTrue($assert_session->waitForText('field_test_field_formatter_settings_summary_alter'));
 
     // Open the settings form for the test field.
     $field_test_settings->click();
-- 
GitLab


From b809c1334fb1f2e316d48615c17fcc739a3e957e Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Tue, 25 Mar 2025 16:09:39 +1000
Subject: [PATCH 39/52] lint

---
 .../toolbar/tests/src/Nightwatch/Tests/toolbarTest.js     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
index d3db004220a2..c670390ed363 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
@@ -110,8 +110,8 @@ module.exports = {
     );
     browser.click('#toolbar-item-administration-tray li:nth-child(2) button');
     browser.waitForElementPresent(
-      '#toolbar-item-administration-tray li:nth-child(2).open'
-    )
+      '#toolbar-item-administration-tray li:nth-child(2).open',
+    );
     browser.assert.hasClass(
       '#toolbar-item-administration-tray li:nth-child(2) button',
       'open',
@@ -138,8 +138,8 @@ module.exports = {
       '#toolbar-item-administration-tray li.menu-item.level-2 button',
     );
     browser.waitForElementPresent(
-      '#toolbar-item-administration-tray li.menu-item.level-2.open'
-    )
+      '#toolbar-item-administration-tray li.menu-item.level-2.open',
+    );
     browser.assert.hasClass(
       '#toolbar-item-administration-tray li.menu-item.level-2 button',
       'open',
-- 
GitLab


From d7dc8645880a747112824e08c246d4827126130b Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 07:55:05 +1000
Subject: [PATCH 40/52] CKEditor5Test

---
 .../tests/src/FunctionalJavascript/CKEditor5Test.php          | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
index 930e67e429cf..d139ade4b829 100644
--- a/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
+++ b/core/modules/ckeditor5/tests/src/FunctionalJavascript/CKEditor5Test.php
@@ -717,7 +717,7 @@ function (ConstraintViolationInterface $v) {
     $editor = $page->find('css', '.ck-content');
     $editor->setValue('Very important information');
     $page->pressButton('Save');
-    $this->assertSession()->responseContains('Very important information');
+    $this->assertTrue($this->assertSession()->waitForText('Very important information'));
 
     // Test that changes only in source are saved.
     $this->drupalGet('node/1/edit');
@@ -727,7 +727,7 @@ function (ConstraintViolationInterface $v) {
     $editor = $page->find('css', '.ck-source-editing-area textarea');
     $editor->setValue('Text hidden in the source');
     $page->pressButton('Save');
-    $this->assertSession()->responseContains('Text hidden in the source');
+    $this->assertTrue($this->assertSession()->waitForText('Text hidden in the source'));
   }
 
 }
-- 
GitLab


From c7b4c7f7538eacbffeab41d110571575befbefa6 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 08:27:00 +1000
Subject: [PATCH 41/52] LayoutBuilderTest

---
 .../tests/src/FunctionalJavascript/LayoutBuilderTest.php   | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
index 6441e02c943b..576b31b71894 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderTest.php
@@ -152,6 +152,7 @@ public function testLayoutBuilderUi(): void {
 
     // Save the layout, and the new block is visible.
     $page->pressButton('Save layout');
+    $this->assertSession()->waitForDocumentReady();
     $assert_session->addressEquals($node_url);
     $assert_session->pageTextContains('Powered by Drupal');
     $assert_session->pageTextContains('This is the label');
@@ -189,8 +190,7 @@ public function testLayoutBuilderUi(): void {
 
     // Ensure the dragged block is still in the correct position after save.
     $page->pressButton('Save layout');
-    $assert_session->waitForDocumentReady();
-    $assert_session->elementExists('css', '.layout__region--second .block-system-powered-by-block');
+    $this->assertNotNull($assert_session->waitForElement('css', '.layout__region--second .block-system-powered-by-block'));
     $assert_session->elementTextContains('css', '.layout__region--second', 'Powered by Drupal');
 
     // Reconfigure a block and ensure that the layout content is updated.
@@ -225,7 +225,7 @@ public function testLayoutBuilderUi(): void {
     $this->assertPageNotReloaded();
 
     $page->pressButton('Save layout');
-    $assert_session->elementExists('css', '.layout');
+    $this->assertNotNull($assert_session->waitForElement('css', '.layout'));
 
     // Test deriver-based blocks.
     $this->drupalGet($layout_url);
@@ -258,6 +258,7 @@ public function testLayoutBuilderUi(): void {
     $page->pressButton('Save layout');
 
     // Removing all sections results in no layout being used.
+    $assert_session->waitForDocumentReady();
     $assert_session->addressEquals($node_url);
     $assert_session->elementNotExists('css', '.layout');
     $assert_session->pageTextNotContains('The node body');
-- 
GitLab


From b248a0341371223631a32a39080e1a18ea3ddab3 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 08:29:41 +1000
Subject: [PATCH 42/52] LayoutBuilderUiTest

---
 .../tests/src/FunctionalJavascript/LayoutBuilderUiTest.php       | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
index ddc34c60d2e1..4e26e9c0ba61 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderUiTest.php
@@ -99,6 +99,7 @@ public function testUnsavedChangesMessage(): void {
     $this->assertModifiedLayout(static::FIELD_UI_PREFIX . '/display/default/layout');
     // Discard then cancel.
     $page->pressButton('Discard changes');
+    $assert_session->waitForDocumentReady();
     $page->clickLink('Cancel');
     $assert_session->addressEquals(static::FIELD_UI_PREFIX . '/display/default/layout');
     $assert_session->pageTextContainsOnce('You have unsaved changes.');
-- 
GitLab


From 2363cfc8f8a696f74e54af28535ce487fb85bc10 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 08:39:35 +1000
Subject: [PATCH 43/52] MenuUiJavascriptTest

---
 .../tests/src/FunctionalJavascript/MenuUiJavascriptTest.php    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php b/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
index a174b7a33c1f..332cc760acb6 100644
--- a/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
+++ b/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
@@ -90,6 +90,7 @@ protected function addCustomMenu() {
     // Try to fill a text longer than the allowed limit.
     $page->fillField('Menu name', $menu_id);
     $page->pressButton('Save');
+    $this->assertSession()->waitForDocumentReady();
     // Check that the menu was saved with the ID truncated to the max length.
     $menu = Menu::load(substr($menu_id, 0, MenuStorage::MAX_ID_LENGTH));
     $this->assertEquals($label, $menu->label());
@@ -145,7 +146,7 @@ protected function addMenuLink($parent = '', $path = '/', $menu_id = 'tools', $e
 
     // Add menu link.
     $this->submitForm($edit, 'Save');
-    $this->assertSession()->pageTextContains('The menu link has been saved.');
+    $this->assertTrue($this->assertSession()->waitForText('The menu link has been saved.'));
 
     $storage = $this->container->get('entity_type.manager')->getStorage('menu_link_content');
     $menu_links = $storage->loadByProperties(['title' => $title]);
-- 
GitLab


From bef57a500dc25986cd0c71cc0ce4e4910bdff782 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 08:44:26 +1000
Subject: [PATCH 44/52] MediaEmbedFilterConfigurationUiEditTest

---
 .../MediaEmbedFilterConfigurationUiEditTest.php                  | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiEditTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiEditTest.php
index bcc62c736216..c0e92860a59b 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiEditTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaEmbedFilterConfigurationUiEditTest.php
@@ -45,6 +45,7 @@ public function testValidationWhenEditing($filter_html_status, $filter_align_sta
       $page->fillField('filters[filter_html][settings][allowed_html]', $allowed_html);
     }
     $page->pressButton('Save configuration');
+    $this->assertSession()->waitForDocumentReady();
 
     if ($expected_error_message) {
       $this->assertSession()->pageTextNotContains('The text format Test format has been updated.');
-- 
GitLab


From cd0c1fb054591e73ca2b798edda0ba2cab6cecda Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 09:03:18 +1000
Subject: [PATCH 45/52] MediaSourceFileTest

---
 .../tests/src/FunctionalJavascript/MediaSourceFileTest.php    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceFileTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceFileTest.php
index dfb784ba073f..2ad9a0a71c1d 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceFileTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceFileTest.php
@@ -52,6 +52,7 @@ public function testMediaFileSource(): void {
     $page->selectFieldOption("field_map[" . File::METADATA_ATTRIBUTE_SIZE . "]", 'field_string_file_size');
     $page->selectFieldOption("field_map[" . File::METADATA_ATTRIBUTE_MIME . "]", 'field_string_mime_type');
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $test_filename = $this->randomMachineName() . '.txt';
     $test_filepath = 'public://' . $test_filename;
@@ -63,6 +64,7 @@ public function testMediaFileSource(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
 
     $assert_session->addressEquals('admin/content/media');
 
@@ -95,6 +97,7 @@ public function testMediaFileSource(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     $assert_session->elementAttributeContains('css', 'img', 'src', 'text--plain.png');
 
     // Check if the mapped name is automatically updated.
@@ -109,6 +112,7 @@ public function testMediaFileSource(): void {
     $result = $assert_session->waitForButton('Remove');
     $this->assertNotEmpty($result);
     $page->pressButton('Save');
+    $assert_session->waitForDocumentReady();
     /** @var \Drupal\media\MediaInterface $media */
     $media = \Drupal::entityTypeManager()->getStorage('media')->loadUnchanged(1);
     $this->assertEquals($new_filename, $media->getName());
-- 
GitLab


From defb6c14948d0cd71627eec5ccb32eaa2c2b8c13 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 10:45:19 +1000
Subject: [PATCH 46/52] Use outerHeight instead of inner

---
 .../FunctionalJavascriptTests/BrowserWithJavascriptTest.php     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php b/core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
index 2f11f7525eed..3912700e8b49 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
@@ -35,7 +35,7 @@ public function testJavascript(): void {
         e = d.documentElement,
         g = d.getElementsByTagName('body')[0],
         x = w.innerWidth || e.clientWidth || g.clientWidth,
-        y = w.innerHeight || e.clientHeight|| g.clientHeight;
+        y = w.outerHeight || e.clientHeight|| g.clientHeight;
         return x == 400 && y == 300;
     }())
 JS;
-- 
GitLab


From 1a2c117609946778d72c698adefffaf23b6b771d Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 10:45:38 +1000
Subject: [PATCH 47/52] Remove Chromedriver workaround

---
 .../LayoutBuilderDisableInteractionsTest.php                  | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
index 54e5b3fcde6d..febf516a0ef8 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -97,10 +97,6 @@ protected function setUp(): void {
    * Tests that forms and links are disabled in the Layout Builder preview.
    */
   public function testFormsLinksDisabled(): void {
-    // Resize window due to bug in Chromedriver when clicking on overlays over
-    // iFrames.
-    // @see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758
-    $this->getSession()->resizeWindow(1200, 1200);
     $assert_session = $this->assertSession();
     $page = $this->getSession()->getPage();
 
-- 
GitLab


From 104ef87767672218839ebb76605ab82369962760 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 11:00:14 +1000
Subject: [PATCH 48/52] Restore chromedriver workaround, but increase height to
 accommodate toolbars

---
 .../LayoutBuilderDisableInteractionsTest.php                  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
index febf516a0ef8..6d62cd8ad458 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderDisableInteractionsTest.php
@@ -97,6 +97,10 @@ protected function setUp(): void {
    * Tests that forms and links are disabled in the Layout Builder preview.
    */
   public function testFormsLinksDisabled(): void {
+    // Resize window due to bug in Chromedriver when clicking on overlays over
+    // iFrames.
+    // @see https://bugs.chromium.org/p/chromedriver/issues/detail?id=2758
+    $this->getSession()->resizeWindow(1200, 1339);
     $assert_session = $this->assertSession();
     $page = $this->getSession()->getPage();
 
-- 
GitLab


From 0b00ae37ed0286dbde0ec025eb9b0b5d458e0eb5 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 12:40:17 +1000
Subject: [PATCH 49/52] =?UTF-8?q?Resize=20the=20browser=20in=20order=20to?=
 =?UTF-8?q?=20grant=20permissions=20=F0=9F=99=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
index c670390ed363..cd4d1ea1ad48 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
@@ -14,6 +14,8 @@ module.exports = {
   '@tags': ['core'],
   before(browser) {
     browser
+      // We need to resize the browser in order to grant permissions.
+      .setWindowSize(1024, 768)
       .drupalInstall()
       .drupalInstallModule('toolbar', true)
       .drupalCreateUser({
-- 
GitLab


From 166e769e38e6ead02621988172bb94447fc96e61 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 12:56:13 +1000
Subject: [PATCH 50/52] Resize the browser in drupalCreateRole instead

---
 core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js | 2 --
 core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js      | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
index cd4d1ea1ad48..c670390ed363 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
@@ -14,8 +14,6 @@ module.exports = {
   '@tags': ['core'],
   before(browser) {
     browser
-      // We need to resize the browser in order to grant permissions.
-      .setWindowSize(1024, 768)
       .drupalInstall()
       .drupalInstallModule('toolbar', true)
       .drupalCreateUser({
diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
index 2a81a8cd53f3..512699bc1c18 100644
--- a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
+++ b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
@@ -43,6 +43,9 @@ exports.command = function drupalCreateRole(
       'table.permissions',
     );
 
+    // We need to resize the browser in order to grant permissions.
+    browser.resizeWindow(1024, 768);
+
     await Promise.all(
       permissions.map(async (permission) =>
         this.click(`input[name="${machineName}[${permission}]"]`),
-- 
GitLab


From cc46035a53c68eda938ce89690ddeb0b02102970 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 13:21:52 +1000
Subject: [PATCH 51/52] eslint

---
 core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
index 512699bc1c18..c180a0d4d89a 100644
--- a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
+++ b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
@@ -44,6 +44,7 @@ exports.command = function drupalCreateRole(
     );
 
     // We need to resize the browser in order to grant permissions.
+    // eslint-disable-next-line no-undef
     browser.resizeWindow(1024, 768);
 
     await Promise.all(
-- 
GitLab


From 76b54887a870e913dede3c8c204ddb2db7e37bd9 Mon Sep 17 00:00:00 2001
From: Michael Strelan <mstrelan@gmail.com>
Date: Wed, 26 Mar 2025 13:22:53 +1000
Subject: [PATCH 52/52] Use `this` not `browser`

---
 core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
index c180a0d4d89a..82dd9b60597a 100644
--- a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
+++ b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js
@@ -44,8 +44,7 @@ exports.command = function drupalCreateRole(
     );
 
     // We need to resize the browser in order to grant permissions.
-    // eslint-disable-next-line no-undef
-    browser.resizeWindow(1024, 768);
+    this.resizeWindow(1024, 768);
 
     await Promise.all(
       permissions.map(async (permission) =>
-- 
GitLab