Fix viewV2.spec.ts
This commit is contained in:
parent
330790214b
commit
021667c7d9
|
@ -2826,16 +2826,22 @@ if (descriptions.length) {
|
||||||
return total
|
return total
|
||||||
}
|
}
|
||||||
|
|
||||||
const assertRowUsage = async (expected: number) => {
|
async function expectRowUsage(
|
||||||
const usage = await getRowUsage()
|
expected: number,
|
||||||
|
f: () => Promise<void>
|
||||||
|
) {
|
||||||
|
const before = await getRowUsage()
|
||||||
|
await f()
|
||||||
|
const after = await getRowUsage()
|
||||||
|
const usage = after - before
|
||||||
expect(usage).toBe(expected)
|
expect(usage).toBe(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should be able to delete a row", async () => {
|
it("should be able to delete a row", async () => {
|
||||||
const createdRow = await config.api.row.save(table._id!, {})
|
const createdRow = await config.api.row.save(table._id!, {})
|
||||||
const rowUsage = await getRowUsage()
|
await expectRowUsage(isInternal ? 0 : -1, async () => {
|
||||||
await config.api.row.bulkDelete(view.id, { rows: [createdRow] })
|
await config.api.row.bulkDelete(view.id, { rows: [createdRow] })
|
||||||
await assertRowUsage(isInternal ? rowUsage - 1 : rowUsage)
|
})
|
||||||
await config.api.row.get(table._id!, createdRow._id!, {
|
await config.api.row.get(table._id!, createdRow._id!, {
|
||||||
status: 404,
|
status: 404,
|
||||||
})
|
})
|
||||||
|
@ -2847,14 +2853,13 @@ if (descriptions.length) {
|
||||||
config.api.row.save(table._id!, {}),
|
config.api.row.save(table._id!, {}),
|
||||||
config.api.row.save(table._id!, {}),
|
config.api.row.save(table._id!, {}),
|
||||||
])
|
])
|
||||||
const rowUsage = await getRowUsage()
|
|
||||||
|
|
||||||
await config.api.row.bulkDelete(view.id, {
|
await expectRowUsage(isInternal ? 0 : -2, async () => {
|
||||||
rows: [rows[0], rows[2]],
|
await config.api.row.bulkDelete(view.id, {
|
||||||
|
rows: [rows[0], rows[2]],
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
await assertRowUsage(isInternal ? rowUsage - 2 : rowUsage)
|
|
||||||
|
|
||||||
await config.api.row.get(table._id!, rows[0]._id!, {
|
await config.api.row.get(table._id!, rows[0]._id!, {
|
||||||
status: 404,
|
status: 404,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue