From be967ebec07fab223513f93f50bcc389b9a4c548 Mon Sep 17 00:00:00 2001 From: oleg Date: Wed, 29 Jan 2025 11:03:03 +0100 Subject: [PATCH] feat(editor): Add evaluation workflow and enhance workflow selector with pinned data support (#12773) --- cypress/e2e/39-projects.cy.ts | 1 + .../e2e/45-workflow-selector-parameter.cy.ts | 22 ++- cypress/e2e/48-subworkflow-inputs.cy.ts | 69 ++++----- .../EditDefinition/WorkflowSelector.vue | 30 +++- .../EditDefinition/sections/ConfigSection.vue | 17 ++- .../WorkflowSelectorParameterInput.vue | 47 +++--- packages/editor-ui/src/constants.ts | 2 - packages/editor-ui/src/constants.workflows.ts | 141 +++++++++++++++++- .../src/plugins/i18n/locales/en.json | 3 + .../TestDefinition/TestDefinitionEditView.vue | 39 ++++- .../src/views/WorkflowOnboardingView.vue | 44 +----- 11 files changed, 290 insertions(+), 125 deletions(-) diff --git a/cypress/e2e/39-projects.cy.ts b/cypress/e2e/39-projects.cy.ts index 492cdde975..b506040c87 100644 --- a/cypress/e2e/39-projects.cy.ts +++ b/cypress/e2e/39-projects.cy.ts @@ -556,6 +556,7 @@ describe('Projects', { disableAutoLogin: true }, () => { selectResourceLocatorItem('workflowId', 0, 'Create a'); + cy.get('body').type('{esc}'); workflowPage.actions.addNodeToCanvas(NOTION_NODE_NAME, true, true); clickCreateNewCredential(); setCredentialValues({ diff --git a/cypress/e2e/45-workflow-selector-parameter.cy.ts b/cypress/e2e/45-workflow-selector-parameter.cy.ts index ac790a2923..40e5ca2488 100644 --- a/cypress/e2e/45-workflow-selector-parameter.cy.ts +++ b/cypress/e2e/45-workflow-selector-parameter.cy.ts @@ -86,6 +86,8 @@ describe('Workflow Selector Parameter', () => { cy.stub(win, 'open').as('windowOpen'); }); + cy.intercept('POST', '/rest/workflows*').as('createSubworkflow'); + ndv.getters.resourceLocator('workflowId').should('be.visible'); ndv.getters.resourceLocatorInput('workflowId').click(); @@ -98,10 +100,20 @@ describe('Workflow Selector Parameter', () => { getVisiblePopper().findChildByTestId('rlc-item').eq(0).click(); - const SAMPLE_SUBWORKFLOW_TEMPLATE_ID = 'VMiAxXa3lCAizGB5f7dVZQSFfg3FtHkdTKvLuupqBls='; - cy.get('@windowOpen').should( - 'be.calledWith', - `/workflows/onboarding/${SAMPLE_SUBWORKFLOW_TEMPLATE_ID}?sampleSubWorkflows=0`, - ); + cy.wait('@createSubworkflow').then((interception) => { + expect(interception.request.body).to.have.property('name').that.includes('Sub-Workflow'); + expect(interception.request.body.nodes).to.be.an('array'); + expect(interception.request.body.nodes).to.have.length(2); + expect(interception.request.body.nodes[0]).to.have.property( + 'name', + 'When Executed by Another Workflow', + ); + expect(interception.request.body.nodes[1]).to.have.property( + 'name', + 'Replace me with your logic', + ); + }); + + cy.get('@windowOpen').should('be.calledWithMatch', /\/workflow\/.+/); }); }); diff --git a/cypress/e2e/48-subworkflow-inputs.cy.ts b/cypress/e2e/48-subworkflow-inputs.cy.ts index 2c1815d36c..d529ec2c25 100644 --- a/cypress/e2e/48-subworkflow-inputs.cy.ts +++ b/cypress/e2e/48-subworkflow-inputs.cy.ts @@ -65,7 +65,8 @@ describe('Sub-workflow creation and typed usage', () => { // ************************** // NAVIGATE TO CHILD WORKFLOW // ************************** - + // Close NDV before opening the node creator + cy.get('body').type('{esc}'); openNode('When Executed by Another Workflow'); }); @@ -138,41 +139,41 @@ describe('Sub-workflow creation and typed usage', () => { cy.window().then((win) => { cy.stub(win, 'open').callsFake((url) => { cy.visit(url); + selectResourceLocatorItem('workflowId', 0, 'Create a'); + + openNode('When Executed by Another Workflow'); + + getParameterInputByName('inputSource').click(); + + getVisiblePopper() + .getByTestId('parameter-input') + .eq(0) + .type('Using JSON Example{downArrow}{enter}'); + + const exampleJson = + '{{}' + EXAMPLE_FIELDS.map((x) => `"${x[0]}": ${makeExample(x[1])}`).join(',') + '}'; + getParameterInputByName('jsonExample') + .find('.cm-line') + .eq(0) + .type(`{selectAll}{backspace}${exampleJson}{enter}`); + + // first one doesn't work for some reason, might need to wait for something? + clickExecuteNode(); + + validateAndReturnToParent( + DEFAULT_SUBWORKFLOW_NAME_2, + 2, + EXAMPLE_FIELDS.map((f) => f[0]), + ); + + assertOutputTableContent([ + ['[null]', '[null]', '[null]', '[null]', '[null]', 'false'], + ['[null]', '[null]', '[null]', '[null]', '[null]', 'false'], + ]); + + clickExecuteNode(); }); }); - selectResourceLocatorItem('workflowId', 0, 'Create a'); - - openNode('When Executed by Another Workflow'); - - getParameterInputByName('inputSource').click(); - - getVisiblePopper() - .getByTestId('parameter-input') - .eq(0) - .type('Using JSON Example{downArrow}{enter}'); - - const exampleJson = - '{{}' + EXAMPLE_FIELDS.map((x) => `"${x[0]}": ${makeExample(x[1])}`).join(',') + '}'; - getParameterInputByName('jsonExample') - .find('.cm-line') - .eq(0) - .type(`{selectAll}{backspace}${exampleJson}{enter}`); - - // first one doesn't work for some reason, might need to wait for something? - clickExecuteNode(); - - validateAndReturnToParent( - DEFAULT_SUBWORKFLOW_NAME_2, - 2, - EXAMPLE_FIELDS.map((f) => f[0]), - ); - - assertOutputTableContent([ - ['[null]', '[null]', '[null]', '[null]', '[null]', 'false'], - ['[null]', '[null]', '[null]', '[null]', '[null]', 'false'], - ]); - - clickExecuteNode(); }); it('should show node issue when no fields are defined in manual mode', () => { diff --git a/packages/editor-ui/src/components/TestDefinition/EditDefinition/WorkflowSelector.vue b/packages/editor-ui/src/components/TestDefinition/EditDefinition/WorkflowSelector.vue index 87626d3ae3..45b1080fa2 100644 --- a/packages/editor-ui/src/components/TestDefinition/EditDefinition/WorkflowSelector.vue +++ b/packages/editor-ui/src/components/TestDefinition/EditDefinition/WorkflowSelector.vue @@ -1,20 +1,45 @@