Adding test case to confirm works as expected.
This commit is contained in:
parent
b975132329
commit
9ec77c45c8
|
@ -1,11 +1,12 @@
|
||||||
import { context } from "@budibase/backend-core"
|
import { context } from "@budibase/backend-core"
|
||||||
import { isExternalTableID } from "../../../integrations/utils"
|
import { isExternalTableID } from "../../../integrations/utils"
|
||||||
import { APP_PREFIX, DocumentType } from "../../../db/utils"
|
import { APP_PREFIX, DocumentType } from "../../../db/utils"
|
||||||
|
import { Row } from "@budibase/types"
|
||||||
|
|
||||||
export async function addRev(
|
export async function addRev(
|
||||||
body: { _id?: string; _rev?: string },
|
body: { _id?: string; _rev?: string },
|
||||||
tableId?: string
|
tableId?: string
|
||||||
) {
|
): Promise<Row> {
|
||||||
if (!body._id || (tableId && isExternalTableID(tableId))) {
|
if (!body._id || (tableId && isExternalTableID(tableId))) {
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,10 @@ async function processDeleteRowsRequest(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
: fixRow(processedRow, ctx.params)
|
: fixRow(processedRow, ctx.params)
|
||||||
})
|
})
|
||||||
|
|
||||||
return await Promise.all(processedRows)
|
const responses = await Promise.allSettled(processedRows)
|
||||||
|
return responses
|
||||||
|
.filter(resp => resp.status === "fulfilled")
|
||||||
|
.map(resp => (resp as PromiseFulfilledResult<Row>).value)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteRows(ctx: UserCtx<DeleteRowRequest>) {
|
async function deleteRows(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
|
|
|
@ -636,6 +636,17 @@ describe.each([
|
||||||
expect(res[0]._id).toEqual(createdRow._id)
|
expect(res[0]._id).toEqual(createdRow._id)
|
||||||
await assertRowUsage(rowUsage - 1)
|
await assertRowUsage(rowUsage - 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should be able to bulk delete rows, including a row that doesn't exist", async () => {
|
||||||
|
const createdRow = await config.createRow()
|
||||||
|
|
||||||
|
const res = await config.api.row.bulkDelete(table._id!, {
|
||||||
|
rows: [createdRow, { _id: "2" }],
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(res[0]._id).toEqual(createdRow._id)
|
||||||
|
expect(res.length).toEqual(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("validate", () => {
|
describe("validate", () => {
|
||||||
|
|
Loading…
Reference in New Issue