From 6da04293d09093118e6f6f99847475d11adb7a68 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 29 Sep 2023 15:08:47 +0100
Subject: [PATCH] Issue #3387772 by Spokje: [random test failure] Random
 failure in ThrobberTest::testProgressThrobberPosition

---
 .../Ajax/ThrobberTest.php                     | 35 ++++++-------------
 1 file changed, 11 insertions(+), 24 deletions(-)

diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
index eb66398b572a..77e68d21ec0b 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
@@ -28,18 +28,6 @@ class ThrobberTest extends WebDriverTestBase {
    */
   protected $defaultTheme = 'stark';
 
-  /**
-   * {@inheritdoc}
-   */
-  protected function setUp(): void {
-    parent::setUp();
-
-    $admin_user = $this->drupalCreateUser([
-      'administer views',
-    ]);
-    $this->drupalLogin($admin_user);
-  }
-
   /**
    * Tests theming throbber element.
    */
@@ -47,6 +35,11 @@ public function testThemingThrobberElement() {
     $session = $this->getSession();
     $web_assert = $this->assertSession();
     $page = $session->getPage();
+    $admin_user = $this->drupalCreateUser([
+      'administer views',
+      'administer blocks',
+    ]);
+    $this->drupalLogin($admin_user);
 
     $custom_ajax_progress_indicator_fullscreen = <<<JS
       Drupal.theme.ajaxProgressIndicatorFullscreen = function () {
@@ -92,23 +85,17 @@ public function testThemingThrobberElement() {
     $this->assertNotNull($web_assert->waitForElement('css', '.custom-ajax-progress-throbber'), 'Custom ajaxProgressThrobber.');
     hold_test_response(FALSE);
     $web_assert->assertNoElementAfterWait('css', '.custom-ajax-progress-throbber');
-  }
-
-  /**
-   * Tests progress throbber element position.
-   */
-  public function testProgressThrobberPosition() {
-    $this->drupalLogin($this->rootUser);
 
+    // Test progress throbber position on a dropbutton in a table display.
     $this->drupalGet('/admin/structure/block');
     $this->clickLink('Place block');
-    hold_test_response(FALSE);
-    $this->assertSession()->waitForText('Place Block');
-    $this->clickLink('Place block');
+    $web_assert->assertWaitOnAjaxRequest();
+    $this->assertNotEmpty($web_assert->waitForElementVisible('css', '#drupal-modal'));
     hold_test_response(TRUE);
-    $this->assertSession()->elementExists('xpath', '//div[contains(@class, "dropbutton-wrapper")]/following-sibling::div[contains(@class, "ajax-progress-throbber")]');
+    $this->clickLink('Place block');
+    $this->assertNotNull($web_assert->waitForElement('xpath', '//div[contains(@class, "dropbutton-wrapper")]/following-sibling::div[contains(@class, "ajax-progress-throbber")]'));
     hold_test_response(FALSE);
-    $this->assertSession()->assertNoElementAfterWait('css', '.ajax-progress-throbber');
+    $web_assert->assertNoElementAfterWait('css', '.ajax-progress-throbber');
   }
 
 }
-- 
GitLab