Fix a few more test files.

This commit is contained in:
Sam Rose 2025-02-04 11:16:27 +00:00
parent 8068c83c9c
commit b491d8c784
No known key found for this signature in database
4 changed files with 15 additions and 70 deletions

View File

@ -39,7 +39,6 @@ import {
RowExportFormat,
RelationSchemaField,
FormulaResponseType,
MonthlyQuotaName,
} from "@budibase/types"
import { generator, mocks } from "@budibase/backend-core/tests"
import _, { merge } from "lodash"

View File

@ -24,11 +24,7 @@ describe("Branching automations", () => {
const branch2LogId = "33333333-3333-3333-3333-333333333333"
const branch2Id = "44444444-4444-4444-4444-444444444444"
const builder = createAutomationBuilder({
name: "Test Trigger with Loop and Create Row",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.serverLog(
{ text: "Starting automation" },
@ -87,11 +83,7 @@ describe("Branching automations", () => {
})
it("should execute correct branch based on string equality", async () => {
const builder = createAutomationBuilder({
name: "String Equality Branching",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { status: "active" } })
.branch({
activeBranch: {
@ -116,11 +108,7 @@ describe("Branching automations", () => {
})
it("should handle multiple conditions with AND operator", async () => {
const builder = createAutomationBuilder({
name: "Multiple AND Conditions Branching",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { status: "active", role: "admin" } })
.branch({
activeAdminBranch: {
@ -148,11 +136,7 @@ describe("Branching automations", () => {
})
it("should handle multiple conditions with OR operator", async () => {
const builder = createAutomationBuilder({
name: "Multiple OR Conditions Branching",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { status: "test", role: "user" } })
.branch({
specialBranch: {
@ -184,11 +168,7 @@ describe("Branching automations", () => {
})
it("should stop the branch automation when no conditions are met", async () => {
const builder = createAutomationBuilder({
name: "Multiple OR Conditions Branching",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { status: "test", role: "user" } })
.createRow({ row: { name: "Test", tableId: table._id } })
.branch({
@ -215,7 +195,6 @@ describe("Branching automations", () => {
},
},
})
.serverLog({ text: "Test" })
.run()
expect(results.steps[1].outputs.status).toEqual(
@ -225,11 +204,7 @@ describe("Branching automations", () => {
})
it("evaluate multiple conditions", async () => {
const builder = createAutomationBuilder({
name: "evaluate multiple conditions",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { test_trigger: true } })
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
.branch({
@ -270,11 +245,7 @@ describe("Branching automations", () => {
})
it("evaluate multiple conditions with interpolated text", async () => {
const builder = createAutomationBuilder({
name: "evaluate multiple conditions",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: { test_trigger: true } })
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
.branch({

View File

@ -30,11 +30,7 @@ describe("test the update row action", () => {
})
it("should be able to run the update row action", async () => {
const builder = createAutomationBuilder({
name: "Update Row Automation",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.updateRow({
rowId: row._id!,
@ -57,11 +53,7 @@ describe("test the update row action", () => {
})
it("should check invalid inputs return an error", async () => {
const builder = createAutomationBuilder({
name: "Invalid Inputs Automation",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.updateRow({ meta: {}, row: {}, rowId: "" })
.run()
@ -70,11 +62,7 @@ describe("test the update row action", () => {
})
it("should return an error when table doesn't exist", async () => {
const builder = createAutomationBuilder({
name: "Nonexistent Table Automation",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.updateRow({
row: { _id: "invalid" },
@ -118,11 +106,7 @@ describe("test the update row action", () => {
user2: [{ _id: user2._id }],
})
const builder = createAutomationBuilder({
name: "Link Preservation Automation",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.updateRow({
rowId: row._id!,
@ -176,11 +160,7 @@ describe("test the update row action", () => {
user2: [{ _id: user2._id }],
})
const builder = createAutomationBuilder({
name: "Link Overwrite Automation",
})
const results = await builder
const results = await createAutomationBuilder({ config })
.appAction({ fields: {} })
.updateRow({
rowId: row._id!,

View File

@ -11,11 +11,8 @@ describe("Branching automations", () => {
let table: Table
let webhook: Webhook
async function createWebhookAutomation(testName: string) {
const builder = createAutomationBuilder({
name: testName,
})
const automation = await builder
async function createWebhookAutomation() {
const automation = await createAutomationBuilder({ config })
.webhook({ fields: { parameter: "string" } })
.createRow({
row: { tableId: table._id!, name: "{{ trigger.parameter }}" },
@ -50,9 +47,7 @@ describe("Branching automations", () => {
})
it("should run the webhook automation - checking for parameters", async () => {
const { webhook } = await createWebhookAutomation(
"Check a basic webhook works as expected"
)
const { webhook } = await createWebhookAutomation()
const res = await config.api.webhook.trigger(
config.getProdAppId(),
webhook._id!,