From be3bd8e3abf5ed3a6e8e9d9c8d5b4c23d169a118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 23 Oct 2022 13:28:03 +0200 Subject: [PATCH] Test drop onto itself and hide when dragging --- tests/Js/JavascriptTest.php | 15 ++++++++++++++- web-fixtures/js_test.html | 20 ++++++++++++++++++-- 2 files changed, 32 insertions(+), 3 deletions(-) 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 b18047e..a1da4d6 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') + '!' ); } });