Missed a bunch of spots in the refactor.

This commit is contained in:
Sam Rose 2025-02-06 16:44:47 +00:00
parent 924f400992
commit 03e4cfe0b4
No known key found for this signature in database
14 changed files with 125 additions and 93 deletions

View File

@ -25,7 +25,7 @@ describe("Execute Bash Automations", () => {
it("should use trigger data in bash command and pass output to subsequent steps", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { command: "hello world" } })
.onAppAction()
.bash(
{ code: "echo '{{ trigger.fields.command }}'" },
{ stepName: "Echo Command" }
@ -34,7 +34,7 @@ describe("Execute Bash Automations", () => {
{ text: "Bash output was: {{ steps.[Echo Command].stdout }}" },
{ stepName: "Log Output" }
)
.test()
.test({ fields: { command: "hello world" } })
expect(result.steps[0].outputs.stdout).toEqual("hello world\n")
expect(result.steps[1].outputs.message).toContain(
@ -44,7 +44,7 @@ describe("Execute Bash Automations", () => {
it("should chain multiple bash commands using previous outputs", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { filename: "testfile.txt" } })
.onAppAction()
.bash(
{ code: "echo 'initial content' > {{ trigger.fields.filename }}" },
{ stepName: "Create File" }
@ -57,7 +57,7 @@ describe("Execute Bash Automations", () => {
{ code: "rm {{ trigger.fields.filename }}" },
{ stepName: "Cleanup" }
)
.test()
.test({ fields: { filename: "testfile.txt" } })
expect(result.steps[1].outputs.stdout).toEqual("INITIAL CONTENT\n")
expect(result.steps[1].outputs.success).toEqual(true)
@ -65,6 +65,7 @@ describe("Execute Bash Automations", () => {
it("should integrate bash output with row operations", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.queryRows(
{
tableId: table._id!,
@ -82,7 +83,7 @@ describe("Execute Bash Automations", () => {
{ text: "{{ steps.[Process Row Data].stdout }}" },
{ stepName: "Log Result" }
)
.run()
.test({ fields: {} })
expect(result.steps[1].outputs.stdout).toContain(
"Row data: test row - test description"
@ -94,7 +95,7 @@ describe("Execute Bash Automations", () => {
it("should handle bash output in conditional logic", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { threshold: "5" } })
.onAppAction()
.bash(
{ code: "echo $(( {{ trigger.fields.threshold }} + 5 ))" },
{ stepName: "Calculate Value" }
@ -112,7 +113,7 @@ describe("Execute Bash Automations", () => {
{ text: "Value was {{ steps.[Check Value].value }}" },
{ stepName: "Log Result" }
)
.test()
.test({ fields: { threshold: "5" } })
expect(result.steps[0].outputs.stdout).toEqual("10\n")
expect(result.steps[1].outputs.value).toEqual("high")
@ -121,12 +122,13 @@ describe("Execute Bash Automations", () => {
it("should handle null values gracefully", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.bash(
// @ts-expect-error - testing null input
{ code: null },
{ stepName: "Null Command" }
)
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.stdout).toBe(
"Budibase bash automation failed: Invalid inputs"

View File

@ -41,14 +41,14 @@ describe("test the create row action", () => {
it("should be able to run the action", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { status: "new" } })
.onAppAction()
.serverLog({ text: "Starting create row flow" }, { stepName: "StartLog" })
.createRow({ row }, { stepName: "CreateRow" })
.serverLog(
{ text: "Row created with ID: {{ stepsByName.CreateRow.row._id }}" },
{ stepName: "CreationLog" }
)
.test()
.test({ fields: { status: "new" } })
expect(result.steps[1].outputs.success).toBeDefined()
expect(result.steps[1].outputs.id).toBeDefined()
@ -67,7 +67,7 @@ describe("test the create row action", () => {
it("should return an error (not throw) when bad info provided", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { status: "error" } })
.onAppAction()
.serverLog({ text: "Starting error test flow" }, { stepName: "StartLog" })
.createRow(
{
@ -78,14 +78,14 @@ describe("test the create row action", () => {
},
{ stepName: "CreateRow" }
)
.test()
.test({ fields: { status: "error" } })
expect(result.steps[1].outputs.success).toEqual(false)
})
it("should check invalid inputs return an error", async () => {
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { status: "invalid" } })
.onAppAction()
.serverLog({ text: "Testing invalid input" }, { stepName: "StartLog" })
.createRow({ row: {} }, { stepName: "CreateRow" })
.filter({
@ -97,7 +97,7 @@ describe("test the create row action", () => {
{ text: "This log should not appear" },
{ stepName: "SkippedLog" }
)
.test()
.test({ fields: { status: "invalid" } })
expect(result.steps[1].outputs.success).toEqual(false)
expect(result.steps.length).toBeLessThan(4)
@ -123,7 +123,7 @@ describe("test the create row action", () => {
attachmentRow.file_attachment = attachmentObject
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { type: "attachment" } })
.onAppAction()
.serverLog(
{ text: "Processing attachment upload" },
{ stepName: "StartLog" }
@ -140,7 +140,7 @@ describe("test the create row action", () => {
},
{ stepName: "UploadLog" }
)
.test()
.test({ fields: { type: "attachment" } })
expect(result.steps[1].outputs.success).toEqual(true)
expect(result.steps[1].outputs.row.file_attachment[0]).toHaveProperty("key")
@ -174,7 +174,7 @@ describe("test the create row action", () => {
attachmentRow.single_file_attachment = attachmentObject
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { type: "single-attachment" } })
.onAppAction()
.serverLog(
{ text: "Processing single attachment" },
{ stepName: "StartLog" }
@ -209,7 +209,7 @@ describe("test the create row action", () => {
},
},
})
.test()
.test({ fields: { type: "single-attachment" } })
expect(result.steps[1].outputs.success).toEqual(true)
expect(result.steps[1].outputs.row.single_file_attachment).toHaveProperty(
@ -245,7 +245,7 @@ describe("test the create row action", () => {
attachmentRow.single_file_attachment = attachmentObject
const result = await createAutomationBuilder(config)
.onAppAction({ fields: { type: "invalid-attachment" } })
.onAppAction()
.serverLog(
{ text: "Testing invalid attachment keys" },
{ stepName: "StartLog" }
@ -278,7 +278,7 @@ describe("test the create row action", () => {
},
},
})
.test()
.test({ fields: { type: "invalid-attachment" } })
expect(result.steps[1].outputs.success).toEqual(false)
expect(result.steps[1].outputs.response).toEqual(

View File

@ -16,7 +16,10 @@ describe("test the delay logic", () => {
const time = 100
const before = performance.now()
await createAutomationBuilder(config).delay({ time }).run()
await createAutomationBuilder(config)
.onAppAction()
.delay({ time })
.test({ fields: {} })
const now = performance.now()

View File

@ -21,12 +21,13 @@ describe("test the delete row action", () => {
it("should be able to run the delete row action", async () => {
await createAutomationBuilder(config)
.onAppAction()
.deleteRow({
tableId: table._id!,
id: row._id!,
revision: row._rev,
})
.run()
.test({ fields: {} })
await config.api.row.get(table._id!, row._id!, {
status: 404,
@ -35,20 +36,22 @@ describe("test the delete row action", () => {
it("should check invalid inputs return an error", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.deleteRow({ tableId: "", id: "", revision: "" })
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(false)
})
it("should return an error when table doesn't exist", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.deleteRow({
tableId: "invalid",
id: "invalid",
revision: "invalid",
})
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(false)
})

View File

@ -20,12 +20,13 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action", async () => {
nock("http://www.example.com/").post("/").reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.discord({
url: "http://www.example.com",
username: "joe_bloggs",
content: "Hello, world",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response.foo).toEqual("bar")
expect(result.steps[0].outputs.success).toEqual(true)
})

View File

@ -43,8 +43,9 @@ describe("test the filter logic", () => {
]
it.each(pass)("should pass %p %p %p", async (field, condition, value) => {
const result = await createAutomationBuilder(config)
.onAppAction()
.filter({ field, condition: stringToFilterCondition(condition), value })
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.result).toEqual(true)
expect(result.steps[0].outputs.success).toEqual(true)
@ -60,8 +61,9 @@ describe("test the filter logic", () => {
]
it.each(fail)("should fail %p %p %p", async (field, condition, value) => {
const result = await createAutomationBuilder(config)
.onAppAction()
.filter({ field, condition: stringToFilterCondition(condition), value })
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.result).toEqual(false)
expect(result.steps[0].outputs.success).toEqual(true)

View File

@ -73,17 +73,7 @@ describe("Attempt to run a basic loop automation", () => {
it("should run an automation with a trigger, loop, and create row step", async () => {
const results = await createAutomationBuilder(config)
.onRowSaved(
{ tableId: table._id! },
{
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
}
)
.onRowSaved({ tableId: table._id! })
.loop({
option: LoopStepType.ARRAY,
binding: [1, 2, 3],
@ -95,7 +85,14 @@ describe("Attempt to run a basic loop automation", () => {
tableId: table._id,
},
})
.test()
.test({
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
})
expect(results.trigger).toBeDefined()
expect(results.steps).toHaveLength(1)
@ -116,17 +113,7 @@ describe("Attempt to run a basic loop automation", () => {
it("should run an automation where a loop step is between two normal steps to ensure context correctness", async () => {
const results = await createAutomationBuilder(config)
.onRowSaved(
{ tableId: table._id! },
{
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
}
)
.onRowSaved({ tableId: table._id! })
.queryRows({
tableId: table._id!,
})
@ -136,7 +123,14 @@ describe("Attempt to run a basic loop automation", () => {
})
.serverLog({ text: "Message {{loop.currentItem}}" })
.serverLog({ text: "{{steps.1.rows.0._id}}" })
.test()
.test({
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
})
results.steps[1].outputs.items.forEach(
(output: ServerLogStepOutputs, index: number) => {
@ -152,12 +146,13 @@ describe("Attempt to run a basic loop automation", () => {
it("if an incorrect type is passed to the loop it should return an error", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop({
option: LoopStepType.ARRAY,
binding: "1, 2, 3",
})
.serverLog({ text: "Message {{loop.currentItem}}" })
.run()
.test({ fields: {} })
expect(results.steps[0].outputs).toEqual({
success: false,
@ -167,13 +162,14 @@ describe("Attempt to run a basic loop automation", () => {
it("ensure the loop stops if the failure condition is reached", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop({
option: LoopStepType.ARRAY,
binding: ["test", "test2", "test3"],
failure: "test2",
})
.serverLog({ text: "Message {{loop.currentItem}}" })
.run()
.test({ fields: {} })
expect(results.steps[0].outputs).toEqual(
expect.objectContaining({
@ -185,6 +181,7 @@ describe("Attempt to run a basic loop automation", () => {
it("ensure the loop stops if the max iterations are reached", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop({
option: LoopStepType.ARRAY,
binding: ["test", "test2", "test3"],
@ -192,13 +189,14 @@ describe("Attempt to run a basic loop automation", () => {
})
.serverLog({ text: "{{loop.currentItem}}" })
.serverLog({ text: "{{steps.1.iterations}}" })
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.iterations).toBe(2)
})
it("should run an automation with loop and max iterations to ensure context correctness further down the tree", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop({
option: LoopStepType.ARRAY,
binding: ["test", "test2", "test3"],
@ -206,24 +204,14 @@ describe("Attempt to run a basic loop automation", () => {
})
.serverLog({ text: "{{loop.currentItem}}" })
.serverLog({ text: "{{steps.1.iterations}}" })
.run()
.test({ fields: {} })
expect(results.steps[1].outputs.message).toContain("- 2")
})
it("should run an automation where a loop is successfully run twice", async () => {
const results = await createAutomationBuilder(config)
.onRowSaved(
{ tableId: table._id! },
{
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
}
)
.onRowSaved({ tableId: table._id! })
.loop({
option: LoopStepType.ARRAY,
binding: [1, 2, 3],
@ -240,7 +228,14 @@ describe("Attempt to run a basic loop automation", () => {
binding: "Message 1,Message 2,Message 3",
})
.serverLog({ text: "{{loop.currentItem}}" })
.test()
.test({
row: {
name: "Trigger Row",
description: "This row triggers the automation",
},
id: "1234",
revision: "1",
})
expect(results.trigger).toBeDefined()
expect(results.steps).toHaveLength(2)
@ -275,6 +270,7 @@ describe("Attempt to run a basic loop automation", () => {
it("should run an automation where a loop is used twice to ensure context correctness further down the tree", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop({
option: LoopStepType.ARRAY,
binding: [1, 2, 3],
@ -287,7 +283,7 @@ describe("Attempt to run a basic loop automation", () => {
})
.serverLog({ text: "{{loop.currentItem}}" })
.serverLog({ text: "{{steps.3.iterations}}" })
.run()
.test({ fields: {} })
// We want to ensure that bindings are corr
expect(results.steps[1].outputs.message).toContain("- 3")
@ -296,6 +292,7 @@ describe("Attempt to run a basic loop automation", () => {
it("should use automation names to loop with", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.loop(
{
option: LoopStepType.ARRAY,
@ -311,7 +308,7 @@ describe("Attempt to run a basic loop automation", () => {
{ text: "{{steps.FirstLoopLog.iterations}}" },
{ stepName: "FirstLoopIterationLog" }
)
.run()
.test({ fields: {} })
expect(results.steps[1].outputs.message).toContain("- 3")
})
@ -347,6 +344,7 @@ describe("Attempt to run a basic loop automation", () => {
await config.api.row.bulkImport(table._id!, { rows })
const results = await createAutomationBuilder(config)
.onAppAction()
.queryRows({
tableId: table._id!,
})
@ -366,7 +364,7 @@ describe("Attempt to run a basic loop automation", () => {
.queryRows({
tableId: table._id!,
})
.run()
.test({ fields: {} })
const expectedRows = [
{ name: "Updated Row 1", value: 1 },
@ -426,6 +424,7 @@ describe("Attempt to run a basic loop automation", () => {
await config.api.row.bulkImport(table._id!, { rows })
const results = await createAutomationBuilder(config)
.onAppAction()
.queryRows(
{
tableId: table._id!,
@ -448,7 +447,7 @@ describe("Attempt to run a basic loop automation", () => {
.queryRows({
tableId: table._id!,
})
.run()
.test({ fields: {} })
const expectedRows = [
{ name: "Updated Row 1", value: 1 },
@ -508,6 +507,7 @@ describe("Attempt to run a basic loop automation", () => {
await config.api.row.bulkImport(table._id!, { rows })
const results = await createAutomationBuilder(config)
.onAppAction()
.queryRows({
tableId: table._id!,
})
@ -522,7 +522,7 @@ describe("Attempt to run a basic loop automation", () => {
.queryRows({
tableId: table._id!,
})
.run()
.test({ fields: {} })
expect(results.steps).toHaveLength(3)

View File

@ -20,11 +20,12 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action", async () => {
nock("http://www.example.com/").post("/").reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.make({
url: "http://www.example.com",
body: null,
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response.foo).toEqual("bar")
expect(result.steps[0].outputs.success).toEqual(true)
@ -46,11 +47,12 @@ describe("test the outgoing webhook action", () => {
.reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.make({
body: { value: JSON.stringify(payload) },
url: "http://www.example.com",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response.foo).toEqual("bar")
expect(result.steps[0].outputs.success).toEqual(true)
@ -58,11 +60,12 @@ describe("test the outgoing webhook action", () => {
it("should return a 400 if the JSON payload string is malformed", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.make({
body: { value: "{ invalid json }" },
url: "http://www.example.com",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.httpStatus).toEqual(400)
expect(result.steps[0].outputs.response).toEqual("Invalid payload JSON")

View File

@ -21,12 +21,13 @@ describe("test the outgoing webhook action", () => {
it("should be able to run the action and default to 'get'", async () => {
nock("http://www.example.com/").get("/").reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.n8n({
url: "http://www.example.com",
body: { test: "IGNORE_ME" },
authorization: "",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response).toEqual({ foo: "bar" })
expect(result.steps[0].outputs.httpStatus).toEqual(200)
@ -39,26 +40,28 @@ describe("test the outgoing webhook action", () => {
.reply(200)
const result = await createAutomationBuilder(config)
.onAppAction()
.n8n({
url: "http://www.example.com",
body: { value: JSON.stringify({ name: "Adam", age: 9 }) },
method: HttpMethod.POST,
authorization: "",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toEqual(true)
})
it("should return a 400 if the JSON payload string is malformed", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.n8n({
url: "http://www.example.com",
body: { value: "{ value1 1 }" },
method: HttpMethod.POST,
authorization: "",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.httpStatus).toEqual(400)
expect(result.steps[0].outputs.response).toEqual("Invalid payload JSON")
@ -71,13 +74,14 @@ describe("test the outgoing webhook action", () => {
.reply(200)
const result = await createAutomationBuilder(config)
.onAppAction()
.n8n({
url: "http://www.example.com",
method: HttpMethod.HEAD,
body: { test: "IGNORE_ME" },
authorization: "",
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toEqual(true)
})

View File

@ -24,13 +24,14 @@ describe("test the outgoing webhook action", () => {
.reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.outgoingWebhook({
requestMethod: RequestType.POST,
url: "http://www.example.com",
requestBody: JSON.stringify({ a: 1 }),
headers: {},
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toEqual(true)
expect(result.steps[0].outputs.httpStatus).toEqual(200)
@ -39,13 +40,14 @@ describe("test the outgoing webhook action", () => {
it("should return an error if something goes wrong in fetch", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.outgoingWebhook({
requestMethod: RequestType.GET,
url: "www.invalid.com",
requestBody: "",
headers: {},
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toEqual(false)
})
})

View File

@ -14,8 +14,9 @@ describe("test the server log action", () => {
it("should be able to log the text", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.serverLog({ text: "Hello World" })
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.message).toEqual(
`App ${config.getAppId()} - Hello World`
)

View File

@ -17,24 +17,27 @@ describe("Test triggering an automation from another automation", () => {
})
it("should trigger an other server log automation", async () => {
const automation = await createAutomationBuilder(config)
const { automation } = await createAutomationBuilder(config)
.onAppAction()
.serverLog({ text: "Hello World" })
.save()
const result = await createAutomationBuilder(config)
.onAppAction()
.triggerAutomationRun({
automation: {
automationId: automation._id!,
},
timeout: env.getDefaults().AUTOMATION_THREAD_TIMEOUT,
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toBe(true)
})
it("should fail gracefully if the automation id is incorrect", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.triggerAutomationRun({
automation: {
// @ts-expect-error - incorrect on purpose
@ -42,7 +45,7 @@ describe("Test triggering an automation from another automation", () => {
},
timeout: env.getDefaults().AUTOMATION_THREAD_TIMEOUT,
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toBe(false)
})

View File

@ -31,6 +31,7 @@ describe("test the update row action", () => {
it("should be able to run the update row action", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.updateRow({
rowId: row._id!,
row: {
@ -40,7 +41,7 @@ describe("test the update row action", () => {
},
meta: {},
})
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(true)
const updatedRow = await config.api.row.get(
@ -53,20 +54,22 @@ describe("test the update row action", () => {
it("should check invalid inputs return an error", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.updateRow({ meta: {}, row: {}, rowId: "" })
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(false)
})
it("should return an error when table doesn't exist", async () => {
const results = await createAutomationBuilder(config)
.onAppAction()
.updateRow({
row: { _id: "invalid" },
rowId: "invalid",
meta: {},
})
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(false)
})
@ -104,6 +107,7 @@ describe("test the update row action", () => {
})
const results = await createAutomationBuilder(config)
.onAppAction()
.updateRow({
rowId: row._id!,
row: {
@ -115,7 +119,7 @@ describe("test the update row action", () => {
},
meta: {},
})
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(true)
@ -157,6 +161,7 @@ describe("test the update row action", () => {
})
const results = await createAutomationBuilder(config)
.onAppAction()
.updateRow({
rowId: row._id!,
row: {
@ -174,7 +179,7 @@ describe("test the update row action", () => {
},
},
})
.run()
.test({ fields: {} })
expect(results.steps[0].outputs.success).toEqual(true)

View File

@ -21,8 +21,9 @@ describe("test the outgoing webhook action", () => {
nock("http://www.example.com/").post("/").reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.zapier({ url: "http://www.example.com", body: null })
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response.foo).toEqual("bar")
expect(result.steps[0].outputs.success).toEqual(true)
@ -44,11 +45,12 @@ describe("test the outgoing webhook action", () => {
.reply(200, { foo: "bar" })
const result = await createAutomationBuilder(config)
.onAppAction()
.zapier({
url: "http://www.example.com",
body: { value: JSON.stringify(payload) },
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.response.foo).toEqual("bar")
expect(result.steps[0].outputs.success).toEqual(true)
@ -56,11 +58,12 @@ describe("test the outgoing webhook action", () => {
it("should return a 400 if the JSON payload string is malformed", async () => {
const result = await createAutomationBuilder(config)
.onAppAction()
.zapier({
url: "http://www.example.com",
body: { value: "{ invalid json }" },
})
.run()
.test({ fields: {} })
expect(result.steps[0].outputs.success).toEqual(false)
expect(result.steps[0].outputs.response).toEqual("Invalid payload JSON")