Merge branch 'master' of github.com:budibase/budibase into demock-dynamodb

This commit is contained in:
Sam Rose 2025-03-03 17:43:17 +00:00
commit fc4f4e695a
No known key found for this signature in database
27 changed files with 43 additions and 17 deletions

View File

@ -6,6 +6,7 @@ import {
docIds,
MAX_VALID_DATE,
MIN_VALID_DATE,
setEnv,
SQLITE_DESIGN_DOC_ID,
utils,
withEnv as withCoreEnv,
@ -43,19 +44,7 @@ import { generator, structures, mocks } from "@budibase/backend-core/tests"
import { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default"
import { generateRowIdField } from "../../../integrations/utils"
import { cloneDeep } from "lodash/fp"
jest.mock("@budibase/pro", () => ({
...jest.requireActual("@budibase/pro"),
ai: {
LargeLanguageModel: {
forCurrentTenant: async () => ({
llm: {},
run: jest.fn(() => `Mock LLM Response`),
buildPromptFromAIOperation: jest.fn(),
}),
},
},
}))
import { mockChatGPTResponse } from "../../../tests/utilities/mocks/openai"
const descriptions = datasourceDescribe({ plus: true })
@ -1896,11 +1885,15 @@ if (descriptions.length) {
!isInMemory &&
describe("AI Column", () => {
const UNEXISTING_AI_COLUMN = "Real LLM Response"
let envCleanup: () => void
beforeAll(async () => {
mocks.licenses.useBudibaseAI()
mocks.licenses.useAICustomConfigs()
envCleanup = setEnv({ OPENAI_API_KEY: "mock" })
mockChatGPTResponse("Mock LLM Response")
tableOrViewId = await createTableOrView({
product: { name: "product", type: FieldType.STRING },
ai: {
@ -1917,6 +1910,10 @@ if (descriptions.length) {
])
})
afterAll(() => {
envCleanup()
})
describe("equal", () => {
it("successfully finds rows based on AI column", async () => {
await expectQuery({

View File

@ -16,6 +16,7 @@ describe("Execute Bash Automations", () => {
name: "test row",
description: "test description",
})
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -33,6 +33,7 @@ describe("test the create row action", () => {
name: "test",
description: "test",
}
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -6,6 +6,7 @@ describe("test the delay logic", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -13,6 +13,7 @@ describe("test the delete row action", () => {
await config.init()
table = await config.api.table.save(basicTable())
row = await config.api.row.save(table._id!, {})
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -7,6 +7,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -26,6 +26,7 @@ if (descriptions.length) {
const ds = await dsProvider()
datasource = ds.datasource!
client = ds.client!
await config.api.automation.deleteAll()
})
beforeEach(async () => {

View File

@ -13,6 +13,7 @@ describe("Execute Script Automations", () => {
await config.init()
table = await config.api.table.save(basicTable())
await config.api.row.save(table._id!, {})
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -26,6 +26,7 @@ describe("test the filter logic", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -22,10 +22,7 @@ describe("Attempt to run a basic loop automation", () => {
})
beforeEach(async () => {
const { automations } = await config.api.automation.fetch()
for (const automation of automations) {
await config.api.automation.delete(automation)
}
await config.api.automation.deleteAll()
table = await config.api.table.save(basicTable())
await config.api.row.save(table._id!, {})

View File

@ -7,6 +7,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -8,6 +8,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -16,6 +16,7 @@ describe("test the openai action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
beforeEach(() => {

View File

@ -8,6 +8,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -21,6 +21,7 @@ describe("Test a query step automation", () => {
}
await config.api.row.save(table._id!, row)
await config.api.row.save(table._id!, row)
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -28,6 +28,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -6,6 +6,7 @@ describe("test the server log action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -9,6 +9,7 @@ describe("Test triggering an automation from another automation", () => {
beforeAll(async () => {
await automation.init()
await config.init()
await config.api.automation.deleteAll()
})
afterAll(async () => {

View File

@ -23,6 +23,7 @@ describe("test the update row action", () => {
await config.init()
table = await config.createTable()
row = await config.createRow()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -7,6 +7,7 @@ describe("test the outgoing webhook action", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -9,6 +9,8 @@ describe("app action trigger", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
automation = await createAutomationBuilder(config)
.onAppAction()
.serverLog({

View File

@ -16,6 +16,7 @@ describe("cron trigger", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
})
afterAll(() => {

View File

@ -11,6 +11,7 @@ describe("row deleted trigger", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
table = await config.api.table.save(basicTable())
automation = await createAutomationBuilder(config)
.onRowDeleted({ tableId: table._id! })

View File

@ -11,6 +11,7 @@ describe("row saved trigger", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
table = await config.api.table.save(basicTable())
automation = await createAutomationBuilder(config)
.onRowSaved({ tableId: table._id! })

View File

@ -11,6 +11,7 @@ describe("row updated trigger", () => {
beforeAll(async () => {
await config.init()
await config.api.automation.deleteAll()
table = await config.api.table.save(basicTable())
automation = await createAutomationBuilder(config)
.onRowUpdated({ tableId: table._id! })

View File

@ -37,6 +37,7 @@ describe("Webhook trigger test", () => {
beforeEach(async () => {
await config.init()
await config.api.automation.deleteAll()
table = await config.createTable()
})

View File

@ -133,4 +133,11 @@ export class AutomationAPI extends TestAPI {
}
)
}
deleteAll = async (expectations?: Expectations): Promise<void> => {
const { automations } = await this.fetch()
await Promise.all(
automations.map(automation => this.delete(automation, expectations))
)
}
}