Skip to content

Commit 69ffd8f

Browse files
authored
Merge pull request #59 from mvorisek/test_droppable_hidden_itself
Test drop onto itself and hide when dragging
2 parents 2ef2bff + be3bd8e commit 69ffd8f

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

tests/Js/JavascriptTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,20 @@ public function testDragDrop():void
2727
$droppable = $webAssert->elementExists('css', '#droppable');
2828

2929
$draggable->dragTo($droppable);
30-
$this->assertEquals('Dropped!', $this->getAssertSession()->elementExists('css', 'p', $droppable)->getText());
30+
$this->assertSame('Dropped left!', $webAssert->elementExists('css', 'p', $droppable)->getText());
31+
}
32+
33+
// https://github.com/minkphp/MinkSelenium2Driver/pull/359
34+
public function testDragDropOntoHiddenItself()
35+
{
36+
$this->getSession()->visit($this->pathTo('/js_test.html'));
37+
$webAssert = $this->getAssertSession();
38+
39+
$draggable = $webAssert->elementExists('css', '#draggable2');
40+
$droppable = $webAssert->elementExists('css', '#draggable2');
41+
42+
$draggable->dragTo($droppable);
43+
$this->assertSame('Dropped small!', $webAssert->elementExists('css', '#droppable p')->getText());
3144
}
3245

3346
// test accentuated char in button

web-fixtures/js_test.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
background:#ccc;
1111
opacity:0.5;
1212
}
13+
#draggable2 {
14+
width: 50px; height: 50px; position: absolute; padding: 0.5em; top: 150px; left: 220px;
15+
background:#aaa;
16+
opacity:0.5;
17+
}
1318
#droppable {
1419
width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px;
1520
background:#eee;
@@ -32,7 +37,9 @@
3237
<div class="text-event"></div>
3338
</div>
3439

35-
<div id="draggable" class="ui-widget-content"></div>
40+
<div id="draggable" class="ui-widget-content" data-name="left"></div>
41+
42+
<div id="draggable2" class="ui-widget-content" data-name="small"></div>
3643

3744
<div id="droppable" class="ui-widget-header">
3845
<p>Drop here</p>
@@ -85,9 +92,18 @@
8592
});
8693

8794
$( "#draggable" ).draggable();
95+
$( "#draggable2" ).draggable({
96+
distance: 0,
97+
start: function() {
98+
$( this ).css('visibility', 'hidden');
99+
},
100+
stop: function() {
101+
$( this ).css('visibility', '');
102+
}
103+
});
88104
$( "#droppable" ).droppable({
89105
drop: function( event, ui ) {
90-
$( this ).find( "p" ).html( "Dropped!" );
106+
$( this ).find( "p" ).html( 'Dropped ' + ui.draggable.data('name') + '!' );
91107
}
92108
});
93109

0 commit comments

Comments
 (0)