Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test drop onto itself and hide when dragging #59

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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