Migrate LegacyViewAPI
This commit is contained in:
parent
4fbe03bbda
commit
1a2a77fc91
|
@ -757,16 +757,16 @@ describe.each([
|
||||||
const row = await config.createRow()
|
const row = await config.createRow()
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
|
|
||||||
const res = await config.api.legacyView.get(table._id!)
|
const rows = await config.api.legacyView.get(table._id!)
|
||||||
expect(res.body.length).toEqual(1)
|
expect(rows.length).toEqual(1)
|
||||||
expect(res.body[0]._id).toEqual(row._id)
|
expect(rows[0]._id).toEqual(row._id)
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should throw an error if view doesn't exist", async () => {
|
it("should throw an error if view doesn't exist", async () => {
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
|
|
||||||
await config.api.legacyView.get("derp", { expectStatus: 404 })
|
await config.api.legacyView.get("derp", { status: 404 })
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
})
|
})
|
||||||
|
@ -781,9 +781,9 @@ describe.each([
|
||||||
const row = await config.createRow()
|
const row = await config.createRow()
|
||||||
const rowUsage = await getRowUsage()
|
const rowUsage = await getRowUsage()
|
||||||
|
|
||||||
const res = await config.api.legacyView.get(view.name)
|
const rows = await config.api.legacyView.get(view.name)
|
||||||
expect(res.body.length).toEqual(1)
|
expect(rows.length).toEqual(1)
|
||||||
expect(res.body[0]._id).toEqual(row._id)
|
expect(rows[0]._id).toEqual(row._id)
|
||||||
|
|
||||||
await assertRowUsage(rowUsage)
|
await assertRowUsage(rowUsage)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1054,7 +1054,7 @@ describe("postgres integrations", () => {
|
||||||
|
|
||||||
it("should state an invalid datasource cannot connect", async () => {
|
it("should state an invalid datasource cannot connect", async () => {
|
||||||
const dbConfig = await databaseTestProviders.postgres.datasource()
|
const dbConfig = await databaseTestProviders.postgres.datasource()
|
||||||
const response = await config.api.datasource.verify(
|
await config.api.datasource.verify(
|
||||||
{
|
{
|
||||||
datasource: {
|
datasource: {
|
||||||
...dbConfig,
|
...dbConfig,
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
import { Expectations, TestAPI } from "./base"
|
||||||
import { TestAPI } from "./base"
|
import { Row } from "@budibase/types"
|
||||||
|
|
||||||
export class LegacyViewAPI extends TestAPI {
|
export class LegacyViewAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
get = async (id: string, expectations?: Expectations) => {
|
||||||
super(config)
|
return await this._get<Row[]>(`/api/views/${id}`, { expectations })
|
||||||
}
|
|
||||||
|
|
||||||
get = async (id: string, { expectStatus } = { expectStatus: 200 }) => {
|
|
||||||
return await this.request
|
|
||||||
.get(`/api/views/${id}`)
|
|
||||||
.set(this.config.defaultHeaders())
|
|
||||||
.expect("Content-Type", /json/)
|
|
||||||
.expect(expectStatus)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue