Fix a few more test files.
This commit is contained in:
parent
8068c83c9c
commit
b491d8c784
|
@ -39,7 +39,6 @@ import {
|
||||||
RowExportFormat,
|
RowExportFormat,
|
||||||
RelationSchemaField,
|
RelationSchemaField,
|
||||||
FormulaResponseType,
|
FormulaResponseType,
|
||||||
MonthlyQuotaName,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||||
import _, { merge } from "lodash"
|
import _, { merge } from "lodash"
|
||||||
|
|
|
@ -24,11 +24,7 @@ describe("Branching automations", () => {
|
||||||
const branch2LogId = "33333333-3333-3333-3333-333333333333"
|
const branch2LogId = "33333333-3333-3333-3333-333333333333"
|
||||||
const branch2Id = "44444444-4444-4444-4444-444444444444"
|
const branch2Id = "44444444-4444-4444-4444-444444444444"
|
||||||
|
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Test Trigger with Loop and Create Row",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.serverLog(
|
.serverLog(
|
||||||
{ text: "Starting automation" },
|
{ text: "Starting automation" },
|
||||||
|
@ -87,11 +83,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should execute correct branch based on string equality", async () => {
|
it("should execute correct branch based on string equality", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "String Equality Branching",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { status: "active" } })
|
.appAction({ fields: { status: "active" } })
|
||||||
.branch({
|
.branch({
|
||||||
activeBranch: {
|
activeBranch: {
|
||||||
|
@ -116,11 +108,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle multiple conditions with AND operator", async () => {
|
it("should handle multiple conditions with AND operator", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Multiple AND Conditions Branching",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { status: "active", role: "admin" } })
|
.appAction({ fields: { status: "active", role: "admin" } })
|
||||||
.branch({
|
.branch({
|
||||||
activeAdminBranch: {
|
activeAdminBranch: {
|
||||||
|
@ -148,11 +136,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should handle multiple conditions with OR operator", async () => {
|
it("should handle multiple conditions with OR operator", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Multiple OR Conditions Branching",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { status: "test", role: "user" } })
|
.appAction({ fields: { status: "test", role: "user" } })
|
||||||
.branch({
|
.branch({
|
||||||
specialBranch: {
|
specialBranch: {
|
||||||
|
@ -184,11 +168,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should stop the branch automation when no conditions are met", async () => {
|
it("should stop the branch automation when no conditions are met", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Multiple OR Conditions Branching",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { status: "test", role: "user" } })
|
.appAction({ fields: { status: "test", role: "user" } })
|
||||||
.createRow({ row: { name: "Test", tableId: table._id } })
|
.createRow({ row: { name: "Test", tableId: table._id } })
|
||||||
.branch({
|
.branch({
|
||||||
|
@ -215,7 +195,6 @@ describe("Branching automations", () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.serverLog({ text: "Test" })
|
|
||||||
.run()
|
.run()
|
||||||
|
|
||||||
expect(results.steps[1].outputs.status).toEqual(
|
expect(results.steps[1].outputs.status).toEqual(
|
||||||
|
@ -225,11 +204,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("evaluate multiple conditions", async () => {
|
it("evaluate multiple conditions", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "evaluate multiple conditions",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { test_trigger: true } })
|
.appAction({ fields: { test_trigger: true } })
|
||||||
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
|
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
|
||||||
.branch({
|
.branch({
|
||||||
|
@ -270,11 +245,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("evaluate multiple conditions with interpolated text", async () => {
|
it("evaluate multiple conditions with interpolated text", async () => {
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "evaluate multiple conditions",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: { test_trigger: true } })
|
.appAction({ fields: { test_trigger: true } })
|
||||||
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
|
.serverLog({ text: "Starting automation" }, { stepId: "aN6znRYHG" })
|
||||||
.branch({
|
.branch({
|
||||||
|
|
|
@ -30,11 +30,7 @@ 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 builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Update Row Automation",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.updateRow({
|
.updateRow({
|
||||||
rowId: row._id!,
|
rowId: row._id!,
|
||||||
|
@ -57,11 +53,7 @@ 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 builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Invalid Inputs Automation",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.updateRow({ meta: {}, row: {}, rowId: "" })
|
.updateRow({ meta: {}, row: {}, rowId: "" })
|
||||||
.run()
|
.run()
|
||||||
|
@ -70,11 +62,7 @@ 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 builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Nonexistent Table Automation",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.updateRow({
|
.updateRow({
|
||||||
row: { _id: "invalid" },
|
row: { _id: "invalid" },
|
||||||
|
@ -118,11 +106,7 @@ describe("test the update row action", () => {
|
||||||
user2: [{ _id: user2._id }],
|
user2: [{ _id: user2._id }],
|
||||||
})
|
})
|
||||||
|
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Link Preservation Automation",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.updateRow({
|
.updateRow({
|
||||||
rowId: row._id!,
|
rowId: row._id!,
|
||||||
|
@ -176,11 +160,7 @@ describe("test the update row action", () => {
|
||||||
user2: [{ _id: user2._id }],
|
user2: [{ _id: user2._id }],
|
||||||
})
|
})
|
||||||
|
|
||||||
const builder = createAutomationBuilder({
|
const results = await createAutomationBuilder({ config })
|
||||||
name: "Link Overwrite Automation",
|
|
||||||
})
|
|
||||||
|
|
||||||
const results = await builder
|
|
||||||
.appAction({ fields: {} })
|
.appAction({ fields: {} })
|
||||||
.updateRow({
|
.updateRow({
|
||||||
rowId: row._id!,
|
rowId: row._id!,
|
||||||
|
|
|
@ -11,11 +11,8 @@ describe("Branching automations", () => {
|
||||||
let table: Table
|
let table: Table
|
||||||
let webhook: Webhook
|
let webhook: Webhook
|
||||||
|
|
||||||
async function createWebhookAutomation(testName: string) {
|
async function createWebhookAutomation() {
|
||||||
const builder = createAutomationBuilder({
|
const automation = await createAutomationBuilder({ config })
|
||||||
name: testName,
|
|
||||||
})
|
|
||||||
const automation = await builder
|
|
||||||
.webhook({ fields: { parameter: "string" } })
|
.webhook({ fields: { parameter: "string" } })
|
||||||
.createRow({
|
.createRow({
|
||||||
row: { tableId: table._id!, name: "{{ trigger.parameter }}" },
|
row: { tableId: table._id!, name: "{{ trigger.parameter }}" },
|
||||||
|
@ -50,9 +47,7 @@ describe("Branching automations", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should run the webhook automation - checking for parameters", async () => {
|
it("should run the webhook automation - checking for parameters", async () => {
|
||||||
const { webhook } = await createWebhookAutomation(
|
const { webhook } = await createWebhookAutomation()
|
||||||
"Check a basic webhook works as expected"
|
|
||||||
)
|
|
||||||
const res = await config.api.webhook.trigger(
|
const res = await config.api.webhook.trigger(
|
||||||
config.getProdAppId(),
|
config.getProdAppId(),
|
||||||
webhook._id!,
|
webhook._id!,
|
||||||
|
|
Loading…
Reference in New Issue