mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Improve test-webhooks (no-changelog) (#8069)
Remove duplication, improve readability, and expand tests for `TestWebhooks.ts` - in anticipation for storing test webhooks in Redis. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -450,7 +450,6 @@ export interface IGetExecuteHookFunctions {
|
||||
additionalData: IWorkflowExecuteAdditionalData,
|
||||
mode: WorkflowExecuteMode,
|
||||
activation: WorkflowActivateMode,
|
||||
isTest?: boolean,
|
||||
webhookData?: IWebhookData,
|
||||
): IHookFunctions;
|
||||
}
|
||||
@@ -1660,6 +1659,7 @@ export interface IWebhookData {
|
||||
workflowId: string;
|
||||
workflowExecuteAdditionalData: IWorkflowExecuteAdditionalData;
|
||||
webhookId?: string;
|
||||
isTest?: boolean;
|
||||
}
|
||||
|
||||
export interface IWebhookDescription {
|
||||
|
||||
@@ -1009,7 +1009,6 @@ export class Workflow {
|
||||
nodeExecuteFunctions: INodeExecuteFunctions,
|
||||
mode: WorkflowExecuteMode,
|
||||
activation: WorkflowActivateMode,
|
||||
isTest?: boolean,
|
||||
): Promise<void> {
|
||||
const webhookExists = await this.runWebhookMethod(
|
||||
'checkExists',
|
||||
@@ -1017,18 +1016,10 @@ export class Workflow {
|
||||
nodeExecuteFunctions,
|
||||
mode,
|
||||
activation,
|
||||
isTest,
|
||||
);
|
||||
if (!webhookExists) {
|
||||
// If webhook does not exist yet create it
|
||||
await this.runWebhookMethod(
|
||||
'create',
|
||||
webhookData,
|
||||
nodeExecuteFunctions,
|
||||
mode,
|
||||
activation,
|
||||
isTest,
|
||||
);
|
||||
await this.runWebhookMethod('create', webhookData, nodeExecuteFunctions, mode, activation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,16 +1028,8 @@ export class Workflow {
|
||||
nodeExecuteFunctions: INodeExecuteFunctions,
|
||||
mode: WorkflowExecuteMode,
|
||||
activation: WorkflowActivateMode,
|
||||
isTest?: boolean,
|
||||
) {
|
||||
await this.runWebhookMethod(
|
||||
'delete',
|
||||
webhookData,
|
||||
nodeExecuteFunctions,
|
||||
mode,
|
||||
activation,
|
||||
isTest,
|
||||
);
|
||||
await this.runWebhookMethod('delete', webhookData, nodeExecuteFunctions, mode, activation);
|
||||
}
|
||||
|
||||
private async runWebhookMethod(
|
||||
@@ -1055,7 +1038,6 @@ export class Workflow {
|
||||
nodeExecuteFunctions: INodeExecuteFunctions,
|
||||
mode: WorkflowExecuteMode,
|
||||
activation: WorkflowActivateMode,
|
||||
isTest?: boolean,
|
||||
): Promise<boolean | undefined> {
|
||||
const node = this.getNode(webhookData.node);
|
||||
|
||||
@@ -1072,7 +1054,6 @@ export class Workflow {
|
||||
webhookData.workflowExecuteAdditionalData,
|
||||
mode,
|
||||
activation,
|
||||
isTest,
|
||||
webhookData,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user