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
|
|
|
|
|
|
|
const inputs: any = { automationId: newAutomation._id, timeout: 12000 }
|
|
|
|
const res = await setup.runStep(setup.actions.TRIGGER.stepId, inputs)
|
|
|
|
// 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 () => {
|
|
|
|
const inputs: any = { automationId: null, timeout: 12000 }
|
|
|
|
const res = await setup.runStep(setup.actions.TRIGGER.stepId, inputs)
|
|
|
|
expect(res.success).toBe(false)
|
|
|
|
})
|
|
|
|
})
|