diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 5d924f444a..59fadbc37d 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -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", () => { diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index 445a806428..bca1a97a61 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -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, - { expectStatus } = { expectStatus: 200 } + { + expectStatus, + handleResponse, + }: { + expectStatus: number + handleResponse?: (response: Response) => void + } = { expectStatus: 200 } ): Promise => { 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 }