mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-13 05:47:31 -08:00
fix(core): Fix paired item returning wrong data (#5898)
* 🐛 Fix paired item returning wrong data * 🧪 Add e2e test * ⏪ Restore injection for simulated execution
This commit is contained in:
parent
ee7d5a841e
commit
b13b7d73e7
|
@ -1,3 +1,9 @@
|
||||||
|
import {
|
||||||
|
HTTP_REQUEST_NODE_NAME,
|
||||||
|
MANUAL_TRIGGER_NODE_DISPLAY_NAME,
|
||||||
|
PIPEDRIVE_NODE_NAME,
|
||||||
|
SET_NODE_NAME,
|
||||||
|
} from '../constants';
|
||||||
import { WorkflowPage, NDV } from '../pages';
|
import { WorkflowPage, NDV } from '../pages';
|
||||||
|
|
||||||
const workflowPage = new WorkflowPage();
|
const workflowPage = new WorkflowPage();
|
||||||
|
@ -44,7 +50,7 @@ describe('Data pinning', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should be be able to set pinned data', () => {
|
it('Should be able to set pinned data', () => {
|
||||||
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
|
workflowPage.actions.addInitialNodeToCanvas('Schedule Trigger', { keepNdvOpen: true });
|
||||||
ndv.getters.container().should('be.visible');
|
ndv.getters.container().should('be.visible');
|
||||||
ndv.getters.pinDataButton().should('not.exist');
|
ndv.getters.pinDataButton().should('not.exist');
|
||||||
|
@ -67,4 +73,35 @@ describe('Data pinning', () => {
|
||||||
ndv.getters.outputTableHeaders().first().should('include.text', 'test');
|
ndv.getters.outputTableHeaders().first().should('include.text', 'test');
|
||||||
ndv.getters.outputTbodyCell(1, 0).should('include.text', 1);
|
ndv.getters.outputTbodyCell(1, 0).should('include.text', 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should be able to reference paired items in a node located before pinned data', () => {
|
||||||
|
workflowPage.actions.addInitialNodeToCanvas(MANUAL_TRIGGER_NODE_DISPLAY_NAME);
|
||||||
|
workflowPage.actions.addNodeToCanvas(HTTP_REQUEST_NODE_NAME, true, true);
|
||||||
|
ndv.actions.setPinnedData([{ http: 123 }]);
|
||||||
|
ndv.actions.close();
|
||||||
|
|
||||||
|
workflowPage.actions.addNodeToCanvas(PIPEDRIVE_NODE_NAME, true, true);
|
||||||
|
ndv.actions.setPinnedData(Array(3).fill({ pipedrive: 123 }));
|
||||||
|
ndv.actions.close();
|
||||||
|
|
||||||
|
workflowPage.actions.addNodeToCanvas(SET_NODE_NAME, true, true);
|
||||||
|
setExpressionOnStringValueInSet(`{{ $('${HTTP_REQUEST_NODE_NAME}').item`);
|
||||||
|
|
||||||
|
const output = '[Object: {"json": {"http": 123}, "pairedItem": {"item": 0}}]';
|
||||||
|
|
||||||
|
cy.get('div').contains(output).should('be.visible');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setExpressionOnStringValueInSet(expression: string) {
|
||||||
|
cy.get('button').contains('Execute node').click();
|
||||||
|
cy.get('input[placeholder="Add Value"]').click();
|
||||||
|
cy.get('span').contains('String').click();
|
||||||
|
|
||||||
|
ndv.getters.nthParam(3).contains('Expression').invoke('show').click();
|
||||||
|
|
||||||
|
ndv.getters
|
||||||
|
.inlineExpressionEditorInput()
|
||||||
|
.clear()
|
||||||
|
.type(expression, { parseSpecialCharSequences: false });
|
||||||
|
}
|
||||||
|
|
|
@ -140,33 +140,6 @@ export function resolveParameter(
|
||||||
runExecutionData = executionData.data;
|
runExecutionData = executionData.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
parentNode.forEach((parentNodeName) => {
|
|
||||||
const pinData: IPinData[string] | undefined =
|
|
||||||
useWorkflowsStore().pinDataByNodeName(parentNodeName);
|
|
||||||
|
|
||||||
if (pinData) {
|
|
||||||
runExecutionData = {
|
|
||||||
...runExecutionData,
|
|
||||||
resultData: {
|
|
||||||
...runExecutionData.resultData,
|
|
||||||
runData: {
|
|
||||||
...runExecutionData.resultData.runData,
|
|
||||||
[parentNodeName]: [
|
|
||||||
{
|
|
||||||
startTime: new Date().valueOf(),
|
|
||||||
executionTime: 0,
|
|
||||||
source: [],
|
|
||||||
data: {
|
|
||||||
main: [pinData.map((data) => ({ json: data }))],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (_connectionInputData === null) {
|
if (_connectionInputData === null) {
|
||||||
_connectionInputData = [];
|
_connectionInputData = [];
|
||||||
}
|
}
|
||||||
|
@ -254,7 +227,7 @@ function getWorkflow(nodes: INodeUi[], connections: IConnections, copyData?: boo
|
||||||
nodeTypes,
|
nodeTypes,
|
||||||
settings: useWorkflowsStore().workflowSettings,
|
settings: useWorkflowsStore().workflowSettings,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
pinData: useWorkflowsStore().pinData,
|
pinData: useWorkflowsStore().getPinData,
|
||||||
});
|
});
|
||||||
|
|
||||||
return cachedWorkflow;
|
return cachedWorkflow;
|
||||||
|
|
|
@ -719,18 +719,11 @@ export class WorkflowDataProxy {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousNodeHasPinData =
|
|
||||||
sourceData && this.workflow.getPinDataOfNode(sourceData.previousNode) !== undefined;
|
|
||||||
|
|
||||||
let currentPairedItem = pairedItem;
|
let currentPairedItem = pairedItem;
|
||||||
|
|
||||||
let nodeBeforeLast: string | undefined;
|
let nodeBeforeLast: string | undefined;
|
||||||
|
|
||||||
while (
|
while (sourceData !== null && destinationNodeName !== sourceData.previousNode) {
|
||||||
!previousNodeHasPinData &&
|
|
||||||
sourceData !== null &&
|
|
||||||
destinationNodeName !== sourceData.previousNode
|
|
||||||
) {
|
|
||||||
taskData =
|
taskData =
|
||||||
that.runExecutionData!.resultData.runData[sourceData.previousNode][
|
that.runExecutionData!.resultData.runData[sourceData.previousNode][
|
||||||
sourceData?.previousNodeRun || 0
|
sourceData?.previousNodeRun || 0
|
||||||
|
|
Loading…
Reference in a new issue