2024-02-27 01:29:16 -08:00
|
|
|
import { NDV } from '../pages/ndv';
|
2022-12-01 04:26:22 -08:00
|
|
|
import { WorkflowPage as WorkflowPageClass } from '../pages/workflow';
|
|
|
|
|
|
|
|
const WorkflowPage = new WorkflowPageClass();
|
2024-02-27 01:29:16 -08:00
|
|
|
const ndv = new NDV();
|
2022-12-01 04:26:22 -08:00
|
|
|
|
|
|
|
describe('Expression editor modal', () => {
|
|
|
|
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-01 04:26:22 -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.openExpressionEditorModal();
|
|
|
|
});
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
it('should resolve primitive resolvables', () => {
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ 1 + 2');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^3$/);
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ "ab" + "cd"');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^abcd$/);
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ true && false');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^false$/);
|
|
|
|
});
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
it('should resolve object resolvables', () => {
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalInput()
|
2024-05-29 05:37:05 -07:00
|
|
|
.click()
|
2024-02-27 01:29:16 -08:00
|
|
|
.type('{{ { a : 1 }', { parseSpecialCharSequences: false });
|
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^\[Object: \{"a": 1\}\]$/);
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
|
|
|
|
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalInput()
|
2024-05-29 05:37:05 -07:00
|
|
|
.click()
|
2024-02-27 01:29:16 -08:00
|
|
|
.type('{{ { a : 1 }.a', { parseSpecialCharSequences: false });
|
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
|
|
|
|
});
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
it('should resolve array resolvables', () => {
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ [1, 2, 3]');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^\[Array: \[1,2,3\]\]$/);
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2022-12-01 04:26:22 -08:00
|
|
|
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ [1, 2, 3][0]');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().contains(/^1$/);
|
|
|
|
});
|
2022-12-01 04:26:22 -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.openExpressionEditorModal();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should resolve $parameter[]', () => {
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ $parameter["operation"]');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().should('have.text', 'getAll');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should resolve input: $json,$input,$(nodeName)', () => {
|
|
|
|
// Previous nodes have not run, input is empty
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ $json.myStr');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ $input.item.json.myStr');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalInput()
|
|
|
|
.click()
|
|
|
|
.type("{{ $('Schedule Trigger').item.json.myStr");
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalOutput()
|
|
|
|
.should('have.text', '[Execute previous nodes for preview]');
|
|
|
|
|
|
|
|
// Run workflow
|
|
|
|
cy.get('body').type('{esc}');
|
|
|
|
ndv.actions.close();
|
|
|
|
WorkflowPage.actions.executeNode('No Operation');
|
|
|
|
WorkflowPage.actions.openNode('Hacker News');
|
|
|
|
WorkflowPage.actions.openExpressionEditorModal();
|
|
|
|
|
|
|
|
// Previous nodes have run, input can be resolved
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ $json.myStr');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().should('have.text', 'Monday');
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters.expressionModalInput().click().type('{{ $input.item.json.myStr');
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().should('have.text', 'Monday');
|
|
|
|
WorkflowPage.getters.expressionModalInput().clear();
|
2024-05-29 05:37:05 -07:00
|
|
|
WorkflowPage.getters
|
|
|
|
.expressionModalInput()
|
|
|
|
.click()
|
|
|
|
.type("{{ $('Schedule Trigger').item.json.myStr");
|
2024-02-27 01:29:16 -08:00
|
|
|
WorkflowPage.getters.expressionModalOutput().should('have.text', 'Monday');
|
|
|
|
});
|
2022-12-01 04:26:22 -08:00
|
|
|
});
|
|
|
|
});
|