2024-02-27 01:29:16 -08:00
|
|
|
import { NDV } from '../pages/ndv';
|
2022-12-15 06:36:28 -08:00
|
|
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
const ndv = new NDV();
|
2022-12-15 06:36:28 -08:00
|
|
|
const WorkflowPage = new WorkflowPageClass();
|
|
|
|
|
|
|
|
describe('Inline expression editor', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
WorkflowPage.actions.visit();
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.actions.addInitialNodeToCanvas('Schedule');
|
2024-06-10 06:49:50 -07:00
|
|
|
cy.on('uncaught:exception', (error) => error.name !== 'ExpressionError');
|
2022-12-15 06:36:28 -08:00
|
|
|
});
|
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
describe('Static data', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
WorkflowPage.actions.addNodeToCanvas('Hacker News');
|
2024-06-25 02:14:02 -07:00
|
|
|
WorkflowPage.actions.zoomToFit();
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.actions.openNode('Hacker News');
|
|
|
|
WorkflowPage.actions.openInlineExpressionEditor();
|
|
|
|
});
|
2022-12-15 06:36:28 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
it('should resolve primitive resolvables', () => {
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('1 + 2');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^3$/);
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('"ab"');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('{rightArrow}+');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('"cd"');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^abcd$/);
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('true && false');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^false$/);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should resolve object resolvables', () => {
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.type('{ a: 1 }', { parseSpecialCharSequences: false });
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^\[Object: \{"a": 1\}\]$/);
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2022-12-15 06:36:28 -08:00
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.type('{ a: 1 }.a', { parseSpecialCharSequences: false });
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^1$/);
|
|
|
|
});
|
2022-12-15 06:36:28 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
it('should resolve array resolvables', () => {
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('[1, 2, 3]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^\[Array: \[1,2,3\]\]$/);
|
2022-12-15 06:36:28 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('[1, 2, 3]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('[0]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().contains(/^1$/);
|
|
|
|
});
|
2022-12-15 06:36:28 -08:00
|
|
|
});
|
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
describe('Dynamic data', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
WorkflowPage.actions.openNode('Schedule Trigger');
|
|
|
|
ndv.actions.setPinnedData([{ myStr: 'Monday' }]);
|
|
|
|
ndv.actions.close();
|
|
|
|
WorkflowPage.actions.addNodeToCanvas('No Operation');
|
|
|
|
WorkflowPage.actions.addNodeToCanvas('Hacker News');
|
2024-06-25 02:14:02 -07:00
|
|
|
WorkflowPage.actions.zoomToFit();
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.actions.openNode('Hacker News');
|
|
|
|
WorkflowPage.actions.openInlineExpressionEditor();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should resolve $parameter[]', () => {
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
// Resolving $parameter is slow, especially on CI runner
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('$parameter["operation"]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().should('have.text', 'getAll');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should resolve input: $json,$input,$(nodeName)', () => {
|
|
|
|
// Previous nodes have not run, input is empty
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('$json.myStr');
|
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('$input.item.json.myStr');
|
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.type("$('Schedule Trigger').item.json.myStr");
|
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
|
|
|
|
// Run workflow
|
|
|
|
ndv.actions.close();
|
|
|
|
WorkflowPage.actions.executeNode('No Operation');
|
|
|
|
WorkflowPage.actions.openNode('Hacker News');
|
|
|
|
WorkflowPage.actions.openInlineExpressionEditor();
|
|
|
|
|
|
|
|
// Previous nodes have run, input can be resolved
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('$json.myStr');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().should('have.text', 'Monday');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().type('$input.item.json.myStr');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().should('have.text', 'Monday');
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.inlineExpressionEditorInput().click().type('{{');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.type("$('Schedule Trigger').item.json.myStr");
|
|
|
|
WorkflowPage.getters.inlineExpressionEditorOutput().should('have.text', 'Monday');
|
|
|
|
});
|
2022-12-15 06:36:28 -08:00
|
|
|
});
|
|
|
|
});
|