From 14c499fc7a9e74e1caaa01c586d8b512a3ef2db8 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Wed, 17 Jan 2018 11:40:43 +0000
Subject: [PATCH] Issue #2934997 by benjifisher, Lendude, xjm: Intermittent
 failure in MediaUiJavascriptTest

---
 .../src/FunctionalJavascript/MediaUiJavascriptTest.php    | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
index 4854a5f0e34b..0116305771e7 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaUiJavascriptTest.php
@@ -63,6 +63,10 @@ public function testMediaTypes() {
     $this->assertJsCondition("jQuery('.form-item-source-configuration-test-config-value').length > 0;");
     $page->fillField('description', $description);
     $page->pressButton('Save');
+    // The wait prevents intermittent test failures.
+    $result = $assert_session->waitForLink('Add media type');
+    $this->assertNotEmpty($result);
+    $assert_session->addressEquals('admin/structure/media');
     $assert_session->pageTextContains('The media type ' . $name . ' has been added.');
     $this->drupalGet('admin/structure/media');
     $assert_session->pageTextContains($name);
@@ -134,6 +138,10 @@ public function testMediaTypes() {
     $page->uncheckField('options[status]');
     $page->checkField('options[queue_thumbnail_downloads]');
     $page->pressButton('Save');
+    // The wait prevents intermittent test failures.
+    $result = $assert_session->waitForLink('Add media type');
+    $this->assertNotEmpty($result);
+    $assert_session->addressEquals('admin/structure/media');
     $assert_session->pageTextContains("The media type $new_name has been updated.");
 
     // Test if edit worked and if new field values have been saved as expected.
-- 
GitLab