Skip to content

Commit

Permalink
fix(editor): Prepare e2e suite for inline-expression-editor for new c…
Browse files Browse the repository at this point in the history
…anvas (no-changelog) (n8n-io#12110)

Co-authored-by: Oleg Ivaniv <[email protected]>
  • Loading branch information
alexgrozav and OlegIvaniv authored Dec 10, 2024
1 parent 2e61722 commit 1c52bf9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/11-inline-expression-editor.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Inline expression editor', () => {

// Run workflow
ndv.actions.close();
WorkflowPage.actions.executeNode('No Operation');
WorkflowPage.actions.executeNode('No Operation', { anchor: 'topLeft' });
WorkflowPage.actions.openNode('Hacker News');
WorkflowPage.actions.openInlineExpressionEditor();

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/13-pinning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('Data pinning', () => {
it('Should be able to pin data from canvas (context menu or shortcut)', () => {
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
workflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME);
workflowPage.actions.openContextMenu(EDIT_FIELDS_SET_NODE_NAME, 'overflow-button');
workflowPage.actions.openContextMenu(EDIT_FIELDS_SET_NODE_NAME, { method: 'overflow-button' });
workflowPage.getters
.contextMenuAction('toggle_pin')
.parent()
Expand Down
11 changes: 6 additions & 5 deletions cypress/pages/workflow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BasePage } from './base';
import { NodeCreator } from './features/node-creator';
import { META_KEY } from '../constants';
import type { OpenContextMenuOptions } from '../types';
import { getVisibleSelect } from '../utils';
import { getUniqueWorkflowName, isCanvasV2 } from '../utils/workflowUtils';

Expand Down Expand Up @@ -272,14 +273,14 @@ export class WorkflowPage extends BasePage {
},
openContextMenu: (
nodeTypeName?: string,
method: 'right-click' | 'overflow-button' = 'right-click',
{ method = 'right-click', anchor = 'center' }: OpenContextMenuOptions = {},
) => {
const target = nodeTypeName
? this.getters.canvasNodeByName(nodeTypeName)
: this.getters.nodeViewBackground();

if (method === 'right-click') {
target.rightclick(nodeTypeName ? 'center' : 'topLeft', { force: true });
target.rightclick(nodeTypeName ? anchor : 'topLeft', { force: true });
} else {
target.realHover();
target.find('[data-test-id="overflow-node-button"]').click({ force: true });
Expand All @@ -296,8 +297,8 @@ export class WorkflowPage extends BasePage {
this.actions.openContextMenu(nodeTypeName);
this.actions.contextMenuAction('delete');
},
executeNode: (nodeTypeName: string) => {
this.actions.openContextMenu(nodeTypeName);
executeNode: (nodeTypeName: string, options?: OpenContextMenuOptions) => {
this.actions.openContextMenu(nodeTypeName, options);
this.actions.contextMenuAction('execute');
},
addStickyFromContextMenu: () => {
Expand All @@ -324,7 +325,7 @@ export class WorkflowPage extends BasePage {
this.actions.contextMenuAction('toggle_pin');
},
openNodeFromContextMenu: (nodeTypeName: string) => {
this.actions.openContextMenu(nodeTypeName, 'overflow-button');
this.actions.openContextMenu(nodeTypeName, { method: 'overflow-button' });
this.actions.contextMenuAction('open');
},
selectAllFromContextMenu: () => {
Expand Down
5 changes: 5 additions & 0 deletions cypress/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ export interface ExecutionResponse {
results: Execution[];
};
}

export type OpenContextMenuOptions = {
method?: 'right-click' | 'overflow-button';
anchor?: 'topRight' | 'topLeft' | 'center' | 'bottomRight' | 'bottomLeft';
};

0 comments on commit 1c52bf9

Please sign in to comment.