From b200582f81cdb7f29e61bbfdba0af5b6bf90d591 Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Sun, 28 Jul 2024 09:02:38 +0900
Subject: [PATCH] Issue #3463594 by alexpott:
 ImageAdminStylesTest::testAjaxEnabledEffectForm() fails because
 statusMessageExists() does not wait

(cherry picked from commit 6a0c12a63515c02ef0b4e8190a7275252c6d1884)
---
 .../FunctionalJavascriptTests/JSWebAssert.php | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
index b1a083f65a24..1d5f9aa2e54e 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
@@ -726,4 +726,25 @@ private function buildJavascriptStatusMessageSelector(?string $message = NULL, ?
     return $this->buildStatusMessageSelector($message, $type) . ' | ' . $js_selector;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function statusMessageContains(string $message, ?string $type = NULL): void {
+    $selector = $this->buildStatusMessageSelector($message, $type);
+    $this->waitForElement('xpath', $selector);
+    parent::statusMessageContains($message, $type);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function statusMessageNotContains(string $message, ?string $type = NULL): void {
+    $selector = $this->buildStatusMessageSelector($message, $type);
+    // Wait for a second for the message to not exist.
+    $this->waitForHelper(1000, function (Element $page) use ($selector) {
+      return !$page->find('xpath', $selector);
+    });
+    parent::statusMessageNotContains($message, $type);
+  }
+
 }
-- 
GitLab