From 579bedd7d2e5849389c42fe1964ef6c86eab27d6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?= Date: Sat, 16 May 2020 08:28:26 +0200 Subject: [PATCH] Tests: Solve a frequent race condition in tests in Chrome/Safari Closes gh-1916 --- tests/unit/sortable/options.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/unit/sortable/options.js b/tests/unit/sortable/options.js index d157d2b77..029b442be 100644 --- a/tests/unit/sortable/options.js +++ b/tests/unit/sortable/options.js @@ -372,7 +372,8 @@ test("{ placeholder: false }, default", function() { QUnit.test( "{ placeholder: false } img", function( assert ) { assert.expect( 3 ); - var element = $( "#sortable-images" ).sortable( { + var done = assert.async(), + element = $( "#sortable-images" ).sortable( { start: function( event, ui ) { assert.ok( ui.placeholder.attr( "src" ).indexOf( "images/jqueryui_32x32.png" ) > 0, "placeholder img has correct src" ); assert.equal( ui.placeholder.height(), 32, "placeholder has correct height" ); @@ -380,9 +381,14 @@ QUnit.test( "{ placeholder: false } img", function( assert ) { } } ); - element.find( "img" ).eq( 0 ).simulate( "drag", { - dy: 1 - } ); + // Give browsers some time to load the image if cache is disabled. + // This resolves a frequent issue in Chrome/Safari. + setTimeout( function() { + element.find( "img" ).eq( 0 ).simulate( "drag", { + dy: 1 + } ); + done(); + }, 500 ); } ); QUnit.test( "{ placeholder: String }", function( assert ) { -- 2.39.5