Skip to content

Commit

Permalink
fix: update draggle tests to use pointer events
Browse files Browse the repository at this point in the history
Related to #596
  • Loading branch information
Skaiir committed Sep 13, 2024
1 parent 2acb7fe commit c4af692
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,16 @@ function dispatchEvent(element, type, options = {}) {
element.dispatchEvent(event);
}

function dispatchPointerEvent(element, type, options = {}) {
const event = new PointerEvent(type, {
bubbles: true,
cancelable: true,
...options,
});

element.dispatchEvent(event);
}

function startResizing(node, position) {
if (!position) {
const bounds = node.getBoundingClientRect();
Expand All @@ -1500,7 +1510,7 @@ function startDragging(container, node) {
node = container.querySelector('.fjs-palette-field[data-field-type="textfield"]');
}

dispatchEvent(node, 'mousedown', { which: 1 });
dispatchPointerEvent(node, 'pointerdown', { pointerId: 1, buttons: 1 });
}

function moveDragging(container, position) {
Expand All @@ -1514,12 +1524,12 @@ function moveDragging(container, position) {
};
}

dispatchEvent(form, 'mousemove', position);
dispatchPointerEvent(form, 'pointermove', { pointerId: 1, buttons: 1, ...position });
}

function endDragging(container) {
const form = container.querySelector('.fjs-drop-container-vertical[data-id="Form_1"]');
dispatchEvent(form, 'mouseup');
dispatchPointerEvent(form, 'pointerup', { pointerId: 1 });
}

function getRowOrder(container) {
Expand Down

0 comments on commit c4af692

Please sign in to comment.