Remove no longer needed appAction calls.
This commit is contained in:
parent
74f2ece72b
commit
d2902464c0
|
@ -257,7 +257,6 @@ describe("/automations", () => {
|
|||
appId: config.getAppId(),
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.serverLog({
|
||||
text: "{{ settings.url }}",
|
||||
})
|
||||
|
|
|
@ -25,7 +25,6 @@ describe("Branching automations", () => {
|
|||
const branch2Id = "44444444-4444-4444-4444-444444444444"
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.serverLog(
|
||||
{ text: "Starting automation" },
|
||||
{ stepName: "FirstLog", stepId: firstLogId }
|
||||
|
|
|
@ -66,7 +66,6 @@ describe("Automation Scenarios", () => {
|
|||
await config.api.row.save(table._id!, row)
|
||||
await config.api.row.save(table._id!, row)
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows({
|
||||
tableId: table._id!,
|
||||
})
|
||||
|
@ -85,7 +84,6 @@ describe("Automation Scenarios", () => {
|
|||
await config.api.row.save(table._id!, row)
|
||||
await config.api.row.save(table._id!, row)
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows({
|
||||
tableId: table._id!,
|
||||
})
|
||||
|
@ -127,7 +125,6 @@ describe("Automation Scenarios", () => {
|
|||
})
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.createRow(
|
||||
{
|
||||
row: {
|
||||
|
@ -196,7 +193,6 @@ describe("Automation Scenarios", () => {
|
|||
await config.api.row.save(table._id!, row)
|
||||
await config.api.row.save(table._id!, row)
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -246,7 +242,6 @@ describe("Automation Scenarios", () => {
|
|||
|
||||
it("should stop an automation if the condition is not met", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.createRow({
|
||||
row: {
|
||||
name: "Equal Test",
|
||||
|
@ -272,7 +267,6 @@ describe("Automation Scenarios", () => {
|
|||
|
||||
it("should continue the automation if the condition is met", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.createRow({
|
||||
row: {
|
||||
name: "Not Equal Test",
|
||||
|
@ -339,7 +333,6 @@ describe("Automation Scenarios", () => {
|
|||
"should pass the filter when condition is $condition",
|
||||
async ({ condition, value, rowValue, expectPass }) => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.createRow({
|
||||
row: {
|
||||
name: `${condition} Test`,
|
||||
|
@ -389,7 +382,6 @@ describe("Automation Scenarios", () => {
|
|||
|
||||
it("Check user is passed through from app trigger", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.serverLog({ text: "{{ [user].[email] }}" })
|
||||
.run()
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ describe("Execute Bash Automations", () => {
|
|||
|
||||
it("should integrate bash output with row operations", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -122,7 +121,6 @@ describe("Execute Bash Automations", () => {
|
|||
|
||||
it("should handle null values gracefully", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.bash(
|
||||
// @ts-expect-error - testing null input
|
||||
{ code: null },
|
||||
|
|
|
@ -16,10 +16,7 @@ describe("test the delay logic", () => {
|
|||
const time = 100
|
||||
const before = performance.now()
|
||||
|
||||
await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.delay({ time })
|
||||
.run()
|
||||
await createAutomationBuilder({ config }).delay({ time }).run()
|
||||
|
||||
const now = performance.now()
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ describe("test the delete row action", () => {
|
|||
|
||||
it("should be able to run the delete row action", async () => {
|
||||
await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({
|
||||
tableId: table._id!,
|
||||
id: row._id!,
|
||||
|
@ -36,7 +35,6 @@ describe("test the delete row action", () => {
|
|||
|
||||
it("should check invalid inputs return an error", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({ tableId: "", id: "", revision: "" })
|
||||
.run()
|
||||
|
||||
|
@ -45,7 +43,6 @@ describe("test the delete row action", () => {
|
|||
|
||||
it("should return an error when table doesn't exist", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.deleteRow({
|
||||
tableId: "invalid",
|
||||
id: "invalid",
|
||||
|
|
|
@ -20,7 +20,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.discord({
|
||||
url: "http://www.example.com",
|
||||
username: "joe_bloggs",
|
||||
|
|
|
@ -21,7 +21,6 @@ describe("Execute Script Automations", () => {
|
|||
|
||||
it("should execute a basic script and return the result", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.executeScript({ code: "return 2 + 2" })
|
||||
.run()
|
||||
|
||||
|
@ -44,7 +43,6 @@ describe("Execute Script Automations", () => {
|
|||
|
||||
it("should handle script execution errors gracefully", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.executeScript({ code: "return nonexistentVariable.map(x => x)" })
|
||||
.run()
|
||||
|
||||
|
@ -73,7 +71,6 @@ describe("Execute Script Automations", () => {
|
|||
|
||||
it("should use multiple steps and validate script execution", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.serverLog(
|
||||
{ text: "Starting multi-step automation" },
|
||||
{ stepId: "start-log-step" }
|
||||
|
|
|
@ -43,7 +43,6 @@ describe("test the filter logic", () => {
|
|||
]
|
||||
it.each(pass)("should pass %p %p %p", async (field, condition, value) => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.filter({ field, condition: stringToFilterCondition(condition), value })
|
||||
.run()
|
||||
|
||||
|
@ -61,7 +60,6 @@ describe("test the filter logic", () => {
|
|||
]
|
||||
it.each(fail)("should fail %p %p %p", async (field, condition, value) => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.filter({ field, condition: stringToFilterCondition(condition), value })
|
||||
.run()
|
||||
|
||||
|
|
|
@ -152,7 +152,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: "1, 2, 3",
|
||||
|
@ -168,7 +167,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: ["test", "test2", "test3"],
|
||||
|
@ -187,7 +185,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: ["test", "test2", "test3"],
|
||||
|
@ -202,7 +199,6 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
|
||||
it("should run an automation with loop and max iterations to ensure context correctness further down the tree", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: ["test", "test2", "test3"],
|
||||
|
@ -279,7 +275,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: [1, 2, 3],
|
||||
|
@ -301,7 +296,6 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
|
||||
it("should use automation names to loop with", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.loop(
|
||||
{
|
||||
option: LoopStepType.ARRAY,
|
||||
|
@ -353,7 +347,6 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
await config.api.row.bulkImport(table._id!, { rows })
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows({
|
||||
tableId: table._id!,
|
||||
})
|
||||
|
@ -433,7 +426,6 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
await config.api.row.bulkImport(table._id!, { rows })
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -516,7 +508,6 @@ describe("Attempt to run a basic loop automation", () => {
|
|||
await config.api.row.bulkImport(table._id!, { rows })
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.queryRows({
|
||||
tableId: table._id!,
|
||||
})
|
||||
|
|
|
@ -20,7 +20,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.make({
|
||||
url: "http://www.example.com",
|
||||
body: null,
|
||||
|
@ -47,7 +46,6 @@ describe("test the outgoing webhook action", () => {
|
|||
.reply(200, { foo: "bar" })
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.make({
|
||||
body: { value: JSON.stringify(payload) },
|
||||
url: "http://www.example.com",
|
||||
|
@ -60,7 +58,6 @@ describe("test the outgoing webhook action", () => {
|
|||
|
||||
it("should return a 400 if the JSON payload string is malformed", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.make({
|
||||
body: { value: "{ invalid json }" },
|
||||
url: "http://www.example.com",
|
||||
|
|
|
@ -21,7 +21,6 @@ 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 })
|
||||
.appAction({ fields: {} })
|
||||
.n8n({
|
||||
url: "http://www.example.com",
|
||||
body: { test: "IGNORE_ME" },
|
||||
|
@ -40,7 +39,6 @@ describe("test the outgoing webhook action", () => {
|
|||
.reply(200)
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.n8n({
|
||||
url: "http://www.example.com",
|
||||
body: { value: JSON.stringify({ name: "Adam", age: 9 }) },
|
||||
|
@ -54,7 +52,6 @@ describe("test the outgoing webhook action", () => {
|
|||
|
||||
it("should return a 400 if the JSON payload string is malformed", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.n8n({
|
||||
url: "http://www.example.com",
|
||||
body: { value: "{ value1 1 }" },
|
||||
|
@ -74,7 +71,6 @@ describe("test the outgoing webhook action", () => {
|
|||
.reply(200)
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.n8n({
|
||||
url: "http://www.example.com",
|
||||
method: HttpMethod.HEAD,
|
||||
|
|
|
@ -58,7 +58,6 @@ describe("test the openai action", () => {
|
|||
// own API key. We don't count this against your quota.
|
||||
const result = await expectAIUsage(0, () =>
|
||||
createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.openai({ prompt: "Hello, world", model: Model.GPT_4O_MINI })
|
||||
.run()
|
||||
)
|
||||
|
@ -70,7 +69,6 @@ describe("test the openai action", () => {
|
|||
it("should present the correct error message when a prompt is not provided", async () => {
|
||||
const result = await expectAIUsage(0, () =>
|
||||
createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.openai({ prompt: "", model: Model.GPT_4O_MINI })
|
||||
.run()
|
||||
)
|
||||
|
@ -86,7 +84,6 @@ describe("test the openai action", () => {
|
|||
|
||||
const result = await expectAIUsage(0, () =>
|
||||
createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.openai({ prompt: "Hello, world", model: Model.GPT_4O_MINI })
|
||||
.run()
|
||||
)
|
||||
|
@ -109,7 +106,6 @@ describe("test the openai action", () => {
|
|||
// key, so we charge users for it.
|
||||
const result = await expectAIUsage(14, () =>
|
||||
createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.openai({ model: Model.GPT_4O_MINI, prompt: "Hello, world" })
|
||||
.run()
|
||||
)
|
||||
|
|
|
@ -24,7 +24,6 @@ describe("test the outgoing webhook action", () => {
|
|||
.reply(200, { foo: "bar" })
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.outgoingWebhook({
|
||||
requestMethod: RequestType.POST,
|
||||
url: "http://www.example.com",
|
||||
|
@ -40,7 +39,6 @@ describe("test the outgoing webhook action", () => {
|
|||
|
||||
it("should return an error if something goes wrong in fetch", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.outgoingWebhook({
|
||||
requestMethod: RequestType.GET,
|
||||
url: "www.invalid.com",
|
||||
|
|
|
@ -32,7 +32,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Basic Query Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -60,7 +59,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Empty Filter Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -84,7 +82,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Return None Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -109,7 +106,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Null Filter Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -138,7 +134,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Return All Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: table._id!,
|
||||
|
@ -169,7 +164,6 @@ describe("Test a query step automation", () => {
|
|||
name: "Return All Test",
|
||||
config,
|
||||
})
|
||||
.appAction({ fields: {} })
|
||||
.queryRows(
|
||||
{
|
||||
tableId: tableWithSpaces._id!,
|
||||
|
|
|
@ -14,7 +14,6 @@ describe("test the server log action", () => {
|
|||
|
||||
it("should be able to log the text", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.serverLog({ text: "Hello World" })
|
||||
.run()
|
||||
expect(result.steps[0].outputs.message).toEqual(
|
||||
|
|
|
@ -18,12 +18,10 @@ describe("Test triggering an automation from another automation", () => {
|
|||
|
||||
it("should trigger an other server log automation", async () => {
|
||||
const automation = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.serverLog({ text: "Hello World" })
|
||||
.save()
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.triggerAutomationRun({
|
||||
automation: {
|
||||
automationId: automation._id!,
|
||||
|
@ -37,7 +35,6 @@ describe("Test triggering an automation from another automation", () => {
|
|||
|
||||
it("should fail gracefully if the automation id is incorrect", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.triggerAutomationRun({
|
||||
automation: {
|
||||
// @ts-expect-error - incorrect on purpose
|
||||
|
|
|
@ -31,7 +31,6 @@ describe("test the update row action", () => {
|
|||
|
||||
it("should be able to run the update row action", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({
|
||||
rowId: row._id!,
|
||||
row: {
|
||||
|
@ -54,7 +53,6 @@ describe("test the update row action", () => {
|
|||
|
||||
it("should check invalid inputs return an error", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({ meta: {}, row: {}, rowId: "" })
|
||||
.run()
|
||||
|
||||
|
@ -63,7 +61,6 @@ describe("test the update row action", () => {
|
|||
|
||||
it("should return an error when table doesn't exist", async () => {
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({
|
||||
row: { _id: "invalid" },
|
||||
rowId: "invalid",
|
||||
|
@ -107,7 +104,6 @@ describe("test the update row action", () => {
|
|||
})
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({
|
||||
rowId: row._id!,
|
||||
row: {
|
||||
|
@ -161,7 +157,6 @@ describe("test the update row action", () => {
|
|||
})
|
||||
|
||||
const results = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.updateRow({
|
||||
rowId: row._id!,
|
||||
row: {
|
||||
|
|
|
@ -21,7 +21,6 @@ describe("test the outgoing webhook action", () => {
|
|||
nock("http://www.example.com/").post("/").reply(200, { foo: "bar" })
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.zapier({ url: "http://www.example.com", body: null })
|
||||
.run()
|
||||
|
||||
|
@ -45,7 +44,6 @@ describe("test the outgoing webhook action", () => {
|
|||
.reply(200, { foo: "bar" })
|
||||
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.zapier({
|
||||
url: "http://www.example.com",
|
||||
body: { value: JSON.stringify(payload) },
|
||||
|
@ -58,7 +56,6 @@ describe("test the outgoing webhook action", () => {
|
|||
|
||||
it("should return a 400 if the JSON payload string is malformed", async () => {
|
||||
const result = await createAutomationBuilder({ config })
|
||||
.appAction({ fields: {} })
|
||||
.zapier({
|
||||
url: "http://www.example.com",
|
||||
body: { value: "{ invalid json }" },
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
import { createAutomationBuilder } from "../utilities/AutomationTestBuilder"
|
||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||
import { getQueue } from "../.."
|
||||
import { Job } from "bull"
|
||||
import { basicTable } from "../../../tests/utilities/structures"
|
||||
import { Table } from "@budibase/types"
|
||||
|
||||
describe("cron trigger", () => {
|
||||
const config = new TestConfiguration()
|
||||
let table: Table
|
||||
|
||||
beforeAll(async () => {
|
||||
await config.init()
|
||||
table = await config.api.table.save(basicTable())
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
config.end()
|
||||
})
|
||||
|
||||
it("should successfully fire", async () => {
|
||||
const queue = getQueue()
|
||||
expect(await queue.getCompletedCount()).toEqual(0)
|
||||
|
||||
const jobPromise = new Promise<Job>(resolve => {
|
||||
queue.on("completed", async job => {
|
||||
resolve(job)
|
||||
})
|
||||
})
|
||||
|
||||
await createAutomationBuilder({ config })
|
||||
.rowSaved({ tableId: table._id! })
|
||||
.cron({ cron: "* * * * *" })
|
||||
.serverLog({
|
||||
text: "Hello, world!",
|
||||
})
|
||||
.save()
|
||||
|
||||
await config.api.application.publish(config.getAppId())
|
||||
|
||||
expect(await queue.getCompletedCount()).toEqual(1)
|
||||
|
||||
const job = await jobPromise
|
||||
const repeat = job.opts?.repeat
|
||||
if (!repeat || !("cron" in repeat)) {
|
||||
throw new Error("Expected cron repeat")
|
||||
}
|
||||
expect(repeat.cron).toEqual("* * * * *")
|
||||
})
|
||||
|
||||
it("should fail if the cron expression is invalid", async () => {
|
||||
await createAutomationBuilder({ config })
|
||||
.cron({ cron: "* * * * * *" })
|
||||
.serverLog({
|
||||
text: "Hello, world!",
|
||||
})
|
||||
.save()
|
||||
|
||||
await config.api.application.publish(config.getAppId(), {
|
||||
status: 500,
|
||||
body: {
|
||||
message:
|
||||
'Deployment Failed: Invalid automation CRON "* * * * * *" - Expected 5 values, but got 6.',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
|
@ -158,7 +158,7 @@ class AutomationBuilder extends BaseStepBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
protected createTriggerFn<
|
||||
protected triggerInputOutput<
|
||||
TStep extends AutomationTriggerStepId,
|
||||
TInput = AutomationTriggerInputs<TStep>,
|
||||
TOutput = AutomationTriggerOutputs<TStep>
|
||||
|
@ -179,12 +179,28 @@ class AutomationBuilder extends BaseStepBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
rowSaved = this.createTriggerFn(AutomationTriggerStepId.ROW_SAVED)
|
||||
rowUpdated = this.createTriggerFn(AutomationTriggerStepId.ROW_UPDATED)
|
||||
rowDeleted = this.createTriggerFn(AutomationTriggerStepId.ROW_DELETED)
|
||||
appAction = this.createTriggerFn(AutomationTriggerStepId.APP)
|
||||
webhook = this.createTriggerFn(AutomationTriggerStepId.WEBHOOK)
|
||||
cron = this.createTriggerFn(AutomationTriggerStepId.CRON)
|
||||
protected triggerOutputOnly<
|
||||
TStep extends AutomationTriggerStepId,
|
||||
TOutput = AutomationTriggerOutputs<TStep>
|
||||
>(stepId: TStep) {
|
||||
return (outputs: TOutput) => {
|
||||
this.triggerOutputs = outputs as TriggerOutputs
|
||||
this.automationConfig.definition.trigger = {
|
||||
...TRIGGER_DEFINITIONS[stepId],
|
||||
stepId,
|
||||
id: uuidv4(),
|
||||
} as AutomationTrigger
|
||||
this.triggerSet = true
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
rowSaved = this.triggerInputOutput(AutomationTriggerStepId.ROW_SAVED)
|
||||
rowUpdated = this.triggerInputOutput(AutomationTriggerStepId.ROW_UPDATED)
|
||||
rowDeleted = this.triggerInputOutput(AutomationTriggerStepId.ROW_DELETED)
|
||||
appAction = this.triggerOutputOnly(AutomationTriggerStepId.APP)
|
||||
webhook = this.triggerInputOutput(AutomationTriggerStepId.WEBHOOK)
|
||||
cron = this.triggerInputOutput(AutomationTriggerStepId.CRON)
|
||||
|
||||
branch(branchConfig: BranchConfig): this {
|
||||
this.addBranchStep(branchConfig)
|
||||
|
|
Loading…
Reference in New Issue