unit test to cover
This commit is contained in:
parent
313bd9b017
commit
b06074128f
|
@ -1,4 +1,4 @@
|
|||
import { AutoFieldSubType, FieldType } from "@budibase/types"
|
||||
import { AIOperationEnum, AutoFieldSubType, FieldType } from "@budibase/types"
|
||||
import TestConfiguration from "../../../../tests/utilities/TestConfiguration"
|
||||
import { importToRows } from "../utils"
|
||||
|
||||
|
@ -92,5 +92,65 @@ describe("utils", () => {
|
|||
expect(result).toHaveLength(3)
|
||||
})
|
||||
})
|
||||
|
||||
it("Imports write as expected with AI columns", async () => {
|
||||
await config.doInContext(config.appId, async () => {
|
||||
const table = await config.createTable({
|
||||
name: "table",
|
||||
type: "table",
|
||||
schema: {
|
||||
autoId: {
|
||||
name: "autoId",
|
||||
type: FieldType.NUMBER,
|
||||
subtype: AutoFieldSubType.AUTO_ID,
|
||||
autocolumn: true,
|
||||
constraints: {
|
||||
type: FieldType.NUMBER,
|
||||
presence: true,
|
||||
},
|
||||
},
|
||||
name: {
|
||||
name: "name",
|
||||
type: FieldType.STRING,
|
||||
constraints: {
|
||||
type: FieldType.STRING,
|
||||
presence: true,
|
||||
},
|
||||
},
|
||||
aicol: {
|
||||
name: "aicol",
|
||||
type: FieldType.AI,
|
||||
operation: AIOperationEnum.PROMPT,
|
||||
prompt: "Test prompt"
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const data = [
|
||||
{ name: "Alice", aicol: "test" },
|
||||
{ name: "Bob", aicol: "test" },
|
||||
{ name: "Claire", aicol: "test" }
|
||||
]
|
||||
|
||||
const result = await importToRows(data, table, config.user?._id)
|
||||
expect(result).toEqual([
|
||||
expect.objectContaining({
|
||||
autoId: 1,
|
||||
name: "Alice",
|
||||
aicol: "test",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
autoId: 2,
|
||||
name: "Bob",
|
||||
aicol: "test",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
autoId: 3,
|
||||
name: "Claire",
|
||||
aicol: "test",
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue