budibase/packages/server/src/automations/tests/triggerAutomationRun.spec.ts

41 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-01-05 17:12:31 +01:00
jest.spyOn(global.console, "error")
import * as setup from "./utilities"
import * as automation from "../index"
2024-01-11 15:13:59 +01:00
import { serverLogAutomation } from "../../tests/utilities/structures"
2024-01-05 17:12:31 +01:00
describe("Test triggering an automation from another automation", () => {
let config = setup.getConfig()
beforeAll(async () => {
await automation.init()
await config.init()
})
afterAll(async () => {
await automation.shutdown()
setup.afterAll()
})
it("should trigger an other server log automation", async () => {
2024-01-11 15:13:59 +01:00
let automation = serverLogAutomation()
let newAutomation = await config.createAutomation(automation)
2024-01-05 17:12:31 +01:00
2024-01-11 16:41:41 +01:00
const inputs: any = {
automation: { automationId: newAutomation._id, timeout: 12000 },
}
2024-01-16 17:22:11 +01:00
const res = await setup.runStep(
setup.actions.TRIGGER_AUTOMATION_RUN.stepId,
inputs
)
2024-01-05 17:12:31 +01:00
// Check if the SERVER_LOG step was successful
expect(res.value[1].outputs.success).toBe(true)
})
it("should fail gracefully if the automation id is incorrect", async () => {
2024-01-11 16:41:41 +01:00
const inputs: any = { automation: { automationId: null, timeout: 12000 } }
2024-01-05 17:12:31 +01:00
const res = await setup.runStep(setup.actions.TRIGGER.stepId, inputs)
expect(res.success).toBe(false)
})
})