capybara
capybara copied to clipboard
Add `dragenter` event and test to `drag_to`
Fire a dragenter
event before the two dragover
events.
The spec requires a dragenter
event to be fired first:
To accept a drop, the drop target has to listen to at least three events. First, the dragenter event, which is used to determine whether or not the drop target is to accept the drop.
Addresses #2576
This is my first code contribution and I'm much more comfortable in Ruby than JavaScript so please let me know if I've done this badly or misunderstood the JavaScript side of things!
Perhaps also add a test that verifies that the dragenter
is dispatched before the dragover
?
How about checking for both at the same time, @boris-petrov? Looks a bit ugly to me but since I need to check their order anyway, this finds the element in question then checks the dragover occurs next using preceding-sibling
Isn't it possible to do something like expect(page).to have_text(/DragEnter.*DragOver/)
?
That's much simpler! Events are listed in reverse chronological order...

It's not obvious reading the test and I couldn't think of a way to make it explicit in code so I added a comment. There's a similar comment on what's currently line 562
Whoops, now the test isn't passing. Bear with me 🙃
~Ugh, I'm trying to rebase against master, squash it all into a single commit and then force push to my branch but I clearly don't know what I'm doing~
Edit: Rebased and squashed to keep the history clean