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