You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The events "dragstart" and "dragover" are emitted, but no "dragend" or "drop".
I copied a second test from this blog post that uses drag & drop with native javascript:
/**
* Playground test. Used for debugging.
* See https://reflect.run/articles/testing-drag-and-drop-workflows-using-cypress/
*/
describe("native dnd spec", () => {
it("should drag-and-drop C to A", () => {
cy.visit("https://simple-drag-drop.glitch.me/");
// to hold the data that is
// dragged during a drag-and-drop operation
const dataTransfer = new DataTransfer();
cy
// getting "A"
.get("div[draggable=true]")
.first()
// triggering the "dragstart" event to
// initialize the dataTransfer object
.trigger("dragstart", { dataTransfer });
cy
// getting "C"
.get("div[draggable=true]")
.eq(2)
// dropping "C" into the "A" position defined in dataTransfer
.trigger("drop", { dataTransfer });
// now "C" is in the first position, and you need
// to retrieve it again
cy
// getting "C"
.get("div[draggable=true]")
.first()
.trigger("dragend")
.then(() => {
// "A" should now be in the position of "C" and vice versa
cy.get("div[draggable=true]").then((elements) => {
cy.wrap(elements.text()).should("be.eq", "CBA");
});
});
});
});
This second test works:
The text was updated successfully, but these errors were encountered:
As a quick and dirty workaround, it seems to work when I force a mouse-up event after the initial drag. The only issue is that you can't then assert the success of the "drag and drop" action using its '.then((status) => {})' chained method.
e.g.:
cy.get(elementToDrag).drag(targetDropzone, {
target: { position: 'center' },
force: true
})
// Then add the below to force the end of the action
cy.get(targetDropzone).trigger('mouseup', { force: true })
Probably related to #18, but I created a new issue since the other is more the two years old.
Sometimes the event "dragend" or "drop" is not emitted. This means that the drag operation is not completed successfully, but no error is emitted.
I co-opted the page simple-drag-drop.glitch.me to create a test case to reproduce the issue:
This test fails to re-order the elements ABC:
Log entry:
The events "dragstart" and "dragover" are emitted, but no "dragend" or "drop".
I copied a second test from this blog post that uses drag & drop with native javascript:
This second test works:
The text was updated successfully, but these errors were encountered: