Skip to content

Commit

Permalink
test drop onto itself and hide when dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 23, 2022
1 parent cfb0a8c commit 658ec41
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
15 changes: 14 additions & 1 deletion tests/Js/JavascriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions web-fixtures/js_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,7 +37,9 @@
<div class="text-event"></div>
</div>

<div id="draggable" class="ui-widget-content"></div>
<div id="draggable" class="ui-widget-content" data-name="left"></div>

<div id="draggable2" class="ui-widget-content" data-name="small"></div>

<div id="droppable" class="ui-widget-header">
<p>Drop here</p>
Expand Down Expand Up @@ -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') + '!' );
}
});

Expand Down

0 comments on commit 658ec41

Please sign in to comment.