Merge pull request #13425 from Budibase/fix-viewv2-api-get

Fix ViewV2API.get to hit the API instead of using the sdk.
This commit is contained in:
Sam Rose 2024-04-08 16:11:13 +01:00 committed by GitHub
commit 7f274e9ae7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 11 deletions

View File

@ -181,7 +181,7 @@ describe.each([
const createdView = await config.api.viewV2.create(newView)
expect(await config.api.viewV2.get(createdView.id)).toEqual({
expect(createdView).toEqual({
...newView,
schema: {
Price: {
@ -398,7 +398,7 @@ describe.each([
})
it("updates only UI schema overrides", async () => {
await config.api.viewV2.update({
const updatedView = await config.api.viewV2.update({
...view,
schema: {
Price: {
@ -417,7 +417,7 @@ describe.each([
} as Record<string, FieldSchema>,
})
expect(await config.api.viewV2.get(view.id)).toEqual({
expect(updatedView).toEqual({
...view,
schema: {
Price: {
@ -479,17 +479,17 @@ describe.each([
describe("fetch view (through table)", () => {
it("should be able to fetch a view V2", async () => {
const newView: CreateViewRequest = {
const res = await config.api.viewV2.create({
name: generator.name(),
tableId: table._id!,
schema: {
Price: { visible: false },
Category: { visible: true },
},
}
const res = await config.api.viewV2.create(newView)
})
expect(res.schema?.Price).toBeUndefined()
const view = await config.api.viewV2.get(res.id)
expect(view!.schema?.Price).toBeUndefined()
const updatedTable = await config.api.table.get(table._id!)
const viewSchema = updatedTable.views![view!.name!].schema as Record<
string,

View File

@ -4,9 +4,9 @@ import {
ViewV2,
SearchViewRowRequest,
PaginatedSearchRowResponse,
ViewResponseEnriched,
} from "@budibase/types"
import { Expectations, TestAPI } from "./base"
import sdk from "../../../sdk"
export class ViewV2API extends TestAPI {
create = async (
@ -45,9 +45,8 @@ export class ViewV2API extends TestAPI {
}
get = async (viewId: string) => {
return await this.config.doInContext(this.config.getAppId(), () =>
sdk.views.get(viewId)
)
return (await this._get<ViewResponseEnriched>(`/api/v2/views/${viewId}`))
.data
}
search = async (