mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Abstract away duplication when finding first pinned trigger (no-changelog) (#5927)
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import type { INode } from 'n8n-workflow';
|
||||
import { LoggerProxy } from 'n8n-workflow';
|
||||
import { LoggerProxy, type Workflow } from 'n8n-workflow';
|
||||
import { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
import { getNodesWithInaccessibleCreds, validateWorkflowCredentialUsage } from '@/WorkflowHelpers';
|
||||
import {
|
||||
getExecutionStartNode,
|
||||
getNodesWithInaccessibleCreds,
|
||||
validateWorkflowCredentialUsage,
|
||||
} from '@/WorkflowHelpers';
|
||||
import { getLogger } from '@/Logger';
|
||||
import type { IWorkflowExecutionDataProcess } from '../../src/Interfaces';
|
||||
|
||||
const FIRST_CREDENTIAL_ID = '1';
|
||||
const SECOND_CREDENTIAL_ID = '2';
|
||||
@@ -145,6 +150,46 @@ describe('WorkflowHelpers', () => {
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
describe('getExecutionStartNode', () => {
|
||||
it('Should return undefined', () => {
|
||||
const data = {
|
||||
pinData: {},
|
||||
startNodes: [],
|
||||
} as unknown as IWorkflowExecutionDataProcess;
|
||||
const workflow = {
|
||||
getNode(nodeName: string) {
|
||||
return {
|
||||
name: nodeName,
|
||||
};
|
||||
},
|
||||
} as unknown as Workflow;
|
||||
const executionStartNode = getExecutionStartNode(data, workflow);
|
||||
expect(executionStartNode).toBeUndefined();
|
||||
});
|
||||
it('Should return startNode', () => {
|
||||
const data = {
|
||||
pinData: {
|
||||
node1: {},
|
||||
node2: {},
|
||||
},
|
||||
startNodes: ['node2'],
|
||||
} as unknown as IWorkflowExecutionDataProcess;
|
||||
const workflow = {
|
||||
getNode(nodeName: string) {
|
||||
if (nodeName === 'node2') {
|
||||
return {
|
||||
name: 'node2',
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
} as unknown as Workflow;
|
||||
const executionStartNode = getExecutionStartNode(data, workflow);
|
||||
expect(executionStartNode).toEqual({
|
||||
name: 'node2',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function generateCredentialEntity(credentialId: string) {
|
||||
|
||||
Reference in New Issue
Block a user