Use test api for patch
This commit is contained in:
parent
9bb1cfcc7a
commit
77c2ce590c
|
@ -399,17 +399,12 @@ describe("/rows", () => {
|
|||
const rowUsage = await getRowUsage()
|
||||
const queryUsage = await getQueryUsage()
|
||||
|
||||
const res = await request
|
||||
.patch(`/api/${table._id}/rows`)
|
||||
.send({
|
||||
_id: existing._id,
|
||||
_rev: existing._rev,
|
||||
tableId: table._id,
|
||||
name: "Updated Name",
|
||||
})
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
const res = await config.api.row.patch(table._id!, {
|
||||
_id: existing._id,
|
||||
_rev: existing._rev,
|
||||
tableId: table._id,
|
||||
name: "Updated Name",
|
||||
})
|
||||
|
||||
expect((res as any).res.statusMessage).toEqual(
|
||||
`${table.name} updated successfully.`
|
||||
|
@ -430,16 +425,16 @@ describe("/rows", () => {
|
|||
const rowUsage = await getRowUsage()
|
||||
const queryUsage = await getQueryUsage()
|
||||
|
||||
await request
|
||||
.patch(`/api/${table._id}/rows`)
|
||||
.send({
|
||||
await config.api.row.patch(
|
||||
table._id!,
|
||||
{
|
||||
_id: existing._id,
|
||||
_rev: existing._rev,
|
||||
tableId: table._id,
|
||||
name: 1,
|
||||
})
|
||||
.set(config.defaultHeaders())
|
||||
.expect(400)
|
||||
},
|
||||
{ expectStatus: 400 }
|
||||
)
|
||||
|
||||
await assertRowUsage(rowUsage)
|
||||
await assertQueryUsage(queryUsage)
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import TestConfiguration from "../TestConfiguration"
|
||||
import { RowAPI } from "./row"
|
||||
import { TableAPI } from "./table"
|
||||
import { ViewV2API } from "./viewV2"
|
||||
|
||||
export default class API {
|
||||
table: TableAPI
|
||||
viewV2: ViewV2API
|
||||
row: RowAPI
|
||||
|
||||
constructor(config: TestConfiguration) {
|
||||
this.table = new TableAPI(config)
|
||||
this.viewV2 = new ViewV2API(config)
|
||||
this.row = new RowAPI(config)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
import { PatchRowRequest } from "@budibase/types"
|
||||
import TestConfiguration from "../TestConfiguration"
|
||||
import { TestAPI } from "./base"
|
||||
|
||||
export class RowAPI extends TestAPI {
|
||||
constructor(config: TestConfiguration) {
|
||||
super(config)
|
||||
}
|
||||
|
||||
patch = async (
|
||||
tableId: string,
|
||||
row: PatchRowRequest,
|
||||
{ expectStatus } = { expectStatus: 200 }
|
||||
) => {
|
||||
return this.request
|
||||
.patch(`/api/${tableId}/rows`)
|
||||
.send(row)
|
||||
.set(this.config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(expectStatus)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue