From b491d8c784eab30b128e6c5d648bfffbbcc3a7eb Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 4 Feb 2025 11:16:27 +0000 Subject: [PATCH] Fix a few more test files. --- .../server/src/api/routes/tests/row.spec.ts | 1 - .../src/automations/tests/branching.spec.ts | 43 +++---------------- .../automations/tests/steps/updateRow.spec.ts | 30 +++---------- .../tests/triggers/webhook.spec.ts | 11 ++--- 4 files changed, 15 insertions(+), 70 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index 70a0bb2de9..87002670b7 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -39,7 +39,6 @@ import { RowExportFormat, RelationSchemaField, FormulaResponseType, - MonthlyQuotaName, } from "@budibase/types" import { generator, mocks } from "@budibase/backend-core/tests" import _, { merge } from "lodash" diff --git a/packages/server/src/automations/tests/branching.spec.ts b/packages/server/src/automations/tests/branching.spec.ts index c2e3f50b8a..1a514e0537 100644 --- a/packages/server/src/automations/tests/branching.spec.ts +++ b/packages/server/src/automations/tests/branching.spec.ts @@ -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({ diff --git a/packages/server/src/automations/tests/steps/updateRow.spec.ts b/packages/server/src/automations/tests/steps/updateRow.spec.ts index 5dc80e2df0..79fed5f613 100644 --- a/packages/server/src/automations/tests/steps/updateRow.spec.ts +++ b/packages/server/src/automations/tests/steps/updateRow.spec.ts @@ -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!, diff --git a/packages/server/src/automations/tests/triggers/webhook.spec.ts b/packages/server/src/automations/tests/triggers/webhook.spec.ts index bce454371f..2e0df5de49 100644 --- a/packages/server/src/automations/tests/triggers/webhook.spec.ts +++ b/packages/server/src/automations/tests/triggers/webhook.spec.ts @@ -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!,