Test updating v1

This commit is contained in:
Adria Navarro 2023-07-25 15:49:32 +02:00
parent 6e24bf41df
commit 9235afb5d9
2 changed files with 30 additions and 1 deletions

View File

@ -169,6 +169,24 @@ describe("/v2/views", () => {
})
)
})
it("cannot update views v1", async () => {
const viewV1 = await config.createView()
await config.api.viewV2.update(
{
...viewV1,
},
{
expectStatus: 400,
handleResponse: r => {
expect(r.body).toEqual({
message: "Only views V2 can be updated",
status: 400,
})
},
}
)
})
})
describe("delete", () => {

View File

@ -2,6 +2,7 @@ import { CreateViewRequest, SortOrder, SortType, ViewV2 } from "@budibase/types"
import TestConfiguration from "../TestConfiguration"
import { TestAPI } from "./base"
import { generator } from "@budibase/backend-core/tests"
import { Response } from "superagent"
export class ViewV2API extends TestAPI {
constructor(config: TestConfiguration) {
@ -33,7 +34,13 @@ export class ViewV2API extends TestAPI {
update = async (
viewData?: Partial<ViewV2>,
{ expectStatus } = { expectStatus: 200 }
{
expectStatus,
handleResponse,
}: {
expectStatus: number
handleResponse?: (response: Response) => void
} = { expectStatus: 200 }
): Promise<ViewV2> => {
let tableId = viewData?.tableId
if (!tableId && !this.config.table) {
@ -51,6 +58,10 @@ export class ViewV2API extends TestAPI {
.set(this.config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(expectStatus)
if (handleResponse) {
handleResponse(result)
}
return result.body.data as ViewV2
}