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:
commit
7f274e9ae7
|
@ -181,7 +181,7 @@ describe.each([
|
||||||
|
|
||||||
const createdView = await config.api.viewV2.create(newView)
|
const createdView = await config.api.viewV2.create(newView)
|
||||||
|
|
||||||
expect(await config.api.viewV2.get(createdView.id)).toEqual({
|
expect(createdView).toEqual({
|
||||||
...newView,
|
...newView,
|
||||||
schema: {
|
schema: {
|
||||||
Price: {
|
Price: {
|
||||||
|
@ -398,7 +398,7 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
it("updates only UI schema overrides", async () => {
|
it("updates only UI schema overrides", async () => {
|
||||||
await config.api.viewV2.update({
|
const updatedView = await config.api.viewV2.update({
|
||||||
...view,
|
...view,
|
||||||
schema: {
|
schema: {
|
||||||
Price: {
|
Price: {
|
||||||
|
@ -417,7 +417,7 @@ describe.each([
|
||||||
} as Record<string, FieldSchema>,
|
} as Record<string, FieldSchema>,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(await config.api.viewV2.get(view.id)).toEqual({
|
expect(updatedView).toEqual({
|
||||||
...view,
|
...view,
|
||||||
schema: {
|
schema: {
|
||||||
Price: {
|
Price: {
|
||||||
|
@ -479,17 +479,17 @@ describe.each([
|
||||||
|
|
||||||
describe("fetch view (through table)", () => {
|
describe("fetch view (through table)", () => {
|
||||||
it("should be able to fetch a view V2", async () => {
|
it("should be able to fetch a view V2", async () => {
|
||||||
const newView: CreateViewRequest = {
|
const res = await config.api.viewV2.create({
|
||||||
name: generator.name(),
|
name: generator.name(),
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
schema: {
|
schema: {
|
||||||
Price: { visible: false },
|
Price: { visible: false },
|
||||||
Category: { visible: true },
|
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)
|
const view = await config.api.viewV2.get(res.id)
|
||||||
expect(view!.schema?.Price).toBeUndefined()
|
|
||||||
const updatedTable = await config.api.table.get(table._id!)
|
const updatedTable = await config.api.table.get(table._id!)
|
||||||
const viewSchema = updatedTable.views![view!.name!].schema as Record<
|
const viewSchema = updatedTable.views![view!.name!].schema as Record<
|
||||||
string,
|
string,
|
||||||
|
|
|
@ -4,9 +4,9 @@ import {
|
||||||
ViewV2,
|
ViewV2,
|
||||||
SearchViewRowRequest,
|
SearchViewRowRequest,
|
||||||
PaginatedSearchRowResponse,
|
PaginatedSearchRowResponse,
|
||||||
|
ViewResponseEnriched,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { Expectations, TestAPI } from "./base"
|
import { Expectations, TestAPI } from "./base"
|
||||||
import sdk from "../../../sdk"
|
|
||||||
|
|
||||||
export class ViewV2API extends TestAPI {
|
export class ViewV2API extends TestAPI {
|
||||||
create = async (
|
create = async (
|
||||||
|
@ -45,9 +45,8 @@ export class ViewV2API extends TestAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
get = async (viewId: string) => {
|
get = async (viewId: string) => {
|
||||||
return await this.config.doInContext(this.config.getAppId(), () =>
|
return (await this._get<ViewResponseEnriched>(`/api/v2/views/${viewId}`))
|
||||||
sdk.views.get(viewId)
|
.data
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
search = async (
|
search = async (
|
||||||
|
|
Loading…
Reference in New Issue