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 rowUsage = await getRowUsage()
|
||||||
const queryUsage = await getQueryUsage()
|
const queryUsage = await getQueryUsage()
|
||||||
|
|
||||||
const res = await request
|
const res = await config.api.row.patch(table._id!, {
|
||||||
.patch(`/api/${table._id}/rows`)
|
_id: existing._id,
|
||||||
.send({
|
_rev: existing._rev,
|
||||||
_id: existing._id,
|
tableId: table._id,
|
||||||
_rev: existing._rev,
|
name: "Updated Name",
|
||||||
tableId: table._id,
|
})
|
||||||
name: "Updated Name",
|
|
||||||
})
|
|
||||||
.set(config.defaultHeaders())
|
|
||||||
.expect("Content-Type", /json/)
|
|
||||||
.expect(200)
|
|
||||||
|
|
||||||
expect((res as any).res.statusMessage).toEqual(
|
expect((res as any).res.statusMessage).toEqual(
|
||||||
`${table.name} updated successfully.`
|
`${table.name} updated successfully.`
|
||||||
|
@ -430,16 +425,16 @@ describe("/rows", () => {
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
const queryUsage = await getQueryUsage()
|
const queryUsage = await getQueryUsage()
|
||||||
|
|
||||||
await request
|
await config.api.row.patch(
|
||||||
.patch(`/api/${table._id}/rows`)
|
table._id!,
|
||||||
.send({
|
{
|
||||||
_id: existing._id,
|
_id: existing._id,
|
||||||
_rev: existing._rev,
|
_rev: existing._rev,
|
||||||
tableId: table._id,
|
tableId: table._id,
|
||||||
name: 1,
|
name: 1,
|
||||||
})
|
},
|
||||||
.set(config.defaultHeaders())
|
{ expectStatus: 400 }
|
||||||
.expect(400)
|
)
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
await assertQueryUsage(queryUsage)
|
await assertQueryUsage(queryUsage)
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
import TestConfiguration from "../TestConfiguration"
|
||||||
|
import { RowAPI } from "./row"
|
||||||
import { TableAPI } from "./table"
|
import { TableAPI } from "./table"
|
||||||
import { ViewV2API } from "./viewV2"
|
import { ViewV2API } from "./viewV2"
|
||||||
|
|
||||||
export default class API {
|
export default class API {
|
||||||
table: TableAPI
|
table: TableAPI
|
||||||
viewV2: ViewV2API
|
viewV2: ViewV2API
|
||||||
|
row: RowAPI
|
||||||
|
|
||||||
constructor(config: TestConfiguration) {
|
constructor(config: TestConfiguration) {
|
||||||
this.table = new TableAPI(config)
|
this.table = new TableAPI(config)
|
||||||
this.viewV2 = new ViewV2API(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