mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix(editor): Fix paired items after renaming a node (#15440)
This commit is contained in:
@@ -990,6 +990,90 @@ describe('useWorkflowsStore', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renameNodeSelectedAndExecution', () => {
|
||||
it('should rename node and update execution data', () => {
|
||||
const nodeName = 'Rename me';
|
||||
const newName = 'Renamed';
|
||||
|
||||
workflowsStore.workflowExecutionData = {
|
||||
data: {
|
||||
resultData: {
|
||||
runData: {
|
||||
"When clicking 'Test workflow'": [
|
||||
{
|
||||
startTime: 1747389900668,
|
||||
executionIndex: 0,
|
||||
source: [],
|
||||
hints: [],
|
||||
executionTime: 1,
|
||||
executionStatus: 'success',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
[nodeName]: [
|
||||
{
|
||||
startTime: 1747389900670,
|
||||
executionIndex: 2,
|
||||
source: [
|
||||
{
|
||||
previousNode: "When clicking 'Test workflow'",
|
||||
},
|
||||
],
|
||||
hints: [],
|
||||
executionTime: 1,
|
||||
executionStatus: 'success',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
'Edit Fields': [
|
||||
{
|
||||
startTime: 1747389900671,
|
||||
executionIndex: 3,
|
||||
source: [
|
||||
{
|
||||
previousNode: nodeName,
|
||||
},
|
||||
],
|
||||
hints: [],
|
||||
executionTime: 3,
|
||||
executionStatus: 'success',
|
||||
data: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
pinData: {},
|
||||
lastNodeExecuted: 'Edit Fields',
|
||||
},
|
||||
},
|
||||
} as unknown as IExecutionResponse;
|
||||
|
||||
workflowsStore.addNode({
|
||||
parameters: {},
|
||||
id: '554c7ff4-7ee2-407c-8931-e34234c5056a',
|
||||
name: nodeName,
|
||||
type: 'n8n-nodes-base.set',
|
||||
position: [680, 180],
|
||||
typeVersion: 3.4,
|
||||
});
|
||||
|
||||
workflowsStore.renameNodeSelectedAndExecution({ old: nodeName, new: newName });
|
||||
|
||||
expect(workflowsStore.nodeMetadata[nodeName]).not.toBeDefined();
|
||||
expect(workflowsStore.nodeMetadata[newName]).toEqual({});
|
||||
expect(
|
||||
workflowsStore.workflowExecutionData?.data?.resultData.runData[nodeName],
|
||||
).not.toBeDefined();
|
||||
expect(workflowsStore.workflowExecutionData?.data?.resultData.runData[newName]).toBeDefined();
|
||||
expect(
|
||||
workflowsStore.workflowExecutionData?.data?.resultData.runData['Edit Fields'][0].source,
|
||||
).toEqual([
|
||||
{
|
||||
previousNode: newName,
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function getMockEditFieldsNode() {
|
||||
|
||||
@@ -1180,10 +1180,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
|
||||
// If node has any WorkflowResultData rename also that one that the data
|
||||
// does still get displayed also after node got renamed
|
||||
if (
|
||||
workflowExecutionData.value?.data &&
|
||||
workflowExecutionData.value.data.resultData.runData.hasOwnProperty(nameData.old)
|
||||
) {
|
||||
if (workflowExecutionData.value?.data?.resultData.runData[nameData.old]) {
|
||||
workflowExecutionData.value.data.resultData.runData[nameData.new] =
|
||||
workflowExecutionData.value.data.resultData.runData[nameData.old];
|
||||
delete workflowExecutionData.value.data.resultData.runData[nameData.old];
|
||||
@@ -1207,6 +1204,13 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Object.values(workflowExecutionData.value?.data?.resultData.runData ?? {})
|
||||
.flatMap((taskData) => taskData.map((task) => task.source).flat())
|
||||
.forEach((source) => {
|
||||
if (!source || source.previousNode !== nameData.old) return;
|
||||
source.previousNode = nameData.new;
|
||||
});
|
||||
}
|
||||
|
||||
function setParentFolder(folder: IWorkflowDb['parentFolder']) {
|
||||
|
||||
Reference in New Issue
Block a user