Merge pull request #15661 from Budibase/demock-ai-column-tests

De-mock AI column search tests.
This commit is contained in:
Sam Rose 2025-03-03 17:00:16 +00:00 committed by GitHub
commit 69f21b2f3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 13 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({