Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Use correct node version when pasting/importing nodes #8456

Merged
merged 4 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cypress/e2e/10-undo-redo.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ describe('Undo/Redo', () => {
cy.fixture('Test_workflow-actions_paste-data.json').then((data) => {
cy.get('body').paste(JSON.stringify(data));
WorkflowPage.actions.zoomToFit();
WorkflowPage.getters.canvasNodes().should('have.have.length', 2);
WorkflowPage.getters.canvasNodes().should('have.have.length', 5);
WorkflowPage.actions.hitUndo();
WorkflowPage.getters.canvasNodes().should('have.have.length', 0);
WorkflowPage.actions.hitRedo();
WorkflowPage.getters.canvasNodes().should('have.have.length', 2);
WorkflowPage.getters.canvasNodes().should('have.have.length', 5);
});
});

Expand Down Expand Up @@ -338,8 +338,8 @@ describe('Undo/Redo', () => {
WorkflowPage.getters.nodeConnections().should('have.length', 1);
cy.get(WorkflowPage.getters.getEndpointSelector('input', 'Switch')).should('have.length', 1);
cy.get(WorkflowPage.getters.getEndpointSelector('input', 'Switch'))
.should('have.css', 'left', `637px`)
.should('have.css', 'top', `501px`);
.should('have.css', 'left', `637px`)
.should('have.css', 'top', `501px`);

cy.fixture('Test_workflow_form_switch.json').then((data) => {
cy.get('body').paste(JSON.stringify(data));
Expand All @@ -353,8 +353,8 @@ describe('Undo/Redo', () => {
WorkflowPage.getters.nodeConnections().should('have.length', 1);
cy.get(WorkflowPage.getters.getEndpointSelector('input', 'Switch')).should('have.length', 1);
cy.get(WorkflowPage.getters.getEndpointSelector('input', 'Switch'))
.should('have.css', 'left', `637px`)
.should('have.css', 'top', `501px`);
.should('have.css', 'left', `637px`)
.should('have.css', 'top', `501px`);
});

it('should not undo/redo when NDV or a modal is open', () => {
Expand Down
10 changes: 6 additions & 4 deletions cypress/e2e/7-workflow-actions.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ describe('Workflow Actions', () => {
WorkflowPage.getters.successToast().should('exist');
});

it('should paste nodes', () => {
it('should paste nodes (both current and old node versions)', () => {
cy.fixture('Test_workflow-actions_paste-data.json').then((data) => {
cy.get('body').paste(JSON.stringify(data));
WorkflowPage.getters.canvasNodes().should('have.have.length', 2);
WorkflowPage.actions.zoomToFit();
WorkflowPage.getters.canvasNodes().should('have.length', 5);
WorkflowPage.getters.nodeConnections().should('have.length', 5);
});
});

Expand All @@ -147,8 +149,8 @@ describe('Workflow Actions', () => {
.selectFile('cypress/fixtures/Test_workflow-actions_paste-data.json', { force: true });
cy.waitForLoad(false);
WorkflowPage.actions.zoomToFit();
WorkflowPage.getters.canvasNodes().should('have.length', 2);
WorkflowPage.getters.nodeConnections().should('have.length', 1);
WorkflowPage.getters.canvasNodes().should('have.length', 5);
WorkflowPage.getters.nodeConnections().should('have.length', 5);
});

it('should update workflow settings', () => {
Expand Down
156 changes: 121 additions & 35 deletions cypress/fixtures/Test_workflow-actions_paste-data.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,128 @@
{
"meta": {
"instanceId": "1a30c82b98a30444ad25bce513655a5e02be772d361403542c23172be6062f04"
"templateCredsSetupCompleted": true,
"instanceId": "669258f419ee5d9faf0a484944244a47fcc28c541f3c6c874e50a171a0be1e6b"
},
"nodes": [
{
"parameters": {
"rule": {
"interval": [{}]
}
},
"id": "a898563b-d2a4-4b15-a979-366872e801b0",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [420, 260]
{
"parameters": {
"rule": {
"interval": [
{}
]
}
},
{
"parameters": {
"options": {}
},
"id": "b9a13e3d-bfa5-4873-959f-fd3d67e380d9",
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [640, 260]
}
"id": "54b1cdeb-b453-4568-8107-c17fcf2aa25a",
"name": "Schedule Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1,
"position": [
240,
560
]
},
{
"parameters": {
"options": {}
},
"id": "5f6dffef-61f7-459d-930c-ef701d08d49a",
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
460,
460
]
},
{
"parameters": {
"rules": {
"rules": [
{
"outputKey": "a"
}
]
}
},
"id": "c07d3a12-1ee2-4131-bec2-ab366457d042",
"name": "Old version Switch Node",
"type": "n8n-nodes-base.switch",
"typeVersion": 2,
"position": [
460,
680
]
},
{
"parameters": {
"options": {}
},
"id": "182a833d-3b93-4e86-a0db-3ceb19d6562b",
"name": "Loop Over Items",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
720,
560
]
},
{
"parameters": {},
"id": "b0d0aeb7-0c8f-4810-8b78-6c0db3c9a486",
"name": "Replace Me",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
900,
560
]
}
],
"connections": {
"Schedule Trigger": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
}
}
}
"Schedule Trigger": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
},
{
"node": "Old version Switch Node",
"type": "main",
"index": 0
},
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
null,
[
{
"node": "Replace Me",
"type": "main",
"index": 0
}
]
]
},
"Replace Me": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {}
}
4 changes: 2 additions & 2 deletions packages/workflow/src/TelemetryHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function generateNodesGraph(
webhookNodeNames.push(node.name);
} else {
try {
const nodeType = nodeTypes.getByNameAndVersion(node.type);
const nodeType = nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
if (nodeType) {
const nodeParameters = getNodeParameters(
nodeType.description.properties,
Expand Down Expand Up @@ -230,7 +230,7 @@ export function generateNodesGraph(

Object.keys(connections).forEach((key) => {
connections[key].forEach((element) => {
element.forEach((element2) => {
(element ?? []).forEach((element2) => {
nodeGraph.node_connections.push(getGraphConnectionItem(nodeName, element2));
});
});
Expand Down
Loading