mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(core): Fix test runs of triggers that rely on static data (#8524)
This commit is contained in:
parent
934d0d35b1
commit
528c07134a
|
@ -91,10 +91,12 @@ export class TestWebhooks implements IWebhookManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const { destinationNode, sessionId, workflowEntity } = registration;
|
const { destinationNode, sessionId, workflowEntity, webhook: testWebhook } = registration;
|
||||||
|
|
||||||
const workflow = this.toWorkflow(workflowEntity);
|
const workflow = this.toWorkflow(workflowEntity);
|
||||||
|
|
||||||
|
if (testWebhook.staticData) workflow.setTestStaticData(testWebhook.staticData);
|
||||||
|
|
||||||
const workflowStartNode = workflow.getNode(webhook.node);
|
const workflowStartNode = workflow.getNode(webhook.node);
|
||||||
|
|
||||||
if (workflowStartNode === null) {
|
if (workflowStartNode === null) {
|
||||||
|
@ -405,14 +407,7 @@ export class TestWebhooks implements IWebhookManager {
|
||||||
connections: workflowEntity.connections,
|
connections: workflowEntity.connections,
|
||||||
active: false,
|
active: false,
|
||||||
nodeTypes: this.nodeTypes,
|
nodeTypes: this.nodeTypes,
|
||||||
|
staticData: {},
|
||||||
/**
|
|
||||||
* `staticData` in the original workflow entity has production webhook IDs.
|
|
||||||
* Since we are creating here a temporary workflow only for a test webhook,
|
|
||||||
* `staticData` from the original workflow entity should not be transferred.
|
|
||||||
*/
|
|
||||||
staticData: undefined,
|
|
||||||
|
|
||||||
settings: workflowEntity.settings,
|
settings: workflowEntity.settings,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,8 @@ export class Workflow {
|
||||||
// ids of registered webhooks of nodes
|
// ids of registered webhooks of nodes
|
||||||
staticData: IDataObject;
|
staticData: IDataObject;
|
||||||
|
|
||||||
|
testStaticData: IDataObject | undefined;
|
||||||
|
|
||||||
pinData?: IPinData;
|
pinData?: IPinData;
|
||||||
|
|
||||||
// constructor(id: string | undefined, nodes: INode[], connections: IConnections, active: boolean, nodeTypes: INodeTypes, staticData?: IDataObject, settings?: IWorkflowSettings) {
|
// constructor(id: string | undefined, nodes: INode[], connections: IConnections, active: boolean, nodeTypes: INodeTypes, staticData?: IDataObject, settings?: IWorkflowSettings) {
|
||||||
|
@ -328,6 +330,8 @@ export class Workflow {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.testStaticData?.[key]) return this.testStaticData[key] as IDataObject;
|
||||||
|
|
||||||
if (this.staticData[key] === undefined) {
|
if (this.staticData[key] === undefined) {
|
||||||
// Create it as ObservableObject that we can easily check if the data changed
|
// Create it as ObservableObject that we can easily check if the data changed
|
||||||
// to know if the workflow with its data has to be saved afterwards or not.
|
// to know if the workflow with its data has to be saved afterwards or not.
|
||||||
|
@ -337,6 +341,10 @@ export class Workflow {
|
||||||
return this.staticData[key] as IDataObject;
|
return this.staticData[key] as IDataObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTestStaticData(testStaticData: IDataObject) {
|
||||||
|
this.testStaticData = testStaticData;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the trigger nodes in the workflow.
|
* Returns all the trigger nodes in the workflow.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue