diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index a83795cb9a..dd3cf3b658 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -127,11 +127,15 @@ describe("/v2/views", () => { }) it("can delete an existing view", async () => { - await config.api.viewV2.get(view.id, { expectStatus: 200 }) + const tableId = config.table!._id! + const getPersistedView = async () => + (await config.api.table.get(tableId)).views![view.name] - await config.api.viewV2.delete(config.table?._id!, view.id) + expect(await getPersistedView()).toBeDefined() - await config.api.viewV2.get(view.id, { expectStatus: 404 }) + await config.api.viewV2.delete(tableId, view.id) + + expect(await getPersistedView()).toBeUndefined() }) }) }) diff --git a/packages/server/src/tests/utilities/api/index.ts b/packages/server/src/tests/utilities/api/index.ts index f759abd47c..cd9f42b82c 100644 --- a/packages/server/src/tests/utilities/api/index.ts +++ b/packages/server/src/tests/utilities/api/index.ts @@ -1,10 +1,13 @@ import TestConfiguration from "../TestConfiguration" +import { TableAPI } from "./table" import { ViewV2API } from "./viewV2" export default class API { + table: TableAPI viewV2: ViewV2API constructor(config: TestConfiguration) { + this.table = new TableAPI(config) this.viewV2 = new ViewV2API(config) } } diff --git a/packages/server/src/tests/utilities/api/table.ts b/packages/server/src/tests/utilities/api/table.ts new file mode 100644 index 0000000000..7e3ef6efa4 --- /dev/null +++ b/packages/server/src/tests/utilities/api/table.ts @@ -0,0 +1,21 @@ +import { Table } from "@budibase/types" +import TestConfiguration from "../TestConfiguration" +import { TestAPI } from "./base" + +export class TableAPI extends TestAPI { + constructor(config: TestConfiguration) { + super(config) + } + + get = async ( + tableId: string, + { expectStatus } = { expectStatus: 200 } + ): Promise => { + const res = await this.request + .get(`/api/tables/${tableId}`) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(expectStatus) + return res.body + } +}