diff --git a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte index 45594c0f0d..439db62639 100644 --- a/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte +++ b/packages/builder/src/components/automation/AutomationBuilder/FlowChart/FlowItem.svelte @@ -14,7 +14,6 @@ $: allowDeleteTrigger = !steps.length function deleteStep() { - console.log("Running") automationStore.actions.deleteAutomationBlock(block) } diff --git a/packages/server/__mocks__/node-fetch.js b/packages/server/__mocks__/node-fetch.js index dfca7fd379..a06d026f38 100644 --- a/packages/server/__mocks__/node-fetch.js +++ b/packages/server/__mocks__/node-fetch.js @@ -4,6 +4,11 @@ module.exports = async (url, opts) => { function json(body, status = 200) { return { status, + headers: { + get: () => { + return ["application/json"] + }, + }, json: async () => { return body }, diff --git a/packages/server/src/automations/steps/outgoingWebhook.js b/packages/server/src/automations/steps/outgoingWebhook.js index 3e56834d3f..269e075018 100644 --- a/packages/server/src/automations/steps/outgoingWebhook.js +++ b/packages/server/src/automations/steps/outgoingWebhook.js @@ -77,7 +77,10 @@ module.exports.run = async function ({ inputs }) { requestBody.length !== 0 && BODY_REQUESTS.indexOf(requestMethod) !== -1 ) { - request.body = requestBody + request.body = + typeof requestBody === "string" + ? requestBody + : JSON.stringify(requestBody) request.headers = { "Content-Type": "application/json", } diff --git a/packages/server/src/automations/tests/outgoingWebhook.spec.js b/packages/server/src/automations/tests/outgoingWebhook.spec.js index f1d8d25ba8..9f82fb7604 100644 --- a/packages/server/src/automations/tests/outgoingWebhook.spec.js +++ b/packages/server/src/automations/tests/outgoingWebhook.spec.js @@ -25,7 +25,7 @@ describe("test the outgoing webhook action", () => { expect(res.success).toEqual(true) expect(res.response.url).toEqual("http://www.test.com") expect(res.response.method).toEqual("POST") - expect(res.response.body.a).toEqual(1) + expect(JSON.parse(res.response.body).a).toEqual(1) }) it("should return an error if something goes wrong in fetch", async () => {