From 36f23abfa8680da123f1c01c48e3c3887bd76f2a Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Fri, 21 Mar 2025 16:54:20 +0000
Subject: [PATCH] Issue #3400150 by mstrelan, quietone: [random test failure]
 TimestampFormatterWithTimeDiffTest::testTimestampFormatterWithTimeDiff

---
 .../Core/Field/TimestampFormatterWithTimeDiffTest.php    | 9 ++++-----
 .../Field/TimestampFormatterWithTimeDiffViewsTest.php    | 7 +++----
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffTest.php
index 61e2506ffd58..92ce91803294 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffTest.php
@@ -88,7 +88,6 @@ protected function setUp(): void {
    * Tests the 'timestamp' formatter when is used with time difference setting.
    */
   public function testTimestampFormatterWithTimeDiff(): void {
-    $this->markTestSkipped("Skipped due to frequent random test failures. See https://www.drupal.org/project/drupal/issues/3400150");
     $this->drupalGet($this->entity->toUrl());
 
     // Unit testing Drupal.timeDiff.format(). Not using @dataProvider mechanism
@@ -120,15 +119,15 @@ public function testTimestampFormatterWithTimeDiff(): void {
     $time_diff = $time_element->getText();
     [$seconds_value] = explode(' ', $time_diff, 2);
 
-    // Wait at least 1 second + 1 millisecond to make sure that the last time
-    // difference value has been refreshed.
-    $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 1001);
+    // Wait up to 2 seconds to make sure that the last time difference value
+    // has been refreshed.
+    $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 2000);
     $time_diff = $time_element->getText();
     [$new_seconds_value] = explode(' ', $time_diff, 2);
     $this->assertGreaterThan($seconds_value, $new_seconds_value);
 
     // Once again.
-    $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 1001);
+    $this->assertJsCondition("document.getElementsByTagName('time')[0].textContent != '$time_diff'", 2000);
     $time_diff = $time_element->getText();
     $seconds_value = $new_seconds_value;
     [$new_seconds_value] = explode(' ', $time_diff, 2);
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffViewsTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffViewsTest.php
index 8441abd91d49..0b5176182390 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffViewsTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Field/TimestampFormatterWithTimeDiffViewsTest.php
@@ -36,7 +36,6 @@ class TimestampFormatterWithTimeDiffViewsTest extends WebDriverTestBase {
    * Tests the timestamp formatter used with time difference setting in views.
    */
   public function testTimestampFormatterWithTimeDiff(): void {
-    $this->markTestSkipped("Skipped due to frequent random test failures. See https://www.drupal.org/project/drupal/issues/3400150");
     ViewTestData::createTestViews(self::class, ['views_test_formatter']);
 
     $data = $this->getRowData();
@@ -67,9 +66,9 @@ public function testTimestampFormatterWithTimeDiff(): void {
       $this->assertMatchesRegularExpression($regex_pattern, $time_diff);
     }
 
-    // Wait at least 1 second + 1 millisecond to make sure the 'right now' time
-    // difference was refreshed.
-    $this->assertJsCondition("document.querySelector('.entity-$delta time').textContent >= '$time_diff'", 1001);
+    // Wait up to 2 seconds to make sure the 'right now' time difference was
+    // refreshed.
+    $this->assertJsCondition("document.querySelector('.entity-$delta time').textContent >= '$time_diff'", 2000);
   }
 
   /**
-- 
GitLab