mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
* test(editor): Add canvas actions E2E tests (#6723)
* test(editor): Add canvas actions E2E tests
* test(editor): Open category items in node creator when category dropped on canvas
* test(editor): Have new position counted only once in drag
* test(editor): rename test
(cherry picked from commit 052d82b220)
* test: fix drag positioning
This commit is contained in:
@@ -103,19 +103,31 @@ Cypress.Commands.add('paste', { prevSubject: true }, (selector, pastePayload) =>
|
||||
Cypress.Commands.add('drag', (selector, pos, options) => {
|
||||
const index = options?.index || 0;
|
||||
const [xDiff, yDiff] = pos;
|
||||
const element = cy.get(selector).eq(index);
|
||||
const element = typeof selector === 'string' ? cy.get(selector).eq(index) : selector;
|
||||
element.should('exist');
|
||||
|
||||
const originalLocation = Cypress.$(selector)[index].getBoundingClientRect();
|
||||
element.then(([$el]) => {
|
||||
const originalLocation = $el.getBoundingClientRect();
|
||||
const newPosition = {
|
||||
x: options?.abs ? xDiff : originalLocation.right + xDiff,
|
||||
y: options?.abs ? yDiff : originalLocation.top + yDiff,
|
||||
}
|
||||
|
||||
element.trigger('mousedown', { force: true });
|
||||
element.trigger('mousemove', {
|
||||
which: 1,
|
||||
pageX: options?.abs ? xDiff : originalLocation.right + xDiff,
|
||||
pageY: options?.abs ? yDiff : originalLocation.top + yDiff,
|
||||
force: true,
|
||||
if(options?.realMouse) {
|
||||
element.realMouseDown();
|
||||
element.realMouseMove(newPosition.x, newPosition.y);
|
||||
element.realMouseUp();
|
||||
} else {
|
||||
element.trigger('mousedown', {force: true});
|
||||
element.trigger('mousemove', {
|
||||
which: 1,
|
||||
pageX: newPosition.x,
|
||||
pageY: newPosition.y,
|
||||
force: true,
|
||||
});
|
||||
element.trigger('mouseup', {force: true});
|
||||
}
|
||||
});
|
||||
element.trigger('mouseup', { force: true });
|
||||
});
|
||||
|
||||
Cypress.Commands.add('draganddrop', (draggableSelector, droppableSelector) => {
|
||||
|
||||
@@ -31,7 +31,7 @@ declare global {
|
||||
grantBrowserPermissions(...permissions: string[]): void;
|
||||
readClipboard(): Chainable<string>;
|
||||
paste(pastePayload: string): void;
|
||||
drag(selector: string, target: [number, number], options?: {abs?: true, index?: number}): void;
|
||||
drag(selector: string | Cypress.Chainable<JQuery<HTMLElement>>, target: [number, number], options?: {abs?: boolean, index?: number, realMouse?: boolean}): void;
|
||||
draganddrop(draggableSelector: string, droppableSelector: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user