n8n/cypress/e2e/9-expression-editor-modal.cy.ts
OlegIvaniv 1c36c37a12
test(editor): Fix flaky e2e tests (#4779)
* test(editor): Fix default-owner and credentials saving e2e specs

* test(editor): fix webhook node test

* test(editor): add cy command for browser permissions

* test(editor): add cy command for reading clipboard

* Fix 3-default-owner spec

* Resolve review comments

* Merge spec

* Fix http node and expression editor modal specs

* Add optional param to credentials modal saving action to wait for the test endpoint

* Improve sidebar items clicking and increase credentials saving timeout

* Rename http e2e spec to fix ordering

* Fix pasting and copying of nodes e2e spec

* Make sure to only access error.cause if it exists

* Wait longer for the keyboard press

* Make sure to focus the body when typing

* Try type delay

* Use meta key based on the running platform

* Fix flaky workflowTagElements getter

Co-authored-by: Csaba Tuncsik <csaba@n8n.io>
2022-12-07 18:16:38 +01:00

66 lines
2.5 KiB
TypeScript

import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
const WorkflowPage = new WorkflowPageClass();
describe('Expression editor modal', () => {
before(() => {
cy.task('reset');
cy.skipSetup();
});
beforeEach(() => {
WorkflowPage.actions.visit();
WorkflowPage.actions.addInitialNodeToCanvas('Manual Trigger');
WorkflowPage.actions.addNodeToCanvas('Hacker News');
WorkflowPage.actions.openNodeNdv('Hacker News');
WorkflowPage.actions.openExpressionEditor();
});
it('should resolve primitive resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('1 + 2');
WorkflowPage.getters.expressionModalOutput().contains(/^3$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('"ab" + "cd"');
WorkflowPage.getters.expressionModalOutput().contains(/^abcd$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('true && false');
WorkflowPage.getters.expressionModalOutput().contains(/^false$/);
});
it('should resolve object resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('{{} a: 1');
WorkflowPage.getters.expressionModalOutput().contains(/^\[Object: \{"a":1\}\]$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('{{} a: 1 }.a{del}{del}');
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
});
it('should resolve array resolvables', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('[1, 2, 3]');
WorkflowPage.getters.expressionModalOutput().contains(/^\[Array: \[1,2,3\]\]$/);
WorkflowPage.getters.expressionModalInput().clear();
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('[1, 2, 3][0]');
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
});
it('should resolve $parameter[]', () => {
WorkflowPage.getters.expressionModalInput().type('{{');
WorkflowPage.getters.expressionModalInput().type('$parameter["operation"]');
WorkflowPage.getters.expressionModalOutput().contains(/^get$/);
});
});