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

feat(core): Implement inter-main communication for test webhooks in multi-main setup #8267

Merged
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Renaming
  • Loading branch information
ivov committed Jan 10, 2024
commit ea7b4628020cb71912ab4598a32e5503905ce0b5
10 changes: 5 additions & 5 deletions packages/cli/src/TestWebhooks.ts
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ export class TestWebhooks implements IWebhookManager {

const { destinationNode, sessionId, workflowEntity } = registration;

const workflow = this.toTempWorkflow(workflowEntity);
const workflow = this.toWorkflow(workflowEntity);

const workflowStartNode = workflow.getNode(webhook.node);

@@ -189,7 +189,7 @@ export class TestWebhooks implements IWebhookManager {

const { workflowEntity } = registration;

const workflow = this.toTempWorkflow(workflowEntity);
const workflow = this.toWorkflow(workflowEntity);

const webhookNode = Object.values(workflow.nodes).find(
({ type, parameters, typeVersion }) =>
@@ -214,7 +214,7 @@ export class TestWebhooks implements IWebhookManager {
) {
if (!workflowEntity.id) throw new WorkflowMissingIdError(workflowEntity);

const workflow = this.toTempWorkflow(workflowEntity);
const workflow = this.toWorkflow(workflowEntity);

const webhooks = WebhookHelpers.getWorkflowWebhooks(
workflow,
@@ -285,7 +285,7 @@ export class TestWebhooks implements IWebhookManager {

const { sessionId, workflowEntity } = registration;

const workflow = this.toTempWorkflow(workflowEntity);
const workflow = this.toWorkflow(workflowEntity);

if (workflowEntity.id !== workflowId) continue;

@@ -380,7 +380,7 @@ export class TestWebhooks implements IWebhookManager {
/**
* Convert a `WorkflowEntity` from `typeorm` to a temporary `Workflow` from `n8n-workflow`.
*/
toTempWorkflow(workflowEntity: IWorkflowDb) {
toWorkflow(workflowEntity: IWorkflowDb) {
return new Workflow({
id: workflowEntity.id,
name: workflowEntity.name,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this file needs refactoring and cleanup, hopefully soon. Only added to it to avoid increasing the scope.

Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ export async function handleCommandMessageMain(messageString: string) {

testWebhooks.clearTimeout(webhookKey);

const workflow = testWebhooks.toTempWorkflow(workflowEntity);
const workflow = testWebhooks.toWorkflow(workflowEntity);

await testWebhooks.deactivateWebhooks(workflow);

2 changes: 1 addition & 1 deletion packages/cli/test/unit/TestWebhooks.test.ts
Original file line number Diff line number Diff line change
@@ -117,7 +117,7 @@ describe('TestWebhooks', () => {
test('should add additional data to workflow', async () => {
registrations.getAllRegistrations.mockResolvedValue([{ workflowEntity, webhook }]);

const workflow = testWebhooks.toTempWorkflow(workflowEntity);
const workflow = testWebhooks.toWorkflow(workflowEntity);

await testWebhooks.deactivateWebhooks(workflow);

Loading