Adding test case for fetch.

This commit is contained in:
mike12345567 2024-10-28 18:09:38 +00:00
parent 0698454855
commit 68a7f88db6
2 changed files with 39 additions and 0 deletions

View File

@ -2592,6 +2592,38 @@ describe.each([
})
})
describe("fetch", () => {
let view: ViewV2, view2: ViewV2
let table: Table, table2: Table
beforeEach(async () => {
// clean app to make sure fixed amount of views
await config.init()
table = await config.api.table.save(saveTableRequest())
table2 = await config.api.table.save(saveTableRequest())
view = await config.api.viewV2.create({
tableId: table._id!,
name: generator.guid(),
schema: {},
})
view2 = await config.api.viewV2.create({
tableId: table2._id!,
name: generator.guid(),
schema: {},
})
})
it("should be able to list views", async () => {
const response = await config.api.viewV2.fetch({
status: 200,
})
expect(response.data.length).toEqual(2)
expect(response.data.find(v => v.id === view.id)).toBeDefined()
expect(response.data.find(v => v.id === view2.id)).toBeDefined()
})
})
describe("read", () => {
let view: ViewV2
let table: Table

View File

@ -5,6 +5,7 @@ import {
SearchViewRowRequest,
PaginatedSearchRowResponse,
ViewResponseEnriched,
ViewFetchResponseEnriched,
} from "@budibase/types"
import { Expectations, TestAPI } from "./base"
@ -49,6 +50,12 @@ export class ViewV2API extends TestAPI {
.data
}
fetch = async (expectations?: Expectations) => {
return await this._get<ViewFetchResponseEnriched>(`/api/v2/views`, {
expectations,
})
}
search = async (
viewId: string,
params?: SearchViewRowRequest,