Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/n8n-io/n8n into node-1197-…
Browse files Browse the repository at this point in the history
…http-node-add-item-number-to-errors-ie-item-n
  • Loading branch information
michael-radency committed Apr 9, 2024
2 parents 662a6bb + 610ead9 commit 0f35810
Show file tree
Hide file tree
Showing 111 changed files with 996 additions and 558 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/13-pinning.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('Data pinning', () => {
ndv.getters.pinDataButton().should('not.exist');
ndv.getters.editPinnedDataButton().should('be.visible');

ndv.actions.setPinnedData([
ndv.actions.pastePinnedData([
{
test: '1'.repeat(Cypress.env('MAX_PINNED_DATA_SIZE')),
},
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/14-mapping.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('Data mapping', () => {
workflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_NAME);
workflowPage.getters.canvasNodeByName(MANUAL_TRIGGER_NODE_DISPLAY_NAME).click();
workflowPage.actions.openNode(MANUAL_TRIGGER_NODE_DISPLAY_NAME);
ndv.actions.setPinnedData([
ndv.actions.pastePinnedData([
{
input: [
{
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/17-workflow-tags.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Workflow tags', () => {
wf.actions.addTags(TEST_TAGS.slice(0, 2));
wf.getters.tagPills().should('have.length', 2);
wf.getters.nthTagPill(1).click();
wf.actions.addTags(TEST_TAGS[2]);
wf.actions.addTags(TEST_TAGS[1].toUpperCase());
wf.getters.tagPills().should('have.length', 3);
wf.getters.isWorkflowSaved();
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/24-ndv-paired-item.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ describe('NDV', () => {
];
/* prettier-ignore */
workflowPage.actions.openNode('Get thread details1');
ndv.actions.setPinnedData(PINNED_DATA);
ndv.actions.pastePinnedData(PINNED_DATA);
ndv.actions.close();

workflowPage.actions.executeWorkflow();
Expand Down
31 changes: 27 additions & 4 deletions cypress/e2e/5-ndv.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ describe('NDV', () => {
cy.shouldNotHaveConsoleErrors();
});

it('should disconect Switch outputs if rules order was changed', () => {
cy.createFixtureWorkflow('NDV-test-switch_reorder.json', `NDV test switch reorder`);
workflowPage.actions.zoomToFit();

workflowPage.actions.executeWorkflow();
workflowPage.actions.openNode('Merge');
ndv.getters.outputPanel().contains('2 items').should('exist');
cy.contains('span', 'first').should('exist');
ndv.getters.backToCanvas().click();

workflowPage.actions.openNode('Switch');
cy.get('.cm-line').realMouseMove(100, 100);
cy.get('.fa-angle-down').click();
ndv.getters.backToCanvas().click();
workflowPage.actions.executeWorkflow();
workflowPage.actions.openNode('Merge');
ndv.getters.outputPanel().contains('1 item').should('exist');
cy.contains('span', 'zero').should('exist');
});

it('should show correct validation state for resource locator params', () => {
workflowPage.actions.addNodeToCanvas('Typeform', true, true);
ndv.getters.container().should('be.visible');
Expand Down Expand Up @@ -660,16 +680,19 @@ describe('NDV', () => {
});

it('Stop listening for trigger event from NDV', () => {
cy.intercept('POST', '/rest/workflows/run').as('workflowRun');
workflowPage.actions.addInitialNodeToCanvas('Local File Trigger', {
keepNdvOpen: true,
action: 'On Changes To A Specific File',
isTrigger: true,
});
ndv.getters.triggerPanelExecuteButton().should('exist');
ndv.getters.triggerPanelExecuteButton().click();
ndv.getters.triggerPanelExecuteButton().realClick();
ndv.getters.triggerPanelExecuteButton().should('contain', 'Stop Listening');
ndv.getters.triggerPanelExecuteButton().click();
ndv.getters.triggerPanelExecuteButton().should('contain', 'Test step');
workflowPage.getters.successToast().should('exist');
ndv.getters.triggerPanelExecuteButton().realClick();
cy.wait('@workflowRun').then(() => {
ndv.getters.triggerPanelExecuteButton().should('contain', 'Test step');
workflowPage.getters.successToast().should('exist');
});
});
});
235 changes: 235 additions & 0 deletions cypress/fixtures/NDV-test-switch_reorder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
{
"name": "switch reorder",
"nodes": [
{
"parameters": {},
"id": "b3f0815d-b733-413f-ab3f-74e48277bd3a",
"name": "When clicking \"Test workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-20,
620
]
},
{
"parameters": {},
"id": "fbc5b12a-6165-4cab-80a1-9fd6e4fbe39f",
"name": "One",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
620,
720
]
},
{
"parameters": {
"duplicateItem": true,
"duplicateCount": 1,
"assignments": {
"assignments": [
{
"id": "ec6c1d1d-a17a-4537-8135-d474df7fded1",
"name": "entry",
"value": "first",
"type": "string"
}
]
},
"options": {}
},
"id": "8c5a72a5-17ef-40e0-8477-764f24770174",
"name": "Edit Fields",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
160,
740
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "d8ec7c46-d02f-4bf5-931e-5ec2fb8bea22",
"name": "entry",
"value": "zero",
"type": "string"
}
]
},
"options": {}
},
"id": "bc3fb81d-2ddf-4b28-a93d-762a48e8fd6b",
"name": "Edit Fields1",
"type": "n8n-nodes-base.set",
"typeVersion": 3.3,
"position": [
160,
500
]
},
{
"parameters": {
"rules": {
"values": [
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"leftValue": "={{ $json.entry }}",
"rightValue": "first",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "1"
},
{
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "ffa570ef-fc16-49ec-87be-56159f14a44b",
"leftValue": "={{ $json.entry }}",
"rightValue": "=second",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"renameOutput": true,
"outputKey": "2"
}
]
},
"options": {}
},
"id": "296ba553-c6c5-4c84-89fb-9056b24bab30",
"name": "Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
360,
740
]
},
{
"parameters": {},
"id": "da787dd6-8e85-4dd5-8326-198705b4ae4b",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"typeVersion": 2.1,
"position": [
880,
520
]
}
],
"pinData": {
"Edit Fields": [
{
"json": {
"entry": "first"
}
},
{
"json": {
"entry": "second"
}
}
]
},
"connections": {
"When clicking \"Test workflow\"": {
"main": [
[
{
"node": "Edit Fields",
"type": "main",
"index": 0
},
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields": {
"main": [
[
{
"node": "Switch",
"type": "main",
"index": 0
}
]
]
},
"One": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Switch": {
"main": [
[
{
"node": "One",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "ce5db792-5e38-4d54-895b-88d85f2545d0",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "be251a83c052a9862eeac953816fbb1464f89dfbf79d7ac490a8e336a8cc8bfd"
},
"id": "uMpL0bN7t1NYZDJS",
"tags": []
}
11 changes: 11 additions & 0 deletions cypress/pages/ndv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ export class NDV extends BasePage {

this.actions.savePinnedData();
},
pastePinnedData: (data: object) => {
this.getters.editPinnedDataButton().click();

this.getters.pinnedDataEditor().click();
this.getters
.pinnedDataEditor()
.type('{selectall}{backspace}', { delay: 0 })
.paste(JSON.stringify(data));

this.actions.savePinnedData();
},
clearParameterInput: (parameterName: string) => {
this.getters.parameterInput(parameterName).type(`{selectall}{backspace}`);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {
type IExecuteFunctions,
type INodeExecutionData,
NodeConnectionType,
NodeOperationError,
} from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';

import { initializeAgentExecutorWithOptions } from 'langchain/agents';
import type { BaseChatMemory } from '@langchain/community/memory/chat_memory';
Expand All @@ -16,13 +12,13 @@ import {
getOptionalOutputParsers,
getConnectedTools,
} from '../../../../../utils/helpers';
import { getTracingConfig } from '../../../../../utils/tracing';

export async function conversationalAgentExecute(
this: IExecuteFunctions,
nodeVersion: number,
): Promise<INodeExecutionData[][]> {
this.logger.verbose('Executing Conversational Agent');

const model = await this.getInputConnectionData(NodeConnectionType.AiLanguageModel, 0);

if (!isChatInstance(model)) {
Expand Down Expand Up @@ -104,7 +100,9 @@ export async function conversationalAgentExecute(
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor.call({ input, outputParsers });
let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getOptionalOutputParsers,
getPromptInputByType,
} from '../../../../../utils/helpers';
import { getTracingConfig } from '../../../../../utils/tracing';

export async function openAiFunctionsAgentExecute(
this: IExecuteFunctions,
Expand Down Expand Up @@ -104,7 +105,9 @@ export async function openAiFunctionsAgentExecute(
input = (await prompt.invoke({ input })).value;
}

let response = await agentExecutor.call({ input, outputParsers });
let response = await agentExecutor
.withConfig(getTracingConfig(this))
.invoke({ input, outputParsers });

if (outputParser) {
response = { output: await outputParser.parse(response.output as string) };
Expand Down
Loading

0 comments on commit 0f35810

Please sign in to comment.