2023-09-22 04:17:54 -07:00
|
|
|
import {
|
|
|
|
HTTP_REQUEST_NODE_NAME,
|
|
|
|
MANUAL_TRIGGER_NODE_NAME,
|
|
|
|
PIPEDRIVE_NODE_NAME,
|
|
|
|
EDIT_FIELDS_SET_NODE_NAME,
|
2023-12-27 01:51:53 -08:00
|
|
|
BACKEND_BASE_URL,
|
2023-09-22 04:17:54 -07:00
|
|
|
} from '../constants';
|
2023-01-18 06:48:36 -08:00
|
|
|
import { WorkflowPage, NDV } from '../pages';
|
|
|
|
|
|
|
|
const workflowPage = new WorkflowPage();
|
|
|
|
const ndv = new NDV();
|
|
|
|
|
|
|
|
describe('Data pinning', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
beforeEach(() => {
|
2023-01-18 06:48:36 -08:00
|
|
|
workflowPage.actions.visit();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should be able to pin node output', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
|
2023-01-18 06:48:36 -08:00
|
|
|
ndv.getters.container().should('be.visible');
|
|
|
|
ndv.getters.pinDataButton().should('not.exist');
|
|
|
|
ndv.getters.editPinnedDataButton().should('be.visible');
|
|
|
|
|
|
|
|
ndv.actions.execute();
|
|
|
|
|
|
|
|
ndv.getters.outputDataContainer().should('be.visible');
|
2023-02-17 06:08:26 -08:00
|
|
|
// We hover over the table to get rid of the pinning tooltip which would overlay the table
|
|
|
|
// slightly and cause the test to fail
|
|
|
|
ndv.getters.outputDataContainer().get('table').realHover().should('be.visible');
|
2023-01-18 06:48:36 -08:00
|
|
|
ndv.getters.outputTableRows().should('have.length', 2);
|
|
|
|
ndv.getters.outputTableHeaders().should('have.length.at.least', 10);
|
|
|
|
ndv.getters.outputTableHeaders().first().should('include.text', 'timestamp');
|
|
|
|
ndv.getters.outputTableHeaders().eq(1).should('include.text', 'Readable date');
|
|
|
|
|
2023-01-27 01:18:15 -08:00
|
|
|
ndv.getters
|
|
|
|
.outputTbodyCell(1, 0)
|
|
|
|
.invoke('text')
|
|
|
|
.then((prevValue) => {
|
|
|
|
ndv.actions.pinData();
|
|
|
|
ndv.actions.close();
|
2023-01-18 06:48:36 -08:00
|
|
|
|
2023-01-27 01:18:15 -08:00
|
|
|
workflowPage.actions.executeWorkflow();
|
|
|
|
workflowPage.actions.openNode('Schedule Trigger');
|
2023-01-18 06:48:36 -08:00
|
|
|
|
2023-01-27 01:18:15 -08:00
|
|
|
ndv.getters.outputTbodyCell(1, 0).invoke('text').should('eq', prevValue);
|
|
|
|
});
|
2023-01-18 06:48:36 -08:00
|
|
|
});
|
|
|
|
|
2023-04-14 04:33:27 -07:00
|
|
|
it('Should be able to set pinned data', () => {
|
2023-02-24 09:07:35 -08:00
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
|
2023-01-18 06:48:36 -08:00
|
|
|
ndv.getters.container().should('be.visible');
|
|
|
|
ndv.getters.pinDataButton().should('not.exist');
|
|
|
|
ndv.getters.editPinnedDataButton().should('be.visible');
|
|
|
|
|
|
|
|
ndv.actions.setPinnedData([{ test: 1 }]);
|
|
|
|
|
|
|
|
ndv.getters.outputTableRows().should('have.length', 2);
|
|
|
|
ndv.getters.outputTableHeaders().should('have.length', 2);
|
|
|
|
ndv.getters.outputTableHeaders().first().should('include.text', 'test');
|
|
|
|
ndv.getters.outputTbodyCell(1, 0).should('include.text', 1);
|
|
|
|
|
|
|
|
ndv.actions.close();
|
|
|
|
|
|
|
|
workflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
|
|
|
|
workflowPage.actions.openNode('Schedule Trigger');
|
|
|
|
|
|
|
|
ndv.getters.outputTableHeaders().first().should('include.text', 'test');
|
|
|
|
ndv.getters.outputTbodyCell(1, 0).should('include.text', 1);
|
|
|
|
});
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-11-02 01:43:02 -07:00
|
|
|
it('Should be duplicating pin data when duplicating node', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
|
2023-11-20 05:37:12 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
|
2023-11-02 01:43:02 -07:00
|
|
|
ndv.getters.container().should('be.visible');
|
|
|
|
ndv.getters.pinDataButton().should('not.exist');
|
|
|
|
ndv.getters.editPinnedDataButton().should('be.visible');
|
|
|
|
|
|
|
|
ndv.actions.setPinnedData([{ test: 1 }]);
|
|
|
|
ndv.actions.close();
|
|
|
|
|
2023-11-20 05:37:12 -08:00
|
|
|
workflowPage.actions.duplicateNode(EDIT_FIELDS_SET_NODE_NAME);
|
2023-11-02 01:43:02 -07:00
|
|
|
|
|
|
|
workflowPage.actions.saveWorkflowOnButtonClick();
|
|
|
|
|
|
|
|
workflowPage.actions.openNode('Edit Fields1');
|
|
|
|
|
|
|
|
ndv.getters.outputTableHeaders().first().should('include.text', 'test');
|
|
|
|
ndv.getters.outputTbodyCell(1, 0).should('include.text', 1);
|
|
|
|
});
|
|
|
|
|
2023-11-20 05:37:12 -08:00
|
|
|
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.getters
|
|
|
|
.contextMenuAction('toggle_pin')
|
|
|
|
.parent()
|
|
|
|
.should('have.class', 'is-disabled');
|
|
|
|
|
|
|
|
// Unpin using context menu
|
|
|
|
workflowPage.actions.openNode(EDIT_FIELDS_SET_NODE_NAME);
|
|
|
|
ndv.actions.setPinnedData([{ test: 1 }]);
|
|
|
|
ndv.actions.close();
|
|
|
|
workflowPage.actions.pinNode(EDIT_FIELDS_SET_NODE_NAME);
|
|
|
|
workflowPage.actions.openNode(EDIT_FIELDS_SET_NODE_NAME);
|
|
|
|
ndv.getters.nodeOutputHint().should('exist');
|
|
|
|
ndv.actions.close();
|
|
|
|
|
|
|
|
// Unpin using shortcut
|
|
|
|
workflowPage.actions.openNode(EDIT_FIELDS_SET_NODE_NAME);
|
|
|
|
ndv.actions.setPinnedData([{ test: 1 }]);
|
|
|
|
ndv.actions.close();
|
|
|
|
workflowPage.getters.canvasNodeByName(EDIT_FIELDS_SET_NODE_NAME).click();
|
|
|
|
workflowPage.actions.hitPinNodeShortcut();
|
|
|
|
workflowPage.actions.openNode(EDIT_FIELDS_SET_NODE_NAME);
|
|
|
|
ndv.getters.nodeOutputHint().should('exist');
|
|
|
|
});
|
|
|
|
|
2023-11-02 01:43:02 -07:00
|
|
|
it('Should show an error when maximum pin data size is exceeded', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger');
|
2023-11-20 05:37:12 -08:00
|
|
|
workflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
|
2023-11-02 01:43:02 -07:00
|
|
|
ndv.getters.container().should('be.visible');
|
|
|
|
ndv.getters.pinDataButton().should('not.exist');
|
|
|
|
ndv.getters.editPinnedDataButton().should('be.visible');
|
|
|
|
|
|
|
|
ndv.actions.setPinnedData([
|
|
|
|
{
|
|
|
|
test: '1'.repeat(Cypress.env('MAX_PINNED_DATA_SIZE')),
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
workflowPage.getters
|
|
|
|
.errorToast()
|
|
|
|
.should('contain', 'Workflow has reached the maximum allowed pinned data size');
|
|
|
|
});
|
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
it('Should be able to reference paired items in a node located before pinned data', () => {
|
|
|
|
workflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
|
|
|
|
workflowPage.actions.addNodeToCanvas(HTTP_REQUEST_NODE_NAME, true, true);
|
|
|
|
ndv.actions.setPinnedData([{ http: 123 }]);
|
|
|
|
ndv.actions.close();
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
workflowPage.actions.addNodeToCanvas(PIPEDRIVE_NODE_NAME, true, true);
|
|
|
|
ndv.actions.setPinnedData(Array(3).fill({ pipedrive: 123 }));
|
|
|
|
ndv.actions.close();
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
workflowPage.actions.addNodeToCanvas(EDIT_FIELDS_SET_NODE_NAME, true, true);
|
|
|
|
setExpressionOnStringValueInSet(`{{ $('${HTTP_REQUEST_NODE_NAME}').item`);
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
const output = '[Object: {"json": {"http": 123}, "pairedItem": {"item": 0}}]';
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
cy.get('div').contains(output).should('be.visible');
|
|
|
|
});
|
2023-12-27 01:51:53 -08:00
|
|
|
|
|
|
|
it('should use pin data in manual executions that are started by a webhook', () => {
|
|
|
|
cy.createFixtureWorkflow('Test_workflow_webhook_with_pin_data.json', 'Test');
|
|
|
|
|
|
|
|
workflowPage.actions.executeWorkflow();
|
|
|
|
|
|
|
|
cy.request('GET', `${BACKEND_BASE_URL}/webhook-test/b0d79ddb-df2d-49b1-8555-9fa2b482608f`).then((response) => {
|
|
|
|
expect(response.status).to.eq(200);
|
|
|
|
});
|
|
|
|
|
|
|
|
workflowPage.actions.openNode('End');
|
|
|
|
|
|
|
|
ndv.getters.outputTableRow(1).should('exist')
|
|
|
|
ndv.getters.outputTableRow(1).should('have.text', 'pin-overwritten');
|
|
|
|
});
|
2023-01-18 06:48:36 -08:00
|
|
|
});
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
function setExpressionOnStringValueInSet(expression: string) {
|
|
|
|
cy.get('button').contains('Execute node').click();
|
|
|
|
cy.get('.fixed-collection-parameter > :nth-child(2) > .button > span').click();
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
ndv.getters.nthParam(4).contains('Expression').invoke('show').click();
|
2023-04-14 04:33:27 -07:00
|
|
|
|
2023-09-22 04:17:54 -07:00
|
|
|
ndv.getters
|
|
|
|
.inlineExpressionEditorInput()
|
|
|
|
.clear()
|
|
|
|
.type(expression, { parseSpecialCharSequences: false });
|
|
|
|
}
|