2024-06-10 06:49:50 -07:00
|
|
|
import { WorkflowPage, NDV } from '../pages';
|
|
|
|
import { getVisibleSelect } from '../utils';
|
2023-02-17 06:08:26 -08:00
|
|
|
import {
|
|
|
|
MANUAL_TRIGGER_NODE_NAME,
|
|
|
|
MANUAL_TRIGGER_NODE_DISPLAY_NAME,
|
|
|
|
SCHEDULE_TRIGGER_NODE_NAME,
|
|
|
|
} from './../constants';
|
2023-02-06 20:47:37 -08:00
|
|
|
|
|
|
|
const workflowPage = new WorkflowPage();
|
|
|
|
const ndv = new NDV();
|
|
|
|
|
|
|
|
describe('Data mapping', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
beforeEach(() => {
|
2023-02-06 20:47:37 -08:00
|
|
|
workflowPage.actions.visit();
|
|
|
|
});
|
|
|
|
|
2023-02-09 06:59:01 -08:00
|
|
|
it('maps expressions from table header', () => {
|
2023-02-06 20:47:37 -08:00
|
|
|
cy.fixture('Test_workflow-actions_paste-data.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
|
|
|
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.openNode('Set');
|
2023-02-06 20:47:37 -08:00
|
|
|
ndv.actions.executePrevious();
|
|
|
|
ndv.actions.switchInputMode('Table');
|
|
|
|
ndv.getters.inputDataContainer().get('table', { timeout: 10000 }).should('exist');
|
|
|
|
|
|
|
|
ndv.getters.nodeParameters().find('input[placeholder*="Add Value"]').click();
|
2023-07-28 00:51:07 -07:00
|
|
|
getVisibleSelect().find('li:nth-child(3)').should('have.text', 'String').click();
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterInput('name')
|
|
|
|
.should('have.length', 1)
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', 'propertyName');
|
|
|
|
ndv.getters
|
|
|
|
.parameterInput('value')
|
|
|
|
.should('have.length', 1)
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', '');
|
2023-02-06 20:47:37 -08:00
|
|
|
|
|
|
|
ndv.actions.mapDataFromHeader(1, 'value');
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.timestamp }}');
|
|
|
|
|
|
|
|
ndv.actions.mapDataFromHeader(2, 'value');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
2023-03-30 06:50:47 -07:00
|
|
|
.should('have.text', "{{ $json.timestamp }} {{ $json['Readable date'] }}");
|
2023-02-06 20:47:37 -08:00
|
|
|
});
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
it('maps expressions from table json, and resolves value based on hover', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.openNode('Set');
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.switchInputMode('Table');
|
|
|
|
ndv.getters.inputDataContainer().get('table', { timeout: 10000 }).should('exist');
|
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterInput('name')
|
|
|
|
.should('have.length', 1)
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', 'other');
|
|
|
|
ndv.getters
|
|
|
|
.parameterInput('value')
|
|
|
|
.should('have.length', 1)
|
|
|
|
.find('input')
|
|
|
|
.should('have.value', '');
|
|
|
|
|
|
|
|
ndv.getters
|
|
|
|
.inputTbodyCell(1, 0)
|
|
|
|
.find('span')
|
|
|
|
.contains('count')
|
|
|
|
.trigger('mousedown', { force: true });
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.mapToParameter('value');
|
|
|
|
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.input[0].count }}');
|
2024-05-10 05:39:06 -07:00
|
|
|
ndv.getters.inlineExpressionEditorInput().type('{esc}');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters.parameterExpressionPreview('value').should('include.text', '0');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.getters.inputTbodyCell(1, 0).realHover();
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterExpressionPreview('value')
|
2023-02-09 06:59:01 -08:00
|
|
|
.should('include.text', '0')
|
|
|
|
.invoke('css', 'color')
|
2023-11-01 05:33:36 -07:00
|
|
|
.should('equal', 'rgb(113, 116, 122)');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.getters.inputTbodyCell(2, 0).realHover();
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterExpressionPreview('value')
|
|
|
|
.should('include.text', '1')
|
|
|
|
.invoke('css', 'color')
|
2023-11-01 05:33:36 -07:00
|
|
|
.should('equal', 'rgb(113, 116, 122)');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.execute();
|
|
|
|
|
|
|
|
ndv.getters.outputTbodyCell(1, 0).realHover();
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterExpressionPreview('value')
|
2023-02-09 06:59:01 -08:00
|
|
|
.should('include.text', '0')
|
|
|
|
.invoke('css', 'color')
|
2023-11-01 05:33:36 -07:00
|
|
|
.should('equal', 'rgb(113, 116, 122)'); // todo update color
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.getters.outputTbodyCell(2, 0).realHover();
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterExpressionPreview('value')
|
|
|
|
.should('include.text', '1')
|
|
|
|
.invoke('css', 'color')
|
2023-11-01 05:33:36 -07:00
|
|
|
.should('equal', 'rgb(113, 116, 122)');
|
2023-02-09 06:59:01 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('maps expressions from json view', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.openNode('Set');
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.switchInputMode('JSON');
|
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inputDataContainer()
|
|
|
|
.should('exist')
|
|
|
|
.find('.json-data')
|
|
|
|
.should(
|
|
|
|
'have.text',
|
2023-07-28 00:51:07 -07:00
|
|
|
'[{"input": [{"count": 0,"with space": "!!","with.dot": "!!","with"quotes": "!!"}]},{"input": [{"count": 1}]}]',
|
2023-02-24 09:07:35 -08:00
|
|
|
)
|
|
|
|
.find('span')
|
|
|
|
.contains('"count"')
|
2023-02-09 06:59:01 -08:00
|
|
|
.realMouseDown();
|
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.input[0].count }}');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters.parameterExpressionPreview('value').should('include.text', '0');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inputDataContainer()
|
|
|
|
.find('.json-data')
|
|
|
|
.find('span')
|
|
|
|
.contains('"input"')
|
2023-02-09 06:59:01 -08:00
|
|
|
.realMouseDown();
|
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.should('have.text', '{{ $json.input[0].count }} {{ $json.input }}');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0 [object Object]');
|
2023-02-09 06:59:01 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('maps expressions from schema view', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.openNode('Set');
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.clearParameterInput('value');
|
|
|
|
cy.get('body').type('{esc}');
|
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters.inputDataContainer().should('exist').find('span').contains('count').realMouseDown();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.input[0].count }}');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters.inputDataContainer().find('span').contains('input').realMouseDown();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.should('have.text', '{{ $json.input[0].count }} {{ $json.input }}');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0 [object Object]');
|
2023-02-09 06:59:01 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('maps expressions from previous nodes', () => {
|
2024-06-10 06:49:50 -07:00
|
|
|
cy.createFixtureWorkflow('Test_workflow_3.json', 'My test workflow');
|
2023-07-28 00:51:07 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.openNode('Set1');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2024-06-24 09:09:28 -07:00
|
|
|
ndv.actions.executePrevious();
|
|
|
|
ndv.actions.expandSchemaViewNode(SCHEDULE_TRIGGER_NODE_NAME);
|
2023-02-09 06:59:01 -08:00
|
|
|
|
2024-06-24 09:09:28 -07:00
|
|
|
const dataPill = ndv.getters
|
|
|
|
.inputDataContainer()
|
|
|
|
.findChildByTestId('run-data-schema-item')
|
|
|
|
.contains('count')
|
|
|
|
.should('be.visible');
|
|
|
|
dataPill.realMouseDown();
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.mapToParameter('value');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
2023-05-12 02:45:10 -07:00
|
|
|
.should('have.text', `{{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input[0].count }}`);
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.switchInputMode('Table');
|
2024-06-24 09:09:28 -07:00
|
|
|
ndv.actions.selectInputNode(SCHEDULE_TRIGGER_NODE_NAME);
|
2023-02-09 06:59:01 -08:00
|
|
|
ndv.actions.mapDataFromHeader(1, 'value');
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.should(
|
|
|
|
'have.text',
|
2023-05-12 02:45:10 -07:00
|
|
|
`{{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input[0].count }} {{ $('${SCHEDULE_TRIGGER_NODE_NAME}').item.json.input }}`,
|
2023-02-24 09:07:35 -08:00
|
|
|
);
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.selectInputNode('Set');
|
|
|
|
|
|
|
|
ndv.getters.executingLoader().should('not.exist');
|
|
|
|
ndv.getters.inputDataContainer().should('exist');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0 [object Object]');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.getters.inputTbodyCell(2, 0).realHover();
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '1 [object Object]');
|
2023-02-09 06:59:01 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('maps keys to path', () => {
|
2023-02-17 06:08:26 -08:00
|
|
|
workflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
|
|
|
workflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
|
|
|
|
workflowPage.actions.openNode(MANUAL_TRIGGER_NODE_DISPLAY_NAME);
|
2024-04-05 06:00:31 -07:00
|
|
|
ndv.actions.pastePinnedData([
|
2023-02-09 06:59:01 -08:00
|
|
|
{
|
|
|
|
input: [
|
|
|
|
{
|
2023-02-24 09:07:35 -08:00
|
|
|
'hello.world': {
|
|
|
|
'my count': 0,
|
2023-02-09 06:59:01 -08:00
|
|
|
},
|
2023-02-24 09:07:35 -08:00
|
|
|
},
|
|
|
|
],
|
2023-02-09 06:59:01 -08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
input: [
|
|
|
|
{
|
2023-02-24 09:07:35 -08:00
|
|
|
'hello.world': {
|
|
|
|
'my count': 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2023-02-09 06:59:01 -08:00
|
|
|
},
|
|
|
|
]);
|
|
|
|
|
|
|
|
ndv.actions.close();
|
|
|
|
|
2023-12-08 02:40:05 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas('Sort');
|
|
|
|
workflowPage.actions.openNode('Sort');
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.getters.nodeParameters().find('button').contains('Add Field To Sort By').click();
|
|
|
|
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters.inputDataContainer().find('span').contains('my count').realMouseDown();
|
2023-02-09 06:59:01 -08:00
|
|
|
|
|
|
|
ndv.actions.mapToParameter('fieldName');
|
|
|
|
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.length', 0);
|
2023-02-24 09:07:35 -08:00
|
|
|
ndv.getters
|
|
|
|
.parameterInput('fieldName')
|
|
|
|
.find('input')
|
2023-03-30 06:50:47 -07:00
|
|
|
.should('have.value', "input[0]['hello.world']['my count']");
|
2023-02-09 06:59:01 -08:00
|
|
|
});
|
2023-03-02 04:02:29 -08:00
|
|
|
|
|
|
|
it('maps expressions to updated fields correctly', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-03-02 04:02:29 -08:00
|
|
|
|
|
|
|
workflowPage.actions.openNode('Set');
|
|
|
|
|
|
|
|
ndv.actions.typeIntoParameterInput('value', 'delete me');
|
|
|
|
|
|
|
|
ndv.actions.typeIntoParameterInput('name', 'test');
|
2024-03-26 07:23:30 -07:00
|
|
|
ndv.getters.parameterInput('name').find('input').blur();
|
2023-03-02 04:02:29 -08:00
|
|
|
|
|
|
|
ndv.actions.typeIntoParameterInput('value', 'fun');
|
|
|
|
ndv.actions.clearParameterInput('value'); // keep focus on param
|
2023-07-28 00:51:07 -07:00
|
|
|
cy.wait(300);
|
2023-03-02 04:02:29 -08:00
|
|
|
|
|
|
|
ndv.getters.inputDataContainer().should('exist').find('span').contains('count').realMouseDown();
|
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
|
|
|
ndv.getters.inlineExpressionEditorInput().should('have.text', '{{ $json.input[0].count }}');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0');
|
2023-03-02 04:02:29 -08:00
|
|
|
|
|
|
|
ndv.getters.inputDataContainer().find('span').contains('input').realMouseDown();
|
|
|
|
|
|
|
|
ndv.actions.mapToParameter('value');
|
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.should('have.text', '{{ $json.input[0].count }} {{ $json.input }}');
|
2023-05-10 01:32:09 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', '0 [object Object]');
|
2023-03-02 04:02:29 -08:00
|
|
|
});
|
2023-03-31 03:35:02 -07:00
|
|
|
|
2024-04-19 01:07:00 -07:00
|
|
|
it('renders expression preview when a previous node is selected', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2024-04-19 01:07:00 -07:00
|
|
|
|
|
|
|
workflowPage.actions.openNode('Set');
|
|
|
|
ndv.actions.typeIntoParameterInput('value', 'test_value');
|
|
|
|
ndv.actions.typeIntoParameterInput('name', '{selectall}test_name');
|
|
|
|
ndv.actions.close();
|
|
|
|
|
|
|
|
workflowPage.actions.openNode('Set1');
|
|
|
|
ndv.actions.executePrevious();
|
|
|
|
ndv.getters.executingLoader().should('not.exist');
|
|
|
|
ndv.getters.inputDataContainer().should('exist');
|
2024-06-24 09:09:28 -07:00
|
|
|
ndv.actions.switchInputMode('Table');
|
|
|
|
ndv.actions.mapDataFromHeader(1, 'value');
|
2024-04-19 01:07:00 -07:00
|
|
|
ndv.actions.validateExpressionPreview('value', 'test_value');
|
|
|
|
ndv.actions.selectInputNode(SCHEDULE_TRIGGER_NODE_NAME);
|
|
|
|
ndv.actions.validateExpressionPreview('value', 'test_value');
|
|
|
|
});
|
|
|
|
|
2023-03-31 03:35:02 -07:00
|
|
|
it('shows you can drop to inputs, including booleans', () => {
|
|
|
|
cy.fixture('Test_workflow_3.json').then((data) => {
|
|
|
|
cy.get('body').paste(JSON.stringify(data));
|
|
|
|
});
|
2024-06-25 02:14:02 -07:00
|
|
|
workflowPage.actions.zoomToFit();
|
2023-03-31 03:35:02 -07:00
|
|
|
|
|
|
|
workflowPage.actions.openNode('Set');
|
2024-03-05 03:42:06 -08:00
|
|
|
ndv.getters.parameterInput('includeOtherFields').find('input[type="checkbox"]').should('exist');
|
|
|
|
ndv.getters.parameterInput('includeOtherFields').find('input[type="text"]').should('not.exist');
|
2024-07-02 11:55:19 -07:00
|
|
|
const pill = ndv.getters.inputDataContainer().find('span').contains('count');
|
|
|
|
pill.should('be.visible');
|
|
|
|
pill.realMouseDown();
|
|
|
|
pill.realMouseMove(100, 100);
|
2023-03-31 03:35:02 -07:00
|
|
|
|
2023-06-15 05:30:05 -07:00
|
|
|
ndv.getters
|
2024-03-05 03:42:06 -08:00
|
|
|
.parameterInput('includeOtherFields')
|
|
|
|
.find('input[type="checkbox"]')
|
|
|
|
.should('not.exist');
|
|
|
|
ndv.getters
|
|
|
|
.parameterInput('includeOtherFields')
|
2023-06-15 05:30:05 -07:00
|
|
|
.find('input[type="text"]')
|
2023-03-31 03:35:02 -07:00
|
|
|
.should('exist')
|
|
|
|
.invoke('css', 'border')
|
2024-07-02 11:55:19 -07:00
|
|
|
.should('include', 'dashed rgb(90, 76, 194)');
|
2023-03-31 03:35:02 -07:00
|
|
|
|
2023-06-15 05:30:05 -07:00
|
|
|
ndv.getters
|
|
|
|
.parameterInput('value')
|
|
|
|
.find('input[type="text"]')
|
|
|
|
.should('exist')
|
|
|
|
.invoke('css', 'border')
|
2024-07-02 11:55:19 -07:00
|
|
|
.should('include', 'dashed rgb(90, 76, 194)');
|
2023-03-31 03:35:02 -07:00
|
|
|
});
|
2023-02-06 20:47:37 -08:00
|
|
|
});
|