diff --git a/tests/Js/JavascriptTest.php b/tests/Js/JavascriptTest.php index 36e9846..8892fdd 100644 --- a/tests/Js/JavascriptTest.php +++ b/tests/Js/JavascriptTest.php @@ -27,7 +27,20 @@ public function testDragDrop() $droppable = $webAssert->elementExists('css', '#droppable'); $draggable->dragTo($droppable); - $this->assertEquals('Dropped!', $this->getAssertSession()->elementExists('css', 'p', $droppable)->getText()); + $this->assertSame('Dropped left!', $webAssert->elementExists('css', 'p', $droppable)->getText()); + } + + // https://github.com/minkphp/MinkSelenium2Driver/pull/359 + public function testDragDropOntoHiddenItself() + { + $this->getSession()->visit($this->pathTo('/js_test.html')); + $webAssert = $this->getAssertSession(); + + $draggable = $webAssert->elementExists('css', '#draggable2'); + $droppable = $webAssert->elementExists('css', '#draggable2'); + + $draggable->dragTo($droppable); + $this->assertSame('Dropped small!', $webAssert->elementExists('css', '#droppable p')->getText()); } // test accentuated char in button diff --git a/web-fixtures/js_test.html b/web-fixtures/js_test.html index b902534..35db3d0 100644 --- a/web-fixtures/js_test.html +++ b/web-fixtures/js_test.html @@ -10,6 +10,11 @@ background:#ccc; opacity:0.5; } + #draggable2 { + width: 50px; height: 50px; position: absolute; padding: 0.5em; top: 150px; left: 220px; + background:#aaa; + opacity:0.5; + } #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; background:#eee; @@ -32,7 +37,9 @@
-
+
+ +

Drop here

@@ -85,9 +92,18 @@ }); $( "#draggable" ).draggable(); + $( "#draggable2" ).draggable({ + distance: 0, + start: function() { + $( this ).css('visibility', 'hidden'); + }, + stop: function() { + $( this ).css('visibility', ''); + } + }); $( "#droppable" ).droppable({ drop: function( event, ui ) { - $( this ).find( "p" ).html( "Dropped!" ); + $( this ).find( "p" ).html( 'Dropped ' + ui.draggable.data('name') + '!' ); } });