Remove :tableid from view create
This commit is contained in:
parent
6d973ce99a
commit
56e6d48ec7
|
@ -2,8 +2,8 @@ import sdk from "../../../sdk"
|
||||||
import { CreateViewRequest, Ctx, ViewResponse } from "@budibase/types"
|
import { CreateViewRequest, Ctx, ViewResponse } from "@budibase/types"
|
||||||
|
|
||||||
export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
|
export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
|
||||||
const { tableId } = ctx.params
|
|
||||||
const view = ctx.request.body
|
const view = ctx.request.body
|
||||||
|
const { tableId } = view
|
||||||
|
|
||||||
const result = await sdk.views.create(tableId, view)
|
const result = await sdk.views.create(tableId, view)
|
||||||
ctx.status = 201
|
ctx.status = 201
|
||||||
|
|
|
@ -743,12 +743,9 @@ describe("/rows", () => {
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create(
|
const createViewResponse = await config.api.viewV2.create({
|
||||||
config.table?._id!,
|
query: { equal: { age: 40 } },
|
||||||
{
|
})
|
||||||
query: { equal: { age: 40 } },
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const response = await config.api.viewV2.search(createViewResponse.id)
|
const response = await config.api.viewV2.search(createViewResponse.id)
|
||||||
|
|
||||||
|
@ -833,12 +830,9 @@ describe("/rows", () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const createViewResponse = await config.api.viewV2.create(
|
const createViewResponse = await config.api.viewV2.create({
|
||||||
config.table?._id!,
|
sort: sortParams,
|
||||||
{
|
})
|
||||||
sort: sortParams,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const response = await config.api.viewV2.search(createViewResponse.id)
|
const response = await config.api.viewV2.search(createViewResponse.id)
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ describe("/v2/views", () => {
|
||||||
name: generator.name(),
|
name: generator.name(),
|
||||||
tableId: config.table!._id!,
|
tableId: config.table!._id!,
|
||||||
}
|
}
|
||||||
const res = await config.api.viewV2.create(config.table?._id, newView)
|
const res = await config.api.viewV2.create(newView)
|
||||||
|
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
...newView,
|
...newView,
|
||||||
|
@ -71,7 +71,7 @@ describe("/v2/views", () => {
|
||||||
tableId: config.table!._id!,
|
tableId: config.table!._id!,
|
||||||
...viewFilters,
|
...viewFilters,
|
||||||
}
|
}
|
||||||
const res = await config.api.viewV2.create(config.table!._id!, newView)
|
const res = await config.api.viewV2.create(newView)
|
||||||
|
|
||||||
expect(res).toEqual({
|
expect(res).toEqual({
|
||||||
...newView,
|
...newView,
|
||||||
|
|
|
@ -9,7 +9,7 @@ const router: Router = new Router()
|
||||||
|
|
||||||
router
|
router
|
||||||
.post(
|
.post(
|
||||||
"/api/v2/views/:tableId",
|
"/api/v2/views",
|
||||||
authorized(permissions.BUILDER),
|
authorized(permissions.BUILDER),
|
||||||
viewController.v2.create
|
viewController.v2.create
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,10 +9,10 @@ export class ViewV2API extends TestAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
create = async (
|
create = async (
|
||||||
tableId?: string,
|
|
||||||
viewData?: Partial<ViewV2>,
|
viewData?: Partial<ViewV2>,
|
||||||
{ expectStatus } = { expectStatus: 201 }
|
{ expectStatus } = { expectStatus: 201 }
|
||||||
): Promise<ViewV2> => {
|
): Promise<ViewV2> => {
|
||||||
|
let tableId = viewData?.tableId
|
||||||
if (!tableId && !this.config.table) {
|
if (!tableId && !this.config.table) {
|
||||||
throw "Test requires table to be configured."
|
throw "Test requires table to be configured."
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ export class ViewV2API extends TestAPI {
|
||||||
...viewData,
|
...viewData,
|
||||||
}
|
}
|
||||||
const result = await this.request
|
const result = await this.request
|
||||||
.post(`/api/v2/views/${tableId}`)
|
.post(`/api/v2/views`)
|
||||||
.send(view)
|
.send(view)
|
||||||
.set(this.config.defaultHeaders())
|
.set(this.config.defaultHeaders())
|
||||||
.expect("Content-Type", /json/)
|
.expect("Content-Type", /json/)
|
||||||
|
|
Loading…
Reference in New Issue