Skip to content

Commit

Permalink
Merge pull request #59 from mvorisek/test_droppable_hidden_itself
Browse files Browse the repository at this point in the history
Test drop onto itself and hide when dragging
  • Loading branch information
stof authored Apr 1, 2024
2 parents 2ef2bff + be3bd8e commit 69ffd8f
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():void
$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()

Check failure on line 34 in tests/Js/JavascriptTest.php

View workflow job for this annotation

GitHub Actions / Static analysis

Method Behat\Mink\Tests\Driver\Js\JavascriptTest::testDragDropOntoHiddenItself() has no return type specified.
{
$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 69ffd8f

Please sign in to comment.