Remove get from delete tests

This commit is contained in:
Adria Navarro 2023-07-19 15:47:45 +02:00
parent 76f89e10d3
commit 56ee61d76c
3 changed files with 31 additions and 3 deletions

View File

@ -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()
})
})
})

View File

@ -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)
}
}

View File

@ -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<Table> => {
const res = await this.request
.get(`/api/tables/${tableId}`)
.set(this.config.defaultHeaders())
.expect("Content-Type", /json/)
.expect(expectStatus)
return res.body
}
}