fix(API): Do not add starting node on workflow creation (#6686)

* fix(API): Do not add starting node on workflow creation

* chore: Remove comment
This commit is contained in:
Iván Ovejero
2023-07-18 14:03:19 +02:00
committed by GitHub
parent 2a6cd26def
commit 92192fbd61
7 changed files with 37 additions and 38 deletions

View File

@@ -8,6 +8,8 @@ import type { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
import { randomApiKey } from '../shared/random';
import * as utils from '../shared/utils/';
import * as testDb from '../shared/testDb';
import type { INode } from 'n8n-workflow';
import { STARTING_NODES } from '@/constants';
let workflowOwnerRole: Role;
let owner: User;
@@ -676,6 +678,35 @@ describe('POST /workflows', () => {
expect(sharedWorkflow?.workflow.createdAt.toISOString()).toBe(createdAt);
expect(sharedWorkflow?.role).toEqual(workflowOwnerRole);
});
test('should not add a starting node if the payload has no starting nodes', async () => {
const response = await authMemberAgent.post('/workflows').send({
name: 'testing',
nodes: [
{
id: 'uuid-1234',
parameters: {},
name: 'Hacker News',
type: 'n8n-nodes-base.hackerNews',
typeVersion: 1,
position: [240, 300],
},
],
connections: {},
settings: {
saveExecutionProgress: true,
saveManualExecutions: true,
saveDataErrorExecution: 'all',
saveDataSuccessExecution: 'all',
executionTimeout: 3600,
timezone: 'America/New_York',
},
});
const found = response.body.nodes.find((node: INode) => STARTING_NODES.includes(node.type));
expect(found).toBeUndefined();
});
});
describe('PUT /workflows/:id', () => {