Merge pull request #15661 from Budibase/demock-ai-column-tests
De-mock AI column search tests.
This commit is contained in:
commit
69f21b2f3a
|
@ -6,6 +6,7 @@ import {
|
||||||
docIds,
|
docIds,
|
||||||
MAX_VALID_DATE,
|
MAX_VALID_DATE,
|
||||||
MIN_VALID_DATE,
|
MIN_VALID_DATE,
|
||||||
|
setEnv,
|
||||||
SQLITE_DESIGN_DOC_ID,
|
SQLITE_DESIGN_DOC_ID,
|
||||||
utils,
|
utils,
|
||||||
withEnv as withCoreEnv,
|
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 { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default"
|
||||||
import { generateRowIdField } from "../../../integrations/utils"
|
import { generateRowIdField } from "../../../integrations/utils"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
import { mockChatGPTResponse } from "../../../tests/utilities/mocks/openai"
|
||||||
jest.mock("@budibase/pro", () => ({
|
|
||||||
...jest.requireActual("@budibase/pro"),
|
|
||||||
ai: {
|
|
||||||
LargeLanguageModel: {
|
|
||||||
forCurrentTenant: async () => ({
|
|
||||||
llm: {},
|
|
||||||
run: jest.fn(() => `Mock LLM Response`),
|
|
||||||
buildPromptFromAIOperation: jest.fn(),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}))
|
|
||||||
|
|
||||||
const descriptions = datasourceDescribe({ plus: true })
|
const descriptions = datasourceDescribe({ plus: true })
|
||||||
|
|
||||||
|
@ -1896,11 +1885,15 @@ if (descriptions.length) {
|
||||||
!isInMemory &&
|
!isInMemory &&
|
||||||
describe("AI Column", () => {
|
describe("AI Column", () => {
|
||||||
const UNEXISTING_AI_COLUMN = "Real LLM Response"
|
const UNEXISTING_AI_COLUMN = "Real LLM Response"
|
||||||
|
let envCleanup: () => void
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
mocks.licenses.useBudibaseAI()
|
mocks.licenses.useBudibaseAI()
|
||||||
mocks.licenses.useAICustomConfigs()
|
mocks.licenses.useAICustomConfigs()
|
||||||
|
|
||||||
|
envCleanup = setEnv({ OPENAI_API_KEY: "mock" })
|
||||||
|
mockChatGPTResponse("Mock LLM Response")
|
||||||
|
|
||||||
tableOrViewId = await createTableOrView({
|
tableOrViewId = await createTableOrView({
|
||||||
product: { name: "product", type: FieldType.STRING },
|
product: { name: "product", type: FieldType.STRING },
|
||||||
ai: {
|
ai: {
|
||||||
|
@ -1917,6 +1910,10 @@ if (descriptions.length) {
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
envCleanup()
|
||||||
|
})
|
||||||
|
|
||||||
describe("equal", () => {
|
describe("equal", () => {
|
||||||
it("successfully finds rows based on AI column", async () => {
|
it("successfully finds rows based on AI column", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
|
|
Loading…
Reference in New Issue